/** * Tests that the page reacts properly when a valid repository name is entered. */ @Test public void testValidRepositoryNameChange() { when(repositoryService.validateRepositoryName("ValidRepo")).thenReturn(true); when(repositoryService.validateRepositoryName("InvalidRepo")).thenReturn(false); when(view.getName()).thenReturn("ValidRepo"); infoPage.onNameChange(); verify(view, times(2)).getName(); verify(view, times(1)).clearNameErrorMessage(); verify(statusChangeHandler, times(1)).handleEvent(any(WizardPageStatusChangeEvent.class)); assertEquals("ValidRepo", model.getRepositoryName()); 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); }
/** * Tests that the page reacts properly when an invalid repository name is typed. */ @Test public void testInvalidRepositoryNameChange() { when(repositoryService.validateRepositoryName("ValidRepo")).thenReturn(true); when(repositoryService.validateRepositoryName("InvalidRepo")).thenReturn(false); when(view.getName()).thenReturn("InvalidRepo"); infoPage.onNameChange(); verify(view, times(2)).getName(); verify(view, times(1)).setNameErrorMessage(anyString()); verify(statusChangeHandler, never()).handleEvent(any(WizardPageStatusChangeEvent.class)); assertEquals("InvalidRepo", model.getRepositoryName()); 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); }
/** * 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 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 managed repository option is checked. */ @Test public void testManagedRepositorySelected() { testManagedRepositoryChange(true); verify(statusChangeHandler, times(1)).handleEvent(any(WizardPageStatusChangeEvent.class)); }
@Override public void fire(WizardPageStatusChangeEvent wizardPageStatusChangeEvent) { for (WizardPageStatusChangeHandler eventHandler : eventHandlers) { eventHandler.handleEvent(wizardPageStatusChangeEvent); } }
/** * Tests that the page reacts properly when the managed repository option is un checked. */ @Test public void testUnManagedRepositorySelected() { testManagedRepositoryChange(false); verify(statusChangeHandler, never()).handleEvent(any(WizardPageStatusChangeEvent.class)); }