/** * Tests that organizational units information is properly loaded when the page is initialized. */ @Test public void testPageLoad() { when(organizationalUnitService.getOrganizationalUnits()).thenReturn(organizationalUnits); infoPage.prepareView(); verify(view, times(1)).init(infoPage); verify(view).initOrganizationalUnits(eq(organizationalUnitsInfo)); verify(statusChangeHandler, never()).handleEvent(any(WizardPageStatusChangeEvent.class)); assertPageComplete(false, infoPage); }
/** * Tests that the page reacts properly when the selected organizational unit changes. */ @Test public void testOrganizationalUnitChange() { when(organizationalUnitService.getOrganizationalUnits()).thenReturn(organizationalUnits); when(view.getOrganizationalUnitName()).thenReturn("OrganizationalUnit1"); infoPage.prepareView(); infoPage.onOUChange(); verify(view, times(1)).getOrganizationalUnitName(); verify(statusChangeHandler, times(1)).handleEvent(any(WizardPageStatusChangeEvent.class)); assertEquals(organizationalUnits.get(0), model.getOrganizationalUnit()); assertPageComplete(false, infoPage); }
/** * Tests that the page reacts properly when there is no selected organizational unit. */ @Test public void testNoSelectedOrganizationalUnit() { when(organizationalUnitService.getOrganizationalUnits()).thenReturn(organizationalUnits); when(view.getOrganizationalUnitName()).thenReturn(RepositoryInfoPageView.NOT_SELECTED); infoPage.prepareView(); infoPage.onOUChange(); verify(view, times(1)).getOrganizationalUnitName(); verify(statusChangeHandler, never()).handleEvent(any(WizardPageStatusChangeEvent.class)); assertEquals(null, model.getOrganizationalUnit()); assertPageComplete(false, infoPage); }
/** * Test a sequence of steps that will successfully complete the page. */ @Test public void testPageCompleted() { when(organizationalUnitService.getOrganizationalUnits()).thenReturn(organizationalUnits); when(repositoryService.validateRepositoryName("ValidRepo")).thenReturn(true); when(view.getOrganizationalUnitName()).thenReturn("OrganizationalUnit1"); when(view.getName()).thenReturn("ValidRepo"); infoPage.prepareView(); infoPage.onNameChange(); infoPage.onOUChange(); verify(statusChangeHandler, times(2)).handleEvent(any(WizardPageStatusChangeEvent.class)); assertEquals(organizationalUnits.get(0), model.getOrganizationalUnit()); assertEquals("ValidRepo", model.getRepositoryName()); assertPageComplete(true, infoPage); }