use of com.yahoo.slime.Slime in project vespa by vespa-engine.
the class ConfigPayloadTest method createStructtypesConfigSimple.
private StructtypesConfig createStructtypesConfigSimple(String name, String gender, String[] emails) {
Slime slime = new Slime();
addStructFields(slime.setObject().setObject("simple"), name, gender, emails);
return new ConfigPayload(slime).toInstance(StructtypesConfig.class, "");
}
use of com.yahoo.slime.Slime in project vespa by vespa-engine.
the class ConfigPayloadTest method test_empty_payload.
@Test
public void test_empty_payload() throws Exception {
Slime slime = new Slime();
slime.setObject();
IntConfig config = new ConfigPayload(slime).toInstance(IntConfig.class, "");
assertThat(config.intVal(), is(1));
}
use of com.yahoo.slime.Slime in project vespa by vespa-engine.
the class ConfigPayloadTest method createStructtypesConfigComplexArray.
private StructtypesConfig createStructtypesConfigComplexArray(String[][] names, String[][] genders) {
Slime slime = new Slime();
Cursor array = slime.setObject().setArray("complexarr");
assertEquals(names.length, genders.length);
for (int i = 0; i < names.length; i++) {
assertEquals(names[i].length, genders[i].length);
Cursor innerarr = array.addObject().setArray("innerarr");
for (int k = 0; k < names[i].length; k++) {
addStructFields(innerarr.addObject(), names[i][k], genders[i][k], null);
}
}
return new ConfigPayload(slime).toInstance(StructtypesConfig.class, "");
}
use of com.yahoo.slime.Slime in project vespa by vespa-engine.
the class ConfigPayloadTest method createAppConfig.
/**
* TODO: Test invalid slime trees?
* TODO: Test sending in wrong class
*/
/**
********************************************************************************************
* Helper methods. consider moving out to another class for reuse by merge tester. *
*********************************************************************************************
*/
private AppConfig createAppConfig(String message, String times, String[] names) {
Slime slime = new Slime();
Cursor root = slime.setObject();
root.setString("message", message);
root.setString("times", times);
Cursor arr = root.setArray("a");
for (String name : names) {
Cursor obj = arr.addObject();
obj.setString("name", name);
}
return new ConfigPayload(slime).toInstance(AppConfig.class, "");
}
use of com.yahoo.slime.Slime in project vespa by vespa-engine.
the class SlimeUtilsTest method test_json_to_slime.
@Test
public void test_json_to_slime() {
byte[] json = Utf8.toBytes("{\"foo\":\"foobie\",\"bar\":{}}");
Slime slime = SlimeUtils.jsonToSlime(json);
assertThat(slime.get().field("foo").asString(), is("foobie"));
assertTrue(slime.get().field("bar").valid());
}
Aggregations