use of com.yahoo.vespa.config.ConfigPayload 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.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class ConfigInstancePayloadTest method function_test_payload_is_correctly_deserialized.
@Test
public void function_test_payload_is_correctly_deserialized() {
FunctionTestConfig orig = createVariableAccessConfigWithBuilder();
List<String> lines = ConfigInstance.serialize(orig);
ConfigPayload payload = new CfgConfigPayloadBuilder().deserialize(lines);
FunctionTestConfig config = ConfigInstanceUtil.getNewInstance(FunctionTestConfig.class, "foo", payload);
FunctionTest.assertVariableAccessValues(config, "foo");
}
use of com.yahoo.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class SuperModelConfigProvider method getConfig.
public <CONFIGTYPE extends ConfigInstance> CONFIGTYPE getConfig(Class<CONFIGTYPE> configClass, ApplicationId applicationId, String configId) {
TenantName tenant = applicationId.tenant();
if (!superModel.getAllModels().containsKey(tenant)) {
throw new IllegalArgumentException("Tenant " + tenant + " not found");
}
Map<ApplicationId, ApplicationInfo> applications = superModel.getAllModels().get(tenant);
if (!applications.containsKey(applicationId)) {
throw new IllegalArgumentException("Application id " + applicationId + " not found");
}
ApplicationInfo application = applications.get(applicationId);
ConfigKey<CONFIGTYPE> key = new ConfigKey<>(configClass, configId);
ConfigPayload payload = application.getModel().getConfig(key, null);
return payload.toInstance(configClass, configId);
}
use of com.yahoo.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class HttpGetConfigHandlerTest method require_that_handler_can_be_created.
@Test
public void require_that_handler_can_be_created() throws IOException {
// Define config response for mock handler
final long generation = 1L;
ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
InnerCNode targetDef = getInnerCNode();
mockRequestHandler.responses.put(new ApplicationId.Builder().tenant(tenant).applicationName("myapplication").build(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
HttpResponse response = handler.handle(HttpRequest.createTestRequest(configUri, GET));
assertThat(SessionHandlerTest.getRenderedString(response), is(EXPECTED_RENDERED_STRING));
}
use of com.yahoo.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class HttpGetConfigHandlerTest method require_that_handler_can_be_created.
@Test
public void require_that_handler_can_be_created() throws IOException {
// Define config response for mock handler
final long generation = 1L;
ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
InnerCNode targetDef = getInnerCNode();
mockRequestHandler.responses.put(ApplicationId.defaultId(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
HttpResponse response = handler.handle(HttpRequest.createTestRequest(configUri, GET));
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
Aggregations