protected String data(DataPair... snippets) throws Exception { JsonNode jsonNode = jsonData(snippets); String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonNode); return json; } }
protected static IntegrationRouteBuilder newIntegrationRouteBuilder(Step... steps) { return newIntegrationRouteBuilder(newIntegration(steps)); }
@Override protected Integration loadIntegration() { Integration integration = newIntegration( new Step.Builder() .id("step-1")
protected void dumpRoutes(CamelContext context) { RoutesDefinition definition = new RoutesDefinition(); definition.setRoutes(context.getRouteDefinitions()); dumpRoutes(context, definition); }
@Override protected Integration loadIntegration() { Integration integration = newIntegration( new Step.Builder() .id("step-1")
@Override protected Integration loadIntegration() { Integration integration = newIntegration( new Step.Builder() .id("step-1")
private JsonNode jsonData(DataPair... snippets) { ObjectNode node = mapper.createObjectNode(); for (DataPair snippet : snippets) { String key = snippet.key.toString(); if (snippet.value instanceof String) { node.put(key, snippet.value.toString()); } else if (snippet.value instanceof String[]) { ArrayNode array = mapper.createArrayNode(); Arrays.stream((String[]) snippet.value).forEach(array::add); node.set(key, array); } else if (snippet.value instanceof DataPair[]) { ArrayNode array = mapper.createArrayNode(); Arrays.stream((DataPair[]) snippet.value).forEach(me -> { JsonNode element = jsonData(me); array.add(element); }); node.set(key, array); } else if (snippet.value instanceof DataPair) { JsonNode valueNode = jsonData((DataPair) snippet.value); node.set(key, valueNode); } } return node; }