public void onOUChange() { final String selectedOU = view.getOrganizationalUnitName(); boolean newIsOUValid = selectedOU != null && !RepositoryInfoPageView.NOT_SELECTED.equals(selectedOU); if (mandatoryOU) { view.setValidOU(newIsOUValid); } model.setOrganizationalUnit(selectedOU != null ? availableOrganizationalUnits.get(selectedOU) : null); if (isOUValid != newIsOUValid) { isOUValid = newIsOUValid; refreshRepositoryStructurePageStatus(); } }
private void setupNameAndOrgUnitMocks(boolean isRepoNameValid, String orgUnit) { when(infoPageView.getName()).thenReturn(REPOSITORY_NAME); when(infoPageView.getOrganizationalUnitName()).thenReturn(orgUnit); when(repositoryService.validateRepositoryName(REPOSITORY_NAME)).thenReturn(isRepoNameValid); when(repositoryService.normalizeRepositoryName(REPOSITORY_NAME)).thenReturn(REPOSITORY_NAME); }
/** * 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); }