use of com.yahoo.slime.JsonFormat in project vespa by vespa-engine.
the class ConfigInstanceSerializerTest method assertConfigEquals.
static void assertConfigEquals(String expectedJson, ConfigInstance config) {
Slime slime = new Slime();
ConfigInstance.serialize(config, new ConfigInstanceSerializer(slime));
JsonFormat jsonFormat = new JsonFormat(true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
jsonFormat.encode(baos, slime);
} catch (IOException e) {
fail();
}
assertJsonEquals(baos.toString(), expectedJson);
}
use of com.yahoo.slime.JsonFormat in project vespa by vespa-engine.
the class SessionActiveHandlerTest method assertActivationMessageOK.
private void assertActivationMessageOK(ActivateRequest activateRequest, String message) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
new JsonFormat(true).encode(byteArrayOutputStream, activateRequest.getMetaData().getSlime());
assertThat(message, containsString("\"tenant\":\"" + tenant + "\",\"message\":\"Session " + activateRequest.getSessionId() + activatedMessage));
assertThat(message, containsString("/application/v2/tenant/" + tenant + "/application/" + appName + "/environment/" + "prod" + "/region/" + "default" + "/instance/" + "default"));
assertTrue(hostProvisioner.activated);
assertThat(hostProvisioner.lastHosts.size(), is(1));
}
use of com.yahoo.slime.JsonFormat in project vespa by vespa-engine.
the class ConfigChangeActionsSlimeConverterTest method toJson.
private static String toJson(ConfigChangeActions actions) throws IOException {
Slime slime = new Slime();
Cursor root = slime.setObject();
new ConfigChangeActionsSlimeConverter(actions).toSlime(root);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
new JsonFormat(false).encode(outputStream, slime);
return outputStream.toString();
}
use of com.yahoo.slime.JsonFormat in project vespa by vespa-engine.
the class ProjectBundleClassPaths method save.
static void save(OutputStream out, ProjectBundleClassPaths mappings) throws IOException {
Slime slime = new Slime();
Cursor rootCursor = slime.setObject();
Cursor mainBundleCursor = rootCursor.setObject("mainBundle");
BundleClasspathMapping.save(mainBundleCursor, mappings.mainBundle);
Cursor dependenciesCursor = rootCursor.setArray("providedDependencies");
mappings.providedDependencies.forEach(d -> BundleClasspathMapping.save(dependenciesCursor.addObject(), d));
new JsonFormat(false).encode(out, slime);
}
use of com.yahoo.slime.JsonFormat in project vespa by vespa-engine.
the class JobsResponse method render.
@Override
public void render(OutputStream stream) throws IOException {
Slime slime = new Slime();
Cursor root = slime.setObject();
Cursor jobArray = root.setArray("jobs");
for (String jobName : jobControl.jobs()) jobArray.addObject().setString("name", jobName);
Cursor inactiveArray = root.setArray("inactive");
for (String jobName : jobControl.inactiveJobs()) inactiveArray.addString(jobName);
new JsonFormat(true).encode(stream, slime);
}
Aggregations