Search in sources :

Example 6 with Concept

use of com.yahoo.bullet.result.Meta.Concept in project bullet-core by yahoo.

the class BulletConfigTest method testIncompleteMetadata.

@Test
public void testIncompleteMetadata() {
    List<Map<String, String>> metadata = new ArrayList<>();
    Map<String, String> expected = new HashMap<>();
    for (Concept concept : Arrays.asList(Concept.QUERY_ID, Concept.SKETCH_ITEMS_SEEN)) {
        Map<String, String> entry = new HashMap<>();
        String name = concept.getName();
        String key = concept.getName().substring(0, 3);
        entry.put(BulletConfig.RESULT_METADATA_METRICS_CONCEPT_KEY, name);
        entry.put(BulletConfig.RESULT_METADATA_METRICS_NAME_KEY, key);
        metadata.add(entry);
        expected.put(name, key);
    }
    BulletConfig config = new BulletConfig();
    config.set(BulletConfig.RESULT_METADATA_METRICS, metadata);
    config.validate();
    Assert.assertEquals(config.get(BulletConfig.RESULT_METADATA_METRICS), expected);
    // Add only one entry
    Map<String, String> entry = new HashMap<>();
    entry.put(BulletConfig.RESULT_METADATA_METRICS_CONCEPT_KEY, Concept.QUERY_ID.getName());
    metadata.add(entry);
    config.set(BulletConfig.RESULT_METADATA_METRICS, metadata);
    config.validate();
    // Now it's all defaults
    Assert.assertEquals(config.get(BulletConfig.RESULT_METADATA_METRICS), allMetadataAsMap());
}
Also used : Concept(com.yahoo.bullet.result.Meta.Concept) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.testng.annotations.Test)

Aggregations

Concept (com.yahoo.bullet.result.Meta.Concept)6 HashMap (java.util.HashMap)6 Test (org.testng.annotations.Test)6 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4