@Test public void testProjectNameNull() { localizationForm.setProjectName(null); when(projectService.isProjectAvailable(null)).thenReturn(false); boolean valid = uniqueLocalizationValidator.isValid(localizationForm, context); assertTrue("Wenn das project nicht angegeben wurde, erstmal valid", valid); }
@Test public void testInvalid() { localizationForm.setProjectName("test"); localizationForm.setLocale(Locale.FRENCH); when(projectService.isProjectAvailable("test")).thenReturn(true); when(localizationService.isLocalizationAvailable("test", Locale.FRENCH)).thenReturn(true); boolean valid = uniqueLocalizationValidator.isValid(localizationForm, context); verify(classLevelValidatorSupport).moveErrorToFieldname(context, "locale"); assertFalse(valid); }
@Test public void testValid() { localizationForm.setProjectName("test"); localizationForm.setLocale(Locale.UK); when(projectService.isProjectAvailable("test")).thenReturn(true); when(localizationService.isLocalizationAvailable("test", Locale.UK)).thenReturn(false); boolean valid = uniqueLocalizationValidator.isValid(localizationForm, context); verifyZeroInteractions(context); assertTrue(valid); }