@Test
public void testFlattenTask() throws Exception {

	String taskJson = " {\n" + "  \"ID\" : \"kz0xbugh9xnf4bqcxjqc97lo3\",\n" + "  \"Version\" : {\n"
			+ "    \"Index\" : 112\n" + "  },\n" + "  \"CreatedAt\" : \"2017-09-08T21:24:42.408242959Z\",\n"
			+ "  \"UpdatedAt\" : \"2017-09-09T02:12:26.443758461Z\",\n" + "  \"Labels\" : { },\n"
			+ "  \"Spec\" : {\n" + "    \"ContainerSpec\" : {\n"
			+ "      \"Image\" : \"trident-echo:latest@sha256:8c850603e5b67909da2409003454d91a154b5dacb2d9add580355f8a42ea2ae0\",\n"
			+ "      \"Env\" : [ \"path=/api/foo\", \"app=foo\" ],\n" + "      \"DNSConfig\" : { }\n" + "    },\n"
			+ "    \"Resources\" : {\n" + "      \"Limits\" : { },\n" + "      \"Reservations\" : { }\n"
			+ "    },\n" + "    \"Placement\" : {\n" + "      \"Platforms\" : [ {\n"
			+ "        \"Architecture\" : \"amd64\",\n" + "        \"OS\" : \"linux\"\n" + "      } ]\n"
			+ "    },\n" + "    \"ForceUpdate\" : 0\n" + "  },\n"
			+ "  \"ServiceID\" : \"sx6r9h4zsyosjqgfx2x66zv7a\",\n" + "  \"Slot\" : 2,\n"
			+ "  \"NodeID\" : \"un7e89zvlnb4c2l11yvmsvlio\",\n" + "  \"Status\" : {\n"
			+ "    \"Timestamp\" : \"2017-09-09T02:12:26.350558639Z\",\n" + "    \"State\" : \"shutdown\",\n"
			+ "    \"Message\" : \"shutdown\",\n" + "    \"ContainerStatus\" : {\n"
			+ "      \"ContainerID\" : \"1812bf07dea79f54c22313d4fe3de263abfc0bfebee9014b09a748208c00aa39\",\n"
			+ "      \"ExitCode\" : 143\n" + "    },\n" + "    \"PortStatus\" : { }\n" + "  },\n"
			+ "  \"DesiredState\" : \"shutdown\"\n" + "}";
	ObjectNode n = (ObjectNode) mapper.readTree(taskJson);
	SwarmScanner scanner = new SwarmScanner(null);
	scanner.swarmClusterId = "abcd123";
	JsonNode flattened = scanner.flattenTask(n);
	JsonLogger.logInfo("foo", flattened);
	Assertions.assertThat(flattened.get("swarmClusterId").asText()).isEqualTo("abcd123");
	Assertions.assertThat(flattened.get("taskId").asText()).isEqualTo("kz0xbugh9xnf4bqcxjqc97lo3");
	Assertions.assertThat(flattened.get("serviceId").asText()).isEqualTo("sx6r9h4zsyosjqgfx2x66zv7a");
	Assertions.assertThat(flattened.get("swarmNodeId").asText()).isEqualTo("un7e89zvlnb4c2l11yvmsvlio");
	Assertions.assertThat(flattened.get("state").asText()).isEqualTo("shutdown");
	Assertions.assertThat(flattened.get("message").asText()).isEqualTo("shutdown");
	Assertions.assertThat(flattened.get("desiredState").asText()).isEqualTo("shutdown");
	Assertions.assertThat(flattened.get("containerId").asText())
			.isEqualTo("1812bf07dea79f54c22313d4fe3de263abfc0bfebee9014b09a748208c00aa39");
}