use of com.fasterxml.jackson.databind.node.TextNode in project flink by apache.
the class JsonGeneratorTest method testGeneratorWithoutAnyAttachements.
@Test
public void testGeneratorWithoutAnyAttachements() {
try {
JobVertex source1 = new JobVertex("source 1");
JobVertex source2 = new JobVertex("source 2");
source2.setInvokableClass(DummyInvokable.class);
JobVertex source3 = new JobVertex("source 3");
JobVertex intermediate1 = new JobVertex("intermediate 1");
JobVertex intermediate2 = new JobVertex("intermediate 2");
JobVertex join1 = new JobVertex("join 1");
JobVertex join2 = new JobVertex("join 2");
JobVertex sink1 = new JobVertex("sink 1");
JobVertex sink2 = new JobVertex("sink 2");
intermediate1.connectNewDataSetAsInput(source1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
intermediate2.connectNewDataSetAsInput(source2, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED);
join1.connectNewDataSetAsInput(intermediate1, DistributionPattern.POINTWISE, ResultPartitionType.BLOCKING);
join1.connectNewDataSetAsInput(intermediate2, DistributionPattern.ALL_TO_ALL, ResultPartitionType.BLOCKING);
join2.connectNewDataSetAsInput(join1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
join2.connectNewDataSetAsInput(source3, DistributionPattern.POINTWISE, ResultPartitionType.BLOCKING);
sink1.connectNewDataSetAsInput(join2, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
sink2.connectNewDataSetAsInput(join1, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED);
JobGraph jg = new JobGraph("my job", source1, source2, source3, intermediate1, intermediate2, join1, join2, sink1, sink2);
String plan = JsonPlanGenerator.generatePlan(jg);
assertNotNull(plan);
// validate the produced JSON
ObjectMapper m = new ObjectMapper();
JsonNode rootNode = m.readTree(plan);
// core fields
assertEquals(new TextNode(jg.getJobID().toString()), rootNode.get("jid"));
assertEquals(new TextNode(jg.getName()), rootNode.get("name"));
assertTrue(rootNode.path("nodes").isArray());
for (Iterator<JsonNode> iter = rootNode.path("nodes").elements(); iter.hasNext(); ) {
JsonNode next = iter.next();
JsonNode idNode = next.get("id");
assertNotNull(idNode);
assertTrue(idNode.isTextual());
checkVertexExists(idNode.asText(), jg);
String description = next.get("description").asText();
assertTrue(description.startsWith("source") || description.startsWith("sink") || description.startsWith("intermediate") || description.startsWith("join"));
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.fasterxml.jackson.databind.node.TextNode in project jsonschema2pojo by joelittlejohn.
the class FormatRuleJodaTest method applyGeneratesTypeFromFormatValue.
@Test
public void applyGeneratesTypeFromFormatValue() {
TextNode formatNode = TextNode.valueOf(formatValue);
JType result = rule.apply("fooBar", formatNode, new JCodeModel().ref(String.class), null);
assertThat(result.fullName(), equalTo(expectedType.getName()));
}
use of com.fasterxml.jackson.databind.node.TextNode in project jsonschema2pojo by joelittlejohn.
the class FormatRuleTest method applyDefaultsToBaseType.
@Test
public void applyDefaultsToBaseType() {
TextNode formatNode = TextNode.valueOf("unknown-format");
JType baseType = new JCodeModel().ref(Long.class);
JType result = rule.apply("fooBar", formatNode, baseType, null);
assertThat(result, equalTo(baseType));
}
use of com.fasterxml.jackson.databind.node.TextNode in project swagger-core by swagger-api.
the class PropertyDeserializer method getEnum.
private static List<String> getEnum(JsonNode node, PropertyBuilder.PropertyId type) {
final List<String> result = new ArrayList<String>();
JsonNode detailNode = getDetailNode(node, type);
if (detailNode != null) {
ArrayNode an = (ArrayNode) detailNode;
for (JsonNode child : an) {
if (child instanceof TextNode || child instanceof NumericNode || child instanceof IntNode || child instanceof LongNode || child instanceof DoubleNode || child instanceof FloatNode) {
result.add(child.asText());
}
}
}
return result.isEmpty() ? null : result;
}
use of com.fasterxml.jackson.databind.node.TextNode in project Gaffer by gchq.
the class HyperLogLogPlusJsonDeserialiser method deserialize.
// TODO - See 'Can't create HyperLogLogPlus sketches in JSON'
@Override
public HyperLogLogPlus deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
final TreeNode treeNode = jsonParser.getCodec().readTree(jsonParser);
final TreeNode coreHyperLogLogPlusObject = treeNode.get("hyperLogLogPlus");
if (coreHyperLogLogPlusObject != null) {
final TextNode jsonNodes = (TextNode) coreHyperLogLogPlusObject.get(HyperLogLogPlusJsonConstants.HYPER_LOG_LOG_PLUS_SKETCH_BYTES_FIELD);
final byte[] nodeAsString = jsonNodes.binaryValue();
final HyperLogLogPlus hyperLogLogPlus = HyperLogLogPlus.Builder.build(nodeAsString);
return hyperLogLogPlus;
} else {
throw new IllegalArgumentException("Recieved null or empty HyperLogLogPlus sketch");
}
}
Aggregations