ValidationExecutorFactory { public @Nullable ValidationExecutor createValidationExecutor(@NotNull ValidationContext context, boolean isSubPackage, boolean enforceSubpackageValidation, Map<String, ? extends ValidatorSettings> validatorSettingsById) { Map<String, Validator> validatorsById = createValidators(context, isSubPackage, enforceSubpackageValidation, validatorSettingsById != null ? validatorSettingsById : Collections.emptyMap()); if (validatorsById.isEmpty()) { return null; } return new ValidationExecutor(validatorsById); } ValidationExecutorFactory(ClassLoader classLoader);   ValidationExecutorFactory(Iterable<ValidatorFactory> validatorFactoriesUnsorted); @Nullable ValidationExecutor createValidationExecutor(@NotNull ValidationContext context, boolean isSubPackage, boolean enforceSubpackageValidation, Map<String, ? extends ValidatorSettings> validatorSettingsById);  }
@Test public void testOrderOfValidators() throws ParserConfigurationException, SAXException { ValidationExecutor executor = executorFactory.createValidationExecutor(context, true, true, validatorsSettings); if (executor == null) { throw new IllegalStateException("Could not create validation executor!"); } Map<String, Validator> actualValidators = executor.getAllValidatorsById(); Map<String, Validator> expectedValidators = new LinkedHashMap<>(); expectedValidators.put("id1", validator1); expectedValidators.put("id2", validator2); expectedValidators.put("id3", validator3); Assert.assertEquals(expectedValidators.toString(), actualValidators.toString()); Assert.assertThat(actualValidators.keySet(), Matchers.contains("id1", "id2", "id3")); Collections.shuffle(validatorFactories); executorFactory = new ValidationExecutorFactory(validatorFactories); executor = executorFactory.createValidationExecutor(context, true, true, validatorsSettings); if (executor == null) { throw new IllegalStateException("Could not create validation executor!"); } actualValidators = executor.getAllValidatorsById(); Assert.assertEquals(expectedValidators.toString(), actualValidators.toString()); Assert.assertThat(actualValidators.keySet(), Matchers.contains("id1", "id2", "id3")); }
@Test public void testValidatorSettings() throws ParserConfigurationException, SAXException { ValidatorSettings settings1 = new ValidatorSettingsImpl("option1", "value1"); validatorsSettings.put("id1", settings1); ValidatorSettings settings2 = new ValidatorSettingsImpl(true); validatorsSettings.put("id2", settings2); ValidatorSettings settings3 = new ValidatorSettingsImpl(ValidationMessageSeverity.INFO); validatorsSettings.put("id3", settings3); executorFactory.createValidationExecutor(context, true, true, validatorsSettings); Mockito.verify(validatorFactory1).createValidator(context, settings1); Mockito.verify(validatorFactory2, Mockito.never()).createValidator(Mockito.any(), Mockito.any()); Mockito.verify(validatorFactory3).createValidator(context, settings3); }