use of com.yahoo.prelude.Index in project vespa by vespa-engine.
the class IndexFactsTestCase method testDefaultPosition.
@Test
public void testDefaultPosition() {
Index a = new Index("a");
assertFalse(a.isDefaultPosition());
a.addCommand("any");
assertFalse(a.isDefaultPosition());
a.addCommand("default-position");
assertTrue(a.isDefaultPosition());
SearchDefinition sd = new SearchDefinition("sd");
sd.addCommand("b", "any");
assertNull(sd.getDefaultPosition());
sd.addCommand("c", "default-position");
assertTrue(sd.getDefaultPosition().equals("c"));
SearchDefinition sd2 = new SearchDefinition("sd");
sd2.addIndex(new Index("b").addCommand("any"));
assertNull(sd2.getDefaultPosition());
sd2.addIndex(a);
assertTrue(sd2.getDefaultPosition().equals("a"));
Map<String, SearchDefinition> m = new TreeMap<>();
m.put(sd.getName(), sd);
IndexFacts indexFacts = createIndexFacts();
indexFacts.setSearchDefinitions(m, sd2);
assertTrue(indexFacts.getDefaultPosition(null).equals("a"));
assertTrue(indexFacts.getDefaultPosition("sd").equals("c"));
}
Aggregations