use of org.codehaus.jackson.JsonNode in project pinot by linkedin.
the class TenantTest method testDeserializeFromJson.
@Test
public void testDeserializeFromJson() throws JSONException, IOException {
JSONObject json = new JSONObject();
json.put("tenantRole", "SERVER");
json.put("tenantName", "newTenant");
json.put("numberOfInstances", 10);
json.put("offlineInstances", 5);
json.put("realtimeInstances", 5);
json.put("keyIDontKnow", "blahblahblah");
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readTree(json.toString());
Tenant tenant = mapper.readValue(jsonNode, Tenant.class);
Assert.assertEquals(5, tenant.getOfflineInstances());
Assert.assertEquals(10, tenant.getNumberOfInstances());
Assert.assertEquals("newTenant", tenant.getTenantName());
Assert.assertEquals(TenantRole.SERVER, tenant.getTenantRole());
}
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());
}
}
use of org.codehaus.jackson.JsonNode in project neo4j by neo4j.
the class JavaProceduresTest method shouldLaunchWithDeclaredProcedures.
@Test
public void shouldLaunchWithDeclaredProcedures() throws Exception {
// When
try (ServerControls server = TestServerBuilders.newInProcessBuilder().withProcedure(MyProcedures.class).newServer()) {
// Then
HTTP.Response response = HTTP.POST(server.httpURI().resolve("db/data/transaction/commit").toString(), quotedJson("{ 'statements': [ { 'statement': 'CALL org.neo4j.harness.myProc' } ] }"));
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());
}
}
Aggregations