use of org.codehaus.jackson.JsonNode in project neo4j by neo4j.
the class ExceptionRepresentationTest method shouldRenderErrorsWithNeo4jStatusCode.
@Test
public void shouldRenderErrorsWithNeo4jStatusCode() throws Exception {
// Given
ExceptionRepresentation rep = new ExceptionRepresentation(new KernelException(UnknownError, "Hello") {
});
// When
JsonNode out = serialize(rep);
// Then
assertThat(out.get("errors").get(0).get("code").asText(), equalTo("Neo.DatabaseError.General.UnknownError"));
assertThat(out.get("errors").get(0).get("message").asText(), equalTo("Hello"));
}
use of org.codehaus.jackson.JsonNode in project neo4j by neo4j.
the class ExceptionRepresentationTest method shoudExcludeLegacyFormatIfAsked.
@Test
public void shoudExcludeLegacyFormatIfAsked() throws Exception {
// Given
ExceptionRepresentation rep = new ExceptionRepresentation(new KernelException(UnknownError, "Hello") {
}, /*legacy*/
false);
// When
JsonNode out = serialize(rep);
// Then
assertThat(out.get("errors").get(0).get("code").asText(), equalTo("Neo.DatabaseError.General.UnknownError"));
assertThat(out.get("errors").get(0).get("message").asText(), equalTo("Hello"));
assertThat(out.has("message"), equalTo(false));
}
use of org.codehaus.jackson.JsonNode in project neo4j by neo4j.
the class JavaAggregationFunctionsTest method shouldLaunchWithDeclaredFunctions.
@Test
public void shouldLaunchWithDeclaredFunctions() throws Exception {
// When
try (ServerControls server = TestServerBuilders.newInProcessBuilder().withAggregationFunction(MyFunctions.class).newServer()) {
// Then
HTTP.Response response = HTTP.POST(server.httpURI().resolve("db/data/transaction/commit").toString(), quotedJson("{ 'statements': [ { 'statement': 'RETURN org.neo4j.harness.myFunc() AS someNumber' } ] " + "}"));
JsonNode result = response.get("results").get(0);
assertEquals("someNumber", result.get("columns").get(0).asText());
assertEquals(1337, result.get("data").get(0).get("row").get(0).asInt());
assertEquals("[]", response.get("errors").toString());
}
}
use of org.codehaus.jackson.JsonNode in project neo4j by neo4j.
the class JavaFunctionsTest method shouldLaunchWithDeclaredFunctions.
@Test
public void shouldLaunchWithDeclaredFunctions() throws Exception {
// When
try (ServerControls server = TestServerBuilders.newInProcessBuilder().withFunction(MyFunctions.class).newServer()) {
// Then
HTTP.Response response = HTTP.POST(server.httpURI().resolve("db/data/transaction/commit").toString(), quotedJson("{ 'statements': [ { 'statement': 'RETURN org.neo4j.harness.myFunc() AS someNumber' } ] " + "}"));
JsonNode result = response.get("results").get(0);
assertEquals("someNumber", result.get("columns").get(0).asText());
assertEquals(1337, result.get("data").get(0).get("row").get(0).asInt());
assertEquals("[]", response.get("errors").toString());
}
}
use of org.codehaus.jackson.JsonNode in project neo4j by neo4j.
the class JavaFunctionsTest method shouldWorkWithInjectableFromKernelExtension.
@Test
public void shouldWorkWithInjectableFromKernelExtension() throws Throwable {
// When
try (ServerControls server = TestServerBuilders.newInProcessBuilder().withFunction(MyFunctionsUsingMyService.class).newServer()) {
// Then
HTTP.Response response = HTTP.POST(server.httpURI().resolve("db/data/transaction/commit").toString(), quotedJson("{ 'statements': [ { 'statement': 'RETURN my.hello() AS result' } ] }"));
assertEquals("[]", response.get("errors").toString());
JsonNode result = response.get("results").get(0);
assertEquals("result", result.get("columns").get(0).asText());
assertEquals("world", result.get("data").get(0).get("row").get(0).asText());
}
}
Aggregations