use of org.openstreetmap.atlas.checks.base.checks.CheckResourceLoaderTestCheck in project atlas-checks by osmlab.
the class CheckResourceLoaderTest method testCountryKeywordCheckLoading.
/**
* Test the check loading using country keyword specific configurations. Assert that each
* country gets its own version of the check.
*/
@Test
public void testCountryKeywordCheckLoading() {
final String configSource = "{\"CheckResourceLoader.scanUrls\": [\"org.openstreetmap.atlas.checks.base.checks\"],\"CheckResourceLoaderTestCheck\":{\"enabled\": true,\"var1\":1,\"override.ABC.var1\":2}}";
final String country1 = "ABC";
final String country2 = "XYZ";
final List<String> countries = Arrays.asList(country1, country2);
final Configuration configuration = ConfigurationResolver.inlineConfiguration(configSource);
final CheckResourceLoader checkResourceLoader = new CheckResourceLoader(configuration);
final Set<Check> loadedCountry1Checks = checkResourceLoader.loadChecksForCountry(country1);
final Set<Check> loadedCountry2Checks = checkResourceLoader.loadChecksForCountry(country2);
// assert both countries loaded with different check sets
Assert.assertNotNull(loadedCountry1Checks);
Assert.assertNotNull(loadedCountry2Checks);
Assert.assertEquals(1, loadedCountry1Checks.size());
Assert.assertEquals(1, loadedCountry2Checks.size());
Assert.assertFalse(Iterables.equals(loadedCountry1Checks, loadedCountry2Checks));
// assert both configurations overrode properly and thus initialized properly
final long country1Var1 = checkResourceLoader.getConfigurationForCountry(country1).get("CheckResourceLoaderTestCheck.var1").value();
final long country2Var2 = checkResourceLoader.getConfigurationForCountry(country2).get("CheckResourceLoaderTestCheck.var1").value();
Assert.assertEquals(country1Var1, 2);
Assert.assertEquals(country2Var2, 1);
}
Aggregations