use of com.yahoo.foo.FunctionTestConfig in project vespa by vespa-engine.
the class ConfigInstanceUtilTest method require_that_builder_values_can_be_overridden_by_another_builder.
@Test
public void require_that_builder_values_can_be_overridden_by_another_builder() {
FunctionTestConfig.Builder destination = createVariableAccessBuilder();
FunctionTestConfig.Builder source = new FunctionTestConfig.Builder().int_val(-1).intarr(0).doublearr(0.0).basicStruct(new FunctionTestConfig.BasicStruct.Builder().bar(-1).intArr(0)).myarray(new FunctionTestConfig.Myarray.Builder().intval(-1).refval("").fileVal("").myStruct(new FunctionTestConfig.Myarray.MyStruct.Builder().a(0)));
ConfigInstanceUtil.setValues(destination, source);
FunctionTestConfig result = new FunctionTestConfig(destination);
assertThat(result.int_val(), is(-1));
assertThat(result.string_val(), is("foo"));
assertThat(result.intarr().size(), is(1));
assertThat(result.intarr(0), is(0));
assertThat(result.longarr().size(), is(2));
assertThat(result.doublearr().size(), is(3));
assertEquals(2344.0, result.doublearr(0), 0.01);
assertEquals(123.0, result.doublearr(1), 0.01);
assertEquals(0.0, result.doublearr(2), 0.01);
assertThat(result.basicStruct().bar(), is(-1));
assertThat(result.basicStruct().foo(), is("basicFoo"));
assertThat(result.basicStruct().intArr().size(), is(3));
assertThat(result.basicStruct().intArr(0), is(310));
assertThat(result.basicStruct().intArr(1), is(311));
assertThat(result.basicStruct().intArr(2), is(0));
assertThat(result.myarray().size(), is(3));
assertThat(result.myarray(2).intval(), is(-1));
assertThat(result.myarray(2).refval(), is(""));
assertThat(result.myarray(2).fileVal().value(), is(""));
assertThat(result.myarray(2).myStruct().a(), is(0));
}
use of com.yahoo.foo.FunctionTestConfig in project vespa by vespa-engine.
the class ConfigInstancePayloadTest method config_builder_can_be_created_from_typed_payload.
@Test
public void config_builder_can_be_created_from_typed_payload() {
FunctionTestConfig config = createVariableAccessConfigWithBuilder();
Slime slime = new Slime();
ConfigInstanceSerializer serializer = new ConfigInstanceSerializer(slime);
ConfigInstance.serialize(config, serializer);
assertFunctionTestPayload(config, new ConfigPayload(slime));
}
use of com.yahoo.foo.FunctionTestConfig in project vespa by vespa-engine.
the class ConfigInstancePayloadTest method assertFunctionTestPayload.
private void assertFunctionTestPayload(FunctionTestConfig expected, ConfigPayload payload) {
try {
System.out.println(payload.toString(false));
FunctionTestConfig config2 = new FunctionTestConfig((FunctionTestConfig.Builder) new ConfigTransformer<>(FunctionTestConfig.class).toConfigBuilder(payload));
assertThat(config2, is(expected));
assertThat(ConfigInstance.serialize(config2), is(ConfigInstance.serialize(expected)));
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
Aggregations