Search in sources :

Example 11 with FunctionTestConfig

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));
}
Also used : FunctionTestConfig(com.yahoo.foo.FunctionTestConfig) ConfigPayloadBuilder(com.yahoo.vespa.config.ConfigPayloadBuilder) ConfigBuilder(com.yahoo.config.ConfigBuilder) Test(org.junit.Test)

Example 12 with FunctionTestConfig

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));
}
Also used : FunctionTestConfig(com.yahoo.foo.FunctionTestConfig) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) Slime(com.yahoo.slime.Slime) Test(org.junit.Test)

Example 13 with FunctionTestConfig

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();
    }
}
Also used : FunctionTestConfig(com.yahoo.foo.FunctionTestConfig)

Aggregations

FunctionTestConfig (com.yahoo.foo.FunctionTestConfig)13 Test (org.junit.Test)11 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)4 ConfigBuilder (com.yahoo.config.ConfigBuilder)1 ConfigSet (com.yahoo.config.subscription.ConfigSet)1 ConfigSubscriber (com.yahoo.config.subscription.ConfigSubscriber)1 JRTConfigSubscription (com.yahoo.config.subscription.impl.JRTConfigSubscription)1 Slime (com.yahoo.slime.Slime)1 ConfigPayloadBuilder (com.yahoo.vespa.config.ConfigPayloadBuilder)1 RawConfig (com.yahoo.vespa.config.RawConfig)1 TimingValues (com.yahoo.vespa.config.TimingValues)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1