@Test public void testValidate() throws ValidationException { @SuppressWarnings("unchecked") Function<Element, DataDirectories> resourcesTypeSupplier = mock(Function.class); DataRootValidator dataRootValidator = new DataRootValidator(resourcesTypeSupplier); DataRootMapping dataRootMapping1 = new DataRootMapping(); dataRootMapping1.setName("dataRoot1"); dataRootMapping1.setValue("../data-root1"); dataRootMapping1.setUseForPlatform(true); DataRootMapping dataRootMapping2 = new DataRootMapping(); dataRootMapping2.setName("dataRoot1"); dataRootMapping2.setValue("../data-root2"); dataRootMapping2.setUseForPlatform(false); DataDirectories dataDirectories = new DataDirectories(); dataDirectories.getDirectory().add(dataRootMapping1); dataDirectories.getDirectory().add(dataRootMapping2); Element element = mock(Element.class); when(resourcesTypeSupplier.apply(element)).thenReturn(dataDirectories); dataRootValidator.validate(element); dataRootMapping2.setUseForPlatform(true); try { dataRootValidator.validate(element); } catch (ValidationException e) { assertEquals(ValidationFailureId.MULTIPLE_PLATFORM_DATA_ROOTS.getFailureId(), e.getErrorId()); } }
public void validate(Element fragment) throws ValidationException { DataDirectories dataDirectories = getDataDirectoriesObject(fragment); checkForMultiplePlatformUsage(dataDirectories.getDirectory()); }
DataRootValidator implements ConfigValidator { public void validate(Element fragment) throws ValidationException { DataDirectories dataDirectories = getDataDirectoriesObject(fragment); checkForMultiplePlatformUsage(dataDirectories.getDirectory()); } }
DataRootValidator implements ConfigValidator { public void validate(Element fragment) throws ValidationException { DataDirectories dataDirectories = getDataDirectoriesObject(fragment); checkForMultiplePlatformUsage(dataDirectories.getDirectory()); } DataRootValidator(Function<Element, DataDirectories> resourcesTypeSupplier); }
DataRootValidator implements ConfigValidator { public void validate(Element fragment) throws ValidationException { DataDirectories dataDirectories = getDataDirectoriesObject(fragment); checkForMultiplePlatformUsage(dataDirectories.getDirectory()); } DataRootValidator(Function<Element, DataDirectories> resourcesTypeSupplier); void validate(Element fragment); void validateAgainst(Element oneFragment, Element otherFragment); }
DataRootValidator implements ConfigValidator { public void validate(Element fragment) throws ValidationException { DataDirectories dataDirectories = getDataDirectoriesObject(fragment); checkForMultiplePlatformUsage(dataDirectories.getDirectory()); } DataRootValidator(Function<Element, DataDirectories> resourcesTypeSupplier); void validate(Element fragment); void validateAgainst(Element oneFragment, Element otherFragment);  }