Example usage for org.apache.wicket.util.tester DummyHomePage DummyHomePage

List of usage examples for org.apache.wicket.util.tester DummyHomePage DummyHomePage

Introduction

In this page you can find the example usage for org.apache.wicket.util.tester DummyHomePage DummyHomePage.

Prototype

public DummyHomePage() 

Source Link

Document

Constructor.

Usage

From source file:org.cdlflex.ui.util.convert.EnumRendererTest.java

License:Apache License

@Test
public void converToString_withLocalizationProvider_noProperties_rendersKeys() throws Exception {
    Component component = new DummyHomePage();

    EnumRenderer<TestEnum> renderer = new EnumRenderer<>(component);
    assertEquals("FOO", renderer.convertToString(TestEnum.FOO));
    assertEquals("BAR_ED", renderer.convertToString(TestEnum.BAR_ED));
    assertEquals("BAZ_", renderer.convertToString(TestEnum.BAZ_));
}

From source file:org.laughingpanda.kansanpankki.account.AccountPageSpec.java

License:Apache License

@Override
protected AccountPage newComponent(String id, IModel<Account> model) {
    dummyPage = new DummyHomePage();
    return new AccountPage(model, dummyPage);
}

From source file:org.obiba.onyx.webapp.participant.panel.EditParticipantPanelTest.java

License:Open Source License

@SuppressWarnings("serial")
@Test//  www  .  j  a v a2 s . c om
@Ignore("refactor - fragile")
public void testEditParticipant() {
    p.setEnrollmentId("10001010");
    p.setBarcode("1234");
    p.setRecruitmentType(RecruitmentType.ENROLLED);

    // We expect the updateParticipant method to be called once
    expect(mockUserSessionService.getDateFormat()).andReturn(new SimpleDateFormat("yyyy-MM-dd")).anyTimes();
    expect(mockUserSessionService.getDatePattern()).andReturn("yyyy-MM-dd").atLeastOnce();
    expect(mockUserSessionService.getUserName()).andReturn("user").anyTimes();
    mockParticipantService.updateParticipant(p);
    expect(mockQueryService.matchOne((ApplicationConfiguration) EasyMock.anyObject()))
            .andReturn(new ApplicationConfiguration());

    EasyMock.replay(mockUserSessionService);
    EasyMock.replay(mockParticipantService);
    EasyMock.replay(mockQueryService);

    tester.startPanel(new TestPanelSource() {
        public Panel getTestPanel(String panelId) {
            DummyHomePage dummyHomePage = new DummyHomePage();
            EditParticipantFormPanel panel = new EditParticipantFormPanel(panelId, new Model(p), dummyHomePage);

            // We have to remove the feedback dialog because it is confusing the WicketTester when we try to submit the form
            // in the EditParticipantFormPanel. The feedback dialog contains a useless form (all Dialogs include a form).
            panel.get("editParticipantForm:editParticipantPanel:feedback")
                    .replaceWith(new EmptyPanel("feedback"));
            return panel;
        }
    });

    FormTester formTester = tester.newFormTester("panel:editParticipantForm");
    formTester.select(
            "editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:1:field:input:select",
            3);
    formTester.setValue(
            "editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:2:field:input:field",
            "Peel street");

    // test EditParticipantPanel in EDIT mode => no editable field (except gender and birthdate)
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:firstName:value", Label.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:lastName:value", Label.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:gender:gender",
            DropDownChoice.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:birthDate:value",
            DateTextField.class);
    tester.assertInvisible("panel:editParticipantForm:editParticipantPanel:assignCodeToParticipantPanel");

    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:1:field:input:select",
            DropDownChoice.class);
    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:2:field:input:field",
            TextField.class);
    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:3:field:input:field",
            TextField.class);
    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:4:field",
            Label.class);

    tester.executeAjaxEvent("panel:editParticipantForm:saveAction", "onclick");
    tester.assertNoErrorMessage();

    EasyMock.verify(mockUserSessionService);
    EasyMock.verify(mockParticipantService);
    EasyMock.verify(mockQueryService);

    // TODO Make this test work: implement the sort option on the allowed values set
    // Assert.assertEquals("NB", p.getConfiguredAttributeValue("Province").getValueAsString());
    Assert.assertEquals("Peel street", p.getConfiguredAttributeValue("Street").getValueAsString());
}

From source file:org.obiba.onyx.webapp.participant.panel.EditParticipantPanelTest.java

License:Open Source License

@Ignore("refactor - fragile")
@SuppressWarnings("serial")
@Test//from   w ww. j  a  v  a  2 s .  c  o  m
public void testReceiveParticipant() {
    p.setBarcode(null);
    p.setRecruitmentType(RecruitmentType.ENROLLED);

    // We expect the updateParticipant method to be called once
    mockParticipantService.updateParticipant(p);
    expect(mockQueryService.matchOne((ApplicationConfiguration) EasyMock.anyObject()))
            .andReturn(new ApplicationConfiguration());
    expect(mockQueryService.count((Participant) EasyMock.anyObject())).andReturn(0);
    mockParticipantService.assignCodeToParticipant(p, "B12345678", null, null);

    EasyMock.replay(mockParticipantService);
    EasyMock.replay(mockQueryService);

    tester.startPanel(new TestPanelSource() {
        public Panel getTestPanel(String panelId) {
            DummyHomePage dummyHomePage = new DummyHomePage();
            EditParticipantFormPanel panel = new EditParticipantFormPanel(panelId, new Model(p), dummyHomePage);
            panel.get("editParticipantForm:editParticipantPanel:assignCodeToParticipantPanel")
                    .replaceWith(new AssignCodeToParticipantPanelMock("assignCodeToParticipantPanel",
                            new Model(p), new Model(participantMetadata)));

            // We have to remove the feedback dialog because it is confusing the WicketTester when we try to submit the form
            // in the EditParticipantFormPanel. The feedback dialog contains a useless form (all Dialogs include a form).
            panel.get("editParticipantForm:editParticipantPanel:feedback")
                    .replaceWith(new EmptyPanel("feedback"));
            return panel;
        }
    });

    // test EditParticipantPanel RECEPTION mode => enrollementId and assignCodeToParticipantPanel are shown, all fields
    // are editable

    FormTester formTester = tester.newFormTester("panel:editParticipantForm");
    formTester.setValue("editParticipantPanel:firstName:value", "Martine");
    formTester.select("editParticipantPanel:gender:gender", 0);
    formTester.setValue(
            "editParticipantPanel:assignCodeToParticipantPanel:assignCodeToParticipantForm:participantCode",
            "B12345678");
    formTester.setValue(
            "editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:2:field:input:field",
            "Peel street");
    formTester.setValue(
            "editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:4:field:input:field",
            "514-398-3311 ext 00721");

    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:enrollmentId:value", Label.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:firstName:value", TextField.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:lastName:value", TextField.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:gender:gender",
            DropDownChoice.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:birthDate:value",
            DateTextField.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:assignCodeToParticipantPanel",
            AssignCodeToParticipantPanel.class);

    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:1:field:input:select",
            DropDownChoice.class);
    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:2:field:input:field",
            TextField.class);
    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:3:field",
            Label.class);
    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:4:field:input:field",
            TextField.class);

    tester.executeAjaxEvent("panel:editParticipantForm:saveAction", "onclick");
    tester.assertNoErrorMessage();

    EasyMock.verify(mockParticipantService);
    EasyMock.verify(mockQueryService);

    Assert.assertEquals("Martine", p.getFirstName());
    Assert.assertEquals(Gender.FEMALE, p.getGender());
    Assert.assertEquals("Peel street", p.getConfiguredAttributeValue("Street").getValueAsString());
    Assert.assertEquals("514-398-3311 ext 00721", p.getConfiguredAttributeValue("Phone").getValueAsString());
}

From source file:org.obiba.onyx.webapp.participant.panel.EditParticipantPanelTest.java

License:Open Source License

@Ignore("refactor - fragile")
@SuppressWarnings("serial")
@Test/*w w w . j  a  v  a 2 s  . c o  m*/
public void testEnrollVolunteerParticipant() {
    p.setEnrollmentId(null);
    p.setBarcode(null);
    p.setRecruitmentType(RecruitmentType.VOLUNTEER);

    // We expect the updateParticipant method to be called once
    mockParticipantService.updateParticipant(p);
    expect(mockQueryService.matchOne((ApplicationConfiguration) EasyMock.anyObject()))
            .andReturn(new ApplicationConfiguration());
    expect(mockQueryService.count((Participant) EasyMock.anyObject())).andReturn(0);
    mockParticipantService.assignCodeToParticipant(p, "B12345678", null, null);

    EasyMock.replay(mockParticipantService);
    EasyMock.replay(mockQueryService);

    tester.startPanel(new TestPanelSource() {
        public Panel getTestPanel(String panelId) {
            DummyHomePage dummyHomePage = new DummyHomePage();
            EditParticipantFormPanel panel = new EditParticipantFormPanel(panelId, new Model(p), dummyHomePage);
            panel.get("editParticipantForm:editParticipantPanel:assignCodeToParticipantPanel")
                    .replaceWith(new AssignCodeToParticipantPanelMock("assignCodeToParticipantPanel",
                            new Model(p), new Model(participantMetadata)));

            // We have to remove the feedback dialog because it is confusing the WicketTester when we try to submit the form
            // in the EditParticipantFormPanel. The feedback dialog contains a useless form (all Dialogs include a form).
            panel.get("editParticipantForm:editParticipantPanel:feedback")
                    .replaceWith(new EmptyPanel("feedback"));
            return panel;
        }
    });

    // test EditParticipantPanel in ENROLLMENT mode => enrollementId not shown, all fields editable
    // assignCodeToParticipantPanel should be shown

    tester.dumpPage();
    FormTester formTester = tester.newFormTester("panel:editParticipantForm");
    formTester.setValue("editParticipantPanel:firstName:value", "Martin");
    formTester.setValue("editParticipantPanel:lastName:value", "Dupont");
    formTester.select("editParticipantPanel:gender:gender", 1);
    formTester.setValue("editParticipantPanel:birthDate:value", "1979-05-05");
    formTester.setValue(
            "editParticipantPanel:assignCodeToParticipantPanel:assignCodeToParticipantForm:participantCode",
            "B12345678");
    formTester.setValue(
            "editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:2:field:input:field",
            "Peel street");
    formTester.setValue(
            "editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:4:field:input:field",
            "514-398-3311 ext 00721");

    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:firstName:value", TextField.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:lastName:value", TextField.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:gender:gender",
            DropDownChoice.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:birthDate:value",
            DateTextField.class);
    tester.assertComponent("panel:editParticipantForm:editParticipantPanel:assignCodeToParticipantPanel",
            AssignCodeToParticipantPanel.class);
    tester.assertVisible("panel:editParticipantForm:editParticipantPanel:assignCodeToParticipantPanel");

    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:1:field:input:select",
            DropDownChoice.class);
    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:2:field:input:field",
            TextField.class);
    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:3:field",
            Label.class);
    tester.assertComponent(
            "panel:editParticipantForm:editParticipantPanel:configuredAttributeGroups:groupRepeater:1:group:attributeRepeater:4:field:input:field",
            TextField.class);

    Assert.assertNull(formTester.getForm().get("enrollmentId:value"));

    tester.executeAjaxEvent("panel:editParticipantForm:saveAction", "onclick");
    tester.assertNoErrorMessage();

    EasyMock.verify(mockParticipantService);
    EasyMock.verify(mockQueryService);

    Assert.assertEquals("Martin", p.getFirstName());
    Assert.assertEquals(Gender.MALE, p.getGender());
    Assert.assertEquals("Peel street", p.getConfiguredAttributeValue("Street").getValueAsString());
    Assert.assertEquals("514-398-3311 ext 00721", p.getConfiguredAttributeValue("Phone").getValueAsString());
}

From source file:org.webical.test.web.WebicalApplicationTest.java

License:Open Source License

@Override
protected void setUp() throws Exception {
    //Setup a mock injector
    InjectorHolder.setInjector(new ConfigurableInjector() {
        @Override/*from  w ww. jav a  2s  .co m*/
        protected IFieldValueFactory getFieldValueFactory() {
            return new IFieldValueFactory() {

                public Object getFieldValue(Field field, Object fieldOwner) {
                    return null;
                }

                public boolean supportsField(Field field) {
                    return false;
                }
            };
        }
    });

    //Set up the WicketTester
    wicketTester = new WicketTester(new WicketTester.DummyWebApplication() {
        //** override so that a WebicalSession is returned */
        /* (non-Javadoc)
         * @see wicket.protocol.http.WebApplication#newSession()
         */
        @Override
        public Session newSession(Request request, Response response) {
            if (WebicalApplicationTest.this.webicalSession == null) {
                WebicalApplicationTest.this.webicalSession = new WebicalSession(request, TestUtils.USERID_JAG);
                WebicalApplicationTest.this.webicalSession.setUserManager(new MockUserManager());
                WebicalApplicationTest.this.webicalSession.setSettingsManager(new MockSettingsManager());
                WebicalApplicationTest.this.webicalSession.setAccessible(true);
            }
            return WebicalApplicationTest.this.webicalSession;
        }
    });

    // Locale for test is en_uk
    getTestSession().setLocale(Locale.UK);
    dateFormat = DateFormat.getDateInstance(DateFormat.LONG, getTestSession().getLocale());
    dateFormatFull = DateFormat.getDateInstance(DateFormat.FULL, getTestSession().getLocale());

    //Couple an Injector to inject the spring beans
    wicketTester.getApplication().addComponentInstantiationListener(new ComponentInjector());

    //Initialize the mock context
    annotApplicationContextMock = new AnnotApplicationContextMock();

    //Initialize the ApplicationSettings
    TestUtils.initializeApplicationSettingsFactory(new ApplicationSettings());

    //Register some dummy beans
    annotApplicationContextMock.putBean("settingsManager", getTestSession().getSettingsManager());
    annotApplicationContextMock.putBean("userManager", getTestSession().getUserManager());

    //Set the dummy page by default
    dummyHomePage = new DummyHomePage();

    //The context working directory
    contextWorkDir = new File(TestUtils.WORKINGDIRECTORY);
    wicketTester.getApplication().getServletContext().setAttribute("javax.servlet.context.tempdir",
            contextWorkDir);
    contextWorkDir = (File) wicketTester.getApplication().getServletContext()
            .getAttribute("javax.servlet.context.tempdir");
}