final IndexFields indexFields = INDEXER_CONF.getIndexFields();
indexFields.visitAll(new Predicate<MappingNode>() {
@Override
public boolean apply(MappingNode input) {
if (input instanceof IndexField) {
final IndexField indexField = (IndexField) input;
if ("cc_less_variant_spaces".equals(indexField.getName().getTemplate())) {
final List<Follow> follows = ((DerefValue) indexField.getValue()).getFollows();
assertEquals(1, follows.size());
final Set<String> dimensions = ((VariantFollow) follows.get(0)).getDimensions();
assertEquals(1, dimensions.size());
assertTrue(dimensions.contains("my branch"));
} else if ("cc_less_variant_spaces_twice".equals(indexField.getName().getTemplate())) {
final List<Follow> follows = ((DerefValue) indexField.getValue()).getFollows();
assertEquals(1, follows.size());
final Set<String> dimensions = ((VariantFollow) follows.get(0)).getDimensions();
assertEquals(2, dimensions.size());
assertTrue(dimensions.contains("my branch"));
assertTrue(dimensions.contains("some lang"));
} else if ("cc_more_variant_spaces".equals(indexField.getName().getTemplate())) {
final List<Follow> follows = ((DerefValue) indexField.getValue()).getFollows();
assertEquals(1, follows.size());
final Map<String, String> dimensions =
((ForwardVariantFollow) follows.get(0)).getDimensions();
assertEquals(1, dimensions.size());
assertTrue(dimensions.containsKey("my branch"));
assertNull(dimensions.get("my branch"));
} else if ("cc_more_variant_spaces_twice".equals(indexField.getName().getTemplate())) {
final List<Follow> follows = ((DerefValue) indexField.getValue()).getFollows();
assertEquals(1, follows.size());
final Map<String, String> dimensions =
((ForwardVariantFollow) follows.get(0)).getDimensions();
assertEquals(2, dimensions.size());
assertTrue(dimensions.containsKey("my branch"));
assertNull(dimensions.get("my branch"));
assertTrue(dimensions.containsKey("some lang"));
assertNull(dimensions.get("some lang"));
} else if ("cc_more_variant_spaces_value".equals(indexField.getName().getTemplate())) {
final List<Follow> follows = ((DerefValue) indexField.getValue()).getFollows();
assertEquals(1, follows.size());
final Map<String, String> dimensions =
((ForwardVariantFollow) follows.get(0)).getDimensions();
assertEquals(1, dimensions.size());
assertTrue(dimensions.containsKey("branch"));
assertEquals("some value", dimensions.get("branch"));
} else if ("cc_more_variant_spaces_twice_value".equals(indexField.getName().getTemplate())) {
final List<Follow> follows = ((DerefValue) indexField.getValue()).getFollows();
assertEquals(1, follows.size());
final Map<String, String> dimensions =
((ForwardVariantFollow) follows.get(0)).getDimensions();
assertEquals(2, dimensions.size());
assertTrue(dimensions.containsKey("branch"));
assertEquals("some value", dimensions.get("branch"));
assertTrue(dimensions.containsKey("lang"));
assertEquals("some lang", dimensions.get("lang"));
} else if ("cc_more_variant_spaces_key_and_value".equals(indexField.getName().getTemplate())) {
final List<Follow> follows = ((DerefValue) indexField.getValue()).getFollows();
assertEquals(1, follows.size());
final Map<String, String> dimensions =
((ForwardVariantFollow) follows.get(0)).getDimensions();
assertEquals(2, dimensions.size());
assertTrue(dimensions.containsKey("my branch"));
assertEquals("some value", dimensions.get("my branch"));
assertTrue(dimensions.containsKey("my lang"));
assertEquals("some lang", dimensions.get("my lang"));
} else {
throw new IllegalStateException("unexpected index field " + indexField.getName().getTemplate());
}
}
return true; // to make visit continue
}