Search in sources :

Example 1 with TestRuntimeImpl

use of com.dexels.navajo.article.test.TestRuntimeImpl in project navajo by Dexels.

the class TestRuntime method testVerjaardag.

@Test
public void testVerjaardag() throws IOException, NoJSONOutputException, APIException {
    File art = context.resolveArticle("/verjaardagen");
    TestRuntimeImpl tr = new TestRuntimeImpl("verjaardagen", art, null);
    context.interpretArticle(art, tr);
    String out = tr.getOutput();
    System.err.println(out);
    ObjectMapper mapper = new ObjectMapper();
    JsonNode rootNode = mapper.readValue(out, JsonNode.class);
    ObjectWriter writer = mapper.writer().withDefaultPrettyPrinter();
    System.out.println(writer.writeValueAsString(rootNode));
    Assert.assertEquals(11, rootNode.size());
}
Also used : ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) TestRuntimeImpl(com.dexels.navajo.article.test.TestRuntimeImpl) JsonNode(com.fasterxml.jackson.databind.JsonNode) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with TestRuntimeImpl

use of com.dexels.navajo.article.test.TestRuntimeImpl in project navajo by Dexels.

the class TestRuntime method testSearchClub.

@Test
public void testSearchClub() throws IOException, NoJSONOutputException, APIException {
    // this test is a bit outdated
    File art = context.resolveArticle("/searchclub");
    TestRuntimeImpl tr = new TestRuntimeImpl("searchclub", art, null);
    context.interpretArticle(art, tr);
    String out = tr.getOutput();
    System.err.println(out);
    ObjectMapper mapper = new ObjectMapper();
    // (note: can also use more specific type, like ArrayNode or ObjectNode!)
    mapper.readValue(out, JsonNode.class);
// Assert.assertEquals(8, rootNode.get("result").get("Club").size());
}
Also used : TestRuntimeImpl(com.dexels.navajo.article.test.TestRuntimeImpl) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 3 with TestRuntimeImpl

use of com.dexels.navajo.article.test.TestRuntimeImpl in project navajo by Dexels.

the class TestRuntime method testTeams.

@Test
public void testTeams() throws IOException, NoJSONOutputException, APIException {
    File art = context.resolveArticle("/teams");
    TestRuntimeImpl tr = new TestRuntimeImpl("teams", art, null);
    context.interpretArticle(art, tr);
    String out = tr.getOutput();
    System.err.println(out);
    ObjectMapper mapper = new ObjectMapper();
    // (note: can also use more specific type, like ArrayNode or ObjectNode!)
    JsonNode rootNode = mapper.readValue(out, JsonNode.class);
    ObjectWriter writer = mapper.writer().withDefaultPrettyPrinter();
    System.out.println(writer.writeValueAsString(rootNode));
// Assert.assertEquals(24, rootNode.get("data").get("verjaardagen").size());
}
Also used : ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) TestRuntimeImpl(com.dexels.navajo.article.test.TestRuntimeImpl) JsonNode(com.fasterxml.jackson.databind.JsonNode) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

TestRuntimeImpl (com.dexels.navajo.article.test.TestRuntimeImpl)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 File (java.io.File)3 Test (org.junit.Test)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)2