diff options
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/derived/SearchOrdererTestCase.java')
-rw-r--r-- | config-model/src/test/java/com/yahoo/searchdefinition/derived/SearchOrdererTestCase.java | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SearchOrdererTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SearchOrdererTestCase.java index 0c677456a87..b770024ebf1 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SearchOrdererTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SearchOrdererTestCase.java @@ -6,7 +6,7 @@ import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.searchdefinition.DocumentReference; import com.yahoo.searchdefinition.DocumentReferences; import com.yahoo.searchdefinition.Search; -import com.yahoo.searchdefinition.SchemaTestCase; +import com.yahoo.searchdefinition.SearchDefinitionTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.TemporarySDField; @@ -26,47 +26,47 @@ import static org.junit.Assert.assertEquals; * @author bratseth * @author bjorncs */ -public class SearchOrdererTestCase extends SchemaTestCase { +public class SearchOrdererTestCase extends SearchDefinitionTestCase { - private static Map<String, Search> createSchemas() { - Map<String, Search> schemas = new HashMap<>(); + private static Map<String, Search> createSearchDefinitions() { + Map<String, Search> searchDefinitions = new HashMap<>(); - Search grandParent = createSchema("grandParent", schemas); + Search grandParent = createSearchDefinition("grandParent", searchDefinitions); - Search mother = createSchema("mother", schemas); + Search mother = createSearchDefinition("mother", searchDefinitions); inherit(mother, grandParent); - Search father = createSchema("father", schemas); + Search father = createSearchDefinition("father", searchDefinitions); inherit(father, grandParent); createDocumentReference(father, mother, "wife_ref"); - Search daugther = createSchema("daughter", schemas); + Search daugther = createSearchDefinition("daughter", searchDefinitions); inherit(daugther, father); inherit(daugther, mother); - Search son = createSchema("son", schemas); + Search son = createSearchDefinition("son", searchDefinitions); inherit(son, father); inherit(son, mother); - Search product = createSchema("product", schemas); + Search product = createSearchDefinition("product", searchDefinitions); - Search pc = createSchema("pc", schemas); + Search pc = createSearchDefinition("pc", searchDefinitions); inherit(pc, product); - Search pcAccessory = createSchema("accessory-pc", schemas); + Search pcAccessory = createSearchDefinition("accessory-pc", searchDefinitions); inherit(pcAccessory, product); createDocumentReference(pcAccessory, pc, "pc_ref"); - createSchema("alone", schemas); + createSearchDefinition("alone", searchDefinitions); - return schemas; + return searchDefinitions; } - private static Search createSchema(String name, Map<String, Search> schemas) { + private static Search createSearchDefinition(String name, Map<String, Search> searchDefinitions) { Search search = new Search(name, null); SDDocumentType document = new SDDocumentType(name); document.setDocumentReferences(new DocumentReferences(emptyMap())); search.addDocument(document); - schemas.put(search.getName(), search); + searchDefinitions.put(search.getName(), search); return search; } @@ -75,13 +75,13 @@ public class SearchOrdererTestCase extends SchemaTestCase { } private static void assertOrder(List<String> expectedSearchOrder, List<String> inputNames) { - Map<String, Search> schemas = createSchemas(); - List<Search> inputSchemas = inputNames.stream() - .map(schemas::get) + Map<String, Search> searchDefinitions = createSearchDefinitions(); + List<Search> inputSearchDefinitions = inputNames.stream() + .map(searchDefinitions::get) .map(Objects::requireNonNull) .collect(toList()); List<String> actualSearchOrder = new SearchOrderer() - .order(inputSchemas) + .order(inputSearchDefinitions) .stream() .map(Search::getName) .collect(toList()); @@ -104,37 +104,31 @@ public class SearchOrdererTestCase extends SchemaTestCase { assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), Arrays.asList("grandParent", "mother", "father", "daughter", "son", "product", "pc", "alone")); } - @Test public void testOneLevelReordering() { assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), Arrays.asList("grandParent", "daughter", "son", "mother", "father", "pc", "product", "alone")); } - @Test public void testMultiLevelReordering() { assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), Arrays.asList("daughter", "son", "mother", "father", "grandParent", "pc", "product", "alone")); } - @Test public void testAloneIsKeptInPlaceWithMultiLevelReordering() { assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), Arrays.asList("alone", "daughter", "son", "mother", "father", "grandParent", "pc", "product")); } - @Test public void testPartialMultiLevelReordering() { assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), Arrays.asList("daughter", "grandParent", "mother", "son", "father", "product", "pc", "alone")); } - @Test public void testMultilevelReorderingAccrossHierarchies() { assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), Arrays.asList("daughter", "pc", "son", "mother", "grandParent", "father", "product", "alone")); } - @Test public void referees_are_ordered_before_referrer() { assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "accessory-pc", "son"), |