Search in sources :

Example 1 with JsonNode

use of io.mantisrx.shaded.com.fasterxml.jackson.databind.JsonNode in project mantis by Netflix.

the class OffsetAndMetadataDeserializer method deserialize.

@Override
public OffsetAndMetadata deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    final JsonNode node = p.getCodec().readTree(p);
    final long offset = node.get("offset").longValue();
    final String metadata = node.get("metadata").textValue();
    return new OffsetAndMetadata(offset, metadata);
}
Also used : OffsetAndMetadata(org.apache.kafka.clients.consumer.OffsetAndMetadata) JsonNode(io.mantisrx.shaded.com.fasterxml.jackson.databind.JsonNode)

Example 2 with JsonNode

use of io.mantisrx.shaded.com.fasterxml.jackson.databind.JsonNode in project mantis by Netflix.

the class JobsRouteTest method validateJobResponse.

private void validateJobResponse(String resp) {
    try {
        assert !Strings.isNullOrEmpty(resp);
        ObjectMapper mapper = new ObjectMapper();
        JsonNode responseObj = mapper.readTree(resp);
        assert responseObj.get("jobMetadata").get("name").asText().equals(TEST_CLUSTER);
        assert responseObj.get("jobMetadata").get("jobId").asText().startsWith("sine-function-");
        assert responseObj.get("jobMetadata").get("sla") != null;
        assert responseObj.get("jobMetadata").get("labels") != null;
        assert responseObj.get("stageMetadataList") != null;
        assert responseObj.get("workerMetadataList") != null;
    } catch (IOException ex) {
        logger.error("Failed to validate job response: " + ex.getMessage());
        assert false;
    }
}
Also used : JsonNode(io.mantisrx.shaded.com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with JsonNode

use of io.mantisrx.shaded.com.fasterxml.jackson.databind.JsonNode in project mantis by Netflix.

the class JobsRouteTest method validateJobsListResponse.

private void validateJobsListResponse(String resp, int expectedJobsCount, boolean isCompact) {
    try {
        assert !Strings.isNullOrEmpty(resp);
        ObjectMapper mapper = new ObjectMapper();
        JsonNode responseObj = mapper.readTree(resp).get("list");
        assert responseObj.size() == expectedJobsCount;
        for (int i = 0; i < expectedJobsCount; i++) {
            validateJobsListItem(responseObj.get(i), isCompact);
        }
    } catch (IOException ex) {
        logger.error("Failed to validate job response: " + ex.getMessage());
        assert false;
    }
}
Also used : JsonNode(io.mantisrx.shaded.com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with JsonNode

use of io.mantisrx.shaded.com.fasterxml.jackson.databind.JsonNode in project mantis by Netflix.

the class JobsRouteTest method validateJobDetails.

private void validateJobDetails(String resp) {
    try {
        assert !Strings.isNullOrEmpty(resp);
        ObjectMapper mapper = new ObjectMapper();
        JsonNode responseObj = mapper.readTree(resp);
        validateJobsListItem(responseObj, false);
    } catch (IOException ex) {
        logger.error("Failed to validate job details response: " + ex.getMessage());
        assert false;
    }
}
Also used : JsonNode(io.mantisrx.shaded.com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with JsonNode

use of io.mantisrx.shaded.com.fasterxml.jackson.databind.JsonNode in project mantis by Netflix.

the class JobClustersRouteTest method compareClusterInstancePayload.

private void compareClusterInstancePayload(String clusterGetResponse) {
    try {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode requestObj = mapper.readTree(JobClusterPayloads.JOB_CLUSTER_CREATE);
        JsonNode responseObj = mapper.readTree(clusterGetResponse);
        assertEquals(responseObj.get("name").toString(), requestObj.get("jobDefinition").get("name").toString());
        assertEquals(responseObj.get("jars").get(0).get("url").toString(), requestObj.get("jobDefinition").get("jobJarFileLocation").toString());
        assertEquals(responseObj.get("jars").get(0).get("version").toString(), requestObj.get("jobDefinition").get("version").toString());
    } catch (IOException ex) {
        assert ex == null;
    }
}
Also used : JsonNode(io.mantisrx.shaded.com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JsonNode (io.mantisrx.shaded.com.fasterxml.jackson.databind.JsonNode)6 ObjectMapper (io.mantisrx.shaded.com.fasterxml.jackson.databind.ObjectMapper)5 IOException (java.io.IOException)5 OffsetAndMetadata (org.apache.kafka.clients.consumer.OffsetAndMetadata)1