use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project buck by facebook.
the class TargetsCommandIntegrationTest method testJsonOutputWithShowFullOutput.
@Test
public void testJsonOutputWithShowFullOutput() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "output_path", tmp);
workspace.setUp();
ProcessResult result = workspace.runBuckCommand("targets", "--json", "--show-full-output", "//:test");
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
// Parse the observed JSON.
JsonNode observed = objectMapper.readTree(objectMapper.getFactory().createParser(result.getStdout()));
assertTrue(observed.isArray());
JsonNode targetNode = observed.get(0);
assertTrue(targetNode.isObject());
JsonNode cellPath = targetNode.get("buck.outputPath");
assertNotNull(cellPath);
Path expectedPath = tmp.getRoot().resolve("buck-out/gen/test/test-output");
String expectedRootPath = MorePaths.pathWithPlatformSeparators(expectedPath);
assertEquals(expectedRootPath, cellPath.asText());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project hadoop by apache.
the class TestLog4Json method testNestedException.
@Test
public void testNestedException() throws Throwable {
Exception e = new NoRouteToHostException("that box caught fire 3 years ago");
Exception ioe = new IOException("Datacenter problems", e);
ThrowableInformation ti = new ThrowableInformation(ioe);
Log4Json l4j = new Log4Json();
long timeStamp = Time.now();
String outcome = l4j.toJson(new StringWriter(), "testNestedException", timeStamp, "INFO", "quoted\"", "new line\n and {}", ti).toString();
println("testNestedException", outcome);
ContainerNode rootNode = Log4Json.parse(outcome);
assertEntryEquals(rootNode, Log4Json.LEVEL, "INFO");
assertEntryEquals(rootNode, Log4Json.NAME, "testNestedException");
assertEntryEquals(rootNode, Log4Json.TIME, timeStamp);
assertEntryEquals(rootNode, Log4Json.EXCEPTION_CLASS, ioe.getClass().getName());
JsonNode node = assertNodeContains(rootNode, Log4Json.STACK);
assertTrue("Not an array: " + node, node.isArray());
node = assertNodeContains(rootNode, Log4Json.DATE);
assertTrue("Not a string: " + node, node.isTextual());
//rather than try and make assertions about the format of the text
//message equalling another ISO date, this test asserts that the hypen
//and colon characters are in the string.
String dateText = node.textValue();
assertTrue("No '-' in " + dateText, dateText.contains("-"));
assertTrue("No '-' in " + dateText, dateText.contains(":"));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project hadoop by apache.
the class TestLog4Json method assertEntryEquals.
void assertEntryEquals(ContainerNode rootNode, String key, String value) {
JsonNode node = assertNodeContains(rootNode, key);
assertEquals(value, node.textValue());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project hadoop by apache.
the class TestLog4Json method assertEntryEquals.
void assertEntryEquals(ContainerNode rootNode, String key, long value) {
JsonNode node = assertNodeContains(rootNode, key);
assertEquals(value, node.numberValue());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project OpenAM by OpenRock.
the class SubjectTypesResource method jsonify.
/**
* Transforms a subclass of {@link EntitlementSubject} in to a JsonSchema representation.
* This schema is then combined with the Subject's name (taken as the resourceId) and all this is
* compiled together into a new {@link JsonValue} object until "title" and "config" fields respectively.
*
* @param subjectClass The class whose schema to produce.
* @param resourceId The ID of the resource to return
* @return A JsonValue containing the schema of the EntitlementSubject
*/
private JsonValue jsonify(Class<? extends EntitlementSubject> subjectClass, String resourceId, boolean logical) {
try {
final JsonSchema schema = mapper.generateJsonSchema(subjectClass);
//this will remove the 'subjectName' attribute from those subjects which incorporate it unnecessarily
final JsonNode node = schema.getSchemaNode().get("properties");
if (node instanceof ObjectNode) {
final ObjectNode alter = (ObjectNode) node;
alter.remove("subjectName");
}
return JsonValue.json(JsonValue.object(JsonValue.field(JSON_OBJ_TITLE, resourceId), JsonValue.field(JSON_OBJ_LOGICAL, logical), JsonValue.field(JSON_OBJ_CONFIG, schema)));
} catch (JsonMappingException e) {
if (debug.errorEnabled()) {
debug.error("SubjectTypesResource :: JSONIFY - Error applying " + "jsonification to the Subject class representation.", e);
}
return null;
}
}
Aggregations