Search in sources :

Example 21 with CompoundName

use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.

the class CompoundNameTestCase method testEmpty.

@Test
public void testEmpty() {
    CompoundName empty = new CompoundName("");
    assertEquals("", empty.toString());
    assertEquals(0, empty.asList().size());
}
Also used : CompoundName(com.yahoo.processing.request.CompoundName) Test(org.junit.Test)

Example 22 with CompoundName

use of com.yahoo.processing.request.CompoundName in project vespa by vespa-engine.

the class RequestTestCase method testProperties.

@Test
public void testProperties() {
    Properties p = new PropertyMap();
    p.set("a", "a1");
    Request r = new Request(p);
    r.properties().set("b", "b1");
    assertEquals(2, r.properties().listProperties().size());
    assertEquals("a1", r.properties().get("a"));
    assertEquals("b1", r.properties().get("b"));
    assertEquals("b1", r.properties().get("b", "default"));
    assertEquals("default", r.properties().get("c", "default"));
    assertNull(r.properties().get("c"));
    assertEquals("b1", r.properties().get(new CompoundName("b")));
    assertEquals("b1", r.properties().get(new CompoundName("b"), "default"));
    assertEquals("default", r.properties().get(new CompoundName("c"), "default"));
    assertNull(r.properties().get(new CompoundName("c")));
    assertEquals("b1", r.properties().getString("b"));
    assertEquals("b1", r.properties().getString("b", "default"));
    assertEquals("default", r.properties().getString("c", "default"));
    assertEquals(null, r.properties().getString("c"));
    assertEquals("b1", r.properties().getString(new CompoundName("b")));
    assertEquals("b1", r.properties().getString(new CompoundName("b"), "default"));
    assertEquals("default", r.properties().getString(new CompoundName("c"), "default"));
    assertEquals(null, r.properties().getString(new CompoundName("c")));
    r.properties().set("i", 7);
    assertEquals(7, (int) r.properties().getInteger("i"));
    assertEquals(7, (int) r.properties().getInteger("i", 3));
    assertEquals(3, (int) r.properties().getInteger("n", 3));
    assertNull(r.properties().getInteger("n"));
    assertEquals(7, (int) r.properties().getInteger(new CompoundName("i")));
    assertEquals(7, (int) r.properties().getInteger(new CompoundName("i"), 3));
    assertEquals(3, (int) r.properties().getInteger(new CompoundName("n"), 3));
    assertNull(r.properties().getInteger("n"));
    r.properties().set(new CompoundName("l"), 7);
    assertEquals(7, (long) r.properties().getLong("l"));
    assertEquals(7, (long) r.properties().getLong("l", 3l));
    assertEquals(3, (long) r.properties().getLong("m", 3l));
    assertNull(r.properties().getInteger("m"));
    assertEquals(7, (long) r.properties().getLong(new CompoundName("l")));
    assertEquals(7, (long) r.properties().getLong(new CompoundName("l"), 3l));
    assertEquals(3, (long) r.properties().getLong(new CompoundName("m"), 3l));
    assertNull(r.properties().getInteger("m"));
    r.properties().set("d", 7.3);
    assertEquals(7.3, r.properties().getDouble("d"));
    assertEquals(7.3, r.properties().getDouble("d", 3.4d));
    assertEquals(3.4, r.properties().getDouble("f", 3.4d));
    assertNull(r.properties().getDouble("f"));
    assertEquals(7.3, r.properties().getDouble(new CompoundName("d")));
    assertEquals(7.3, r.properties().getDouble(new CompoundName("d"), 3.4d));
    assertEquals(3.4, r.properties().getDouble(new CompoundName("f"), 3.4d));
    assertNull(r.properties().getDouble("f"));
    r.properties().set("o", true);
    assertEquals(true, r.properties().getBoolean("o"));
    assertEquals(true, r.properties().getBoolean("o", true));
    assertEquals(true, r.properties().getBoolean("g", true));
    assertEquals(false, r.properties().getBoolean("g"));
    assertEquals(true, r.properties().getBoolean(new CompoundName("o")));
    assertEquals(true, r.properties().getBoolean(new CompoundName("o"), true));
    assertEquals(true, r.properties().getBoolean(new CompoundName("g"), true));
    assertEquals(false, r.properties().getBoolean("g"));
    r.properties().set(new CompoundName("x.y"), "x1.y1");
    r.properties().set("x.z", "x1.z1");
    assertEquals(8, r.properties().listProperties().size());
    assertEquals(0, r.properties().listProperties("a").size());
    assertEquals(0, r.properties().listProperties(new CompoundName("a")).size());
    assertEquals(0, r.properties().listProperties(new CompoundName("none")).size());
    assertEquals(2, r.properties().listProperties(new CompoundName("x")).size());
    assertEquals(2, r.properties().listProperties("x").size());
}
Also used : CompoundName(com.yahoo.processing.request.CompoundName) PropertyMap(com.yahoo.processing.request.properties.PropertyMap) Request(com.yahoo.processing.Request) Properties(com.yahoo.processing.request.Properties) Test(org.junit.Test)

Aggregations

CompoundName (com.yahoo.processing.request.CompoundName)22 Test (org.junit.Test)7 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)6 HashMap (java.util.HashMap)6 Map (java.util.Map)5 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)4 PropertyMap (com.yahoo.processing.request.properties.PropertyMap)2 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)2 HashSet (java.util.HashSet)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 Request (com.yahoo.processing.Request)1 Properties (com.yahoo.processing.request.Properties)1 Query (com.yahoo.search.Query)1 ModelObjectMap (com.yahoo.search.query.profile.ModelObjectMap)1 QueryProfile (com.yahoo.search.query.profile.QueryProfile)1 QueryProfileProperties (com.yahoo.search.query.profile.QueryProfileProperties)1 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)1 SubstituteString (com.yahoo.search.query.profile.SubstituteString)1 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)1