use of com.yahoo.foo.MaptypesConfig in project vespa by vespa-engine.
the class ConfigInstanceBuilderTest method inner_map_setter_merges_maps.
@Test
public void inner_map_setter_merges_maps() {
MaptypesConfig.Builder builder = new MaptypesConfig.Builder().innermap("one", new Innermap.Builder().foo(1));
Map<String, Innermap.Builder> newMap = new HashMap<>();
newMap.put("two", new Innermap.Builder().foo(2));
builder.innermap(newMap);
MaptypesConfig config = new MaptypesConfig(builder);
assertThat(config.innermap("one").foo(), is(1));
assertThat(config.innermap("two").foo(), is(2));
}
use of com.yahoo.foo.MaptypesConfig in project vespa by vespa-engine.
the class ConfigInstanceBuilderTest method leaf_map_setter_merges_maps.
@Test
public void leaf_map_setter_merges_maps() {
MaptypesConfig.Builder builder = new MaptypesConfig.Builder().intmap("one", 1);
Map<String, Integer> newMap = new HashMap<>();
newMap.put("two", 2);
builder.intmap(newMap);
MaptypesConfig config = new MaptypesConfig(builder);
assertThat(config.intmap("one"), is(1));
assertThat(config.intmap("two"), is(2));
}
use of com.yahoo.foo.MaptypesConfig in project vespa by vespa-engine.
the class ConfigBuilderMergeTest method source_map_is_copied_into_destination_map_on_merge.
@Test
public void source_map_is_copied_into_destination_map_on_merge() {
MaptypesConfig.Builder destination = new MaptypesConfig.Builder().intmap("one", 1).innermap("first", new Innermap.Builder().foo(1));
MaptypesConfig.Builder source = new MaptypesConfig.Builder().intmap("two", 2).innermap("second", new Innermap.Builder().foo(2));
ConfigInstanceUtil.setValues(destination, source);
MaptypesConfig config = new MaptypesConfig(destination);
assertThat(config.intmap("one"), is(1));
assertThat(config.intmap("two"), is(2));
assertThat(config.innermap("first").foo(), is(1));
assertThat(config.innermap("second").foo(), is(2));
}
use of com.yahoo.foo.MaptypesConfig in project vespa by vespa-engine.
the class ConfigInstancePayloadTest method map_types_are_correctly_deserialized.
@Test
public void map_types_are_correctly_deserialized() {
MaptypesConfig orig = createMapTypesConfig();
List<String> lines = ConfigInstance.serialize(orig);
ConfigPayload payload = new CfgConfigPayloadBuilder().deserialize(lines);
System.out.println(payload.toString());
MaptypesConfig config = ConfigInstanceUtil.getNewInstance(MaptypesConfig.class, "foo", payload);
System.out.println(config);
assertThat(config.intmap().size(), is(1));
assertThat(config.intmap("foo"), is(1337));
assertNotNull(config.innermap("bar"));
assertThat(config.innermap("bar").foo(), is(93));
assertThat(config.nestedmap().size(), is(1));
assertNotNull(config.nestedmap("baz"));
assertThat(config.nestedmap("baz").inner("foo"), is(1));
assertThat(config.nestedmap("baz").inner("bar"), is(2));
}
use of com.yahoo.foo.MaptypesConfig in project vespa by vespa-engine.
the class ConfigInstanceSerializerTest method test_that_maps_are_formatted_to_json.
@Test
public void test_that_maps_are_formatted_to_json() throws IOException {
MaptypesConfig.Builder builder = new MaptypesConfig.Builder();
builder.boolmap("foo", true);
builder.intmap("bar", 3);
builder.stringmap("hei", "hallo");
MaptypesConfig.Innermap.Builder inner = new MaptypesConfig.Innermap.Builder();
inner.foo(133);
builder.innermap("baz", inner);
MaptypesConfig.Nestedmap.Builder nested = new MaptypesConfig.Nestedmap.Builder();
nested.inner("foo", 33);
builder.nestedmap("bim", nested);
final MaptypesConfig config = new MaptypesConfig(builder);
final String expectedJson = inputJson("{", " 'boolmap': {", " 'foo': true", " },", " 'doublemap': {},", " 'filemap': {},", " 'innermap': {", " 'baz': {", " 'foo': 133", " }", " },", " 'intmap': {", " 'bar': 3", " },", " 'longmap': {},", " 'nestedmap': {", " 'bim': {", " 'inner': {", " 'foo': 33", " }", " }", " },", " 'stringmap': {", " 'hei': 'hallo'", " }", "}");
assertConfigEquals(expectedJson, config);
}
Aggregations