test_class.declarator: mapper = new ObjectMapper()
test_class.original_string: ObjectMapper mapper = new ObjectMapper();
test_class.type: ObjectMapper
test_class.var_name: mapper
test_class.file: mercator-docker/src/test/java/org/lendingclub/mercator/docker/SwarmScannerTest.java
test_class.identifier: SwarmScannerTest
test_class.superclass: extends MercatorIntegrationTest
test_case.body: @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");
  
  	}
test_case.class_method_signature: SwarmScannerTest.testFlattenTask()
test_case.full_signature: @Test public void testFlattenTask()
test_case.identifier: testFlattenTask
test_case.invocations: readTree flattenTask logInfo isEqualTo assertThat asText get isEqualTo assertThat asText get isEqualTo assertThat asText get isEqualTo assertThat asText get isEqualTo assertThat asText get isEqualTo assertThat asText get isEqualTo assertThat asText get isEqualTo assertThat asText get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFlattenTask()
focal_class.declarator: mapper = new ObjectMapper()
focal_class.original_string: ObjectMapper mapper = new ObjectMapper();
focal_class.type: ObjectMapper
focal_class.var_name: mapper
focal_class.declarator: logger = LoggerFactory.getLogger(SwarmScanner.class)
focal_class.original_string: Logger logger = LoggerFactory.getLogger(SwarmScanner.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: dockerScanner
focal_class.original_string: DockerScanner dockerScanner;
focal_class.type: DockerScanner
focal_class.var_name: dockerScanner
focal_class.declarator: swarmClusterId = null
focal_class.original_string: String swarmClusterId = null;
focal_class.type: String
focal_class.var_name: swarmClusterId
focal_class.file: mercator-docker/src/main/java/org/lendingclub/mercator/docker/SwarmScanner.java
focal_class.identifier: SwarmScanner
focal_class.class_method_signature: SwarmScanner.SwarmScanner(DockerScanner ds)
focal_class.full_signature:   SwarmScanner(DockerScanner ds)
focal_class.identifier: SwarmScanner
focal_class.parameters: (DockerScanner ds)
focal_class.signature:  SwarmScanner(DockerScanner ds)
focal_class.class_method_signature: SwarmScanner.getRestClient()
focal_class.full_signature: public DockerRestClient getRestClient()
focal_class.identifier: getRestClient
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: DockerRestClient
focal_class.signature: DockerRestClient getRestClient()
focal_class.class_method_signature: SwarmScanner.saveDockerNode(String swarmClusterId, JsonNode n)
focal_class.full_signature:  long saveDockerNode(String swarmClusterId, JsonNode n)
focal_class.identifier: saveDockerNode
focal_class.parameters: (String swarmClusterId, JsonNode n)
focal_class.return: long
focal_class.signature: long saveDockerNode(String swarmClusterId, JsonNode n)
focal_class.class_method_signature: SwarmScanner.flattenSwarmNode(JsonNode n)
focal_class.full_signature:  JsonNode flattenSwarmNode(JsonNode n)
focal_class.identifier: flattenSwarmNode
focal_class.parameters: (JsonNode n)
focal_class.return: JsonNode
focal_class.signature: JsonNode flattenSwarmNode(JsonNode n)
focal_class.class_method_signature: SwarmScanner.extractWebTarget(DockerClient c)
focal_class.full_signature: public static WebTarget extractWebTarget(DockerClient c)
focal_class.identifier: extractWebTarget
focal_class.modifiers: public static
focal_class.parameters: (DockerClient c)
focal_class.return: WebTarget
focal_class.signature: WebTarget extractWebTarget(DockerClient c)
focal_class.class_method_signature: SwarmScanner.isUnixDomainScoket(String jerseyUri)
focal_class.full_signature: protected boolean isUnixDomainScoket(String jerseyUri)
focal_class.identifier: isUnixDomainScoket
focal_class.modifiers: protected
focal_class.parameters: (String jerseyUri)
focal_class.return: boolean
focal_class.signature: boolean isUnixDomainScoket(String jerseyUri)
focal_class.class_method_signature: SwarmScanner.scan()
focal_class.full_signature: public void scan()
focal_class.identifier: scan
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void scan()
focal_class.class_method_signature: SwarmScanner.formatLabelKey(String key)
focal_class.full_signature: protected String formatLabelKey(String key)
focal_class.identifier: formatLabelKey
focal_class.modifiers: protected
focal_class.parameters: (String key)
focal_class.return: String
focal_class.signature: String formatLabelKey(String key)
focal_class.class_method_signature: SwarmScanner.flattenService(JsonNode n)
focal_class.full_signature:  ObjectNode flattenService(JsonNode n)
focal_class.identifier: flattenService
focal_class.parameters: (JsonNode n)
focal_class.return: ObjectNode
focal_class.signature: ObjectNode flattenService(JsonNode n)
focal_class.class_method_signature: SwarmScanner.flattenTask(JsonNode n)
focal_class.full_signature: protected ObjectNode flattenTask(JsonNode n)
focal_class.identifier: flattenTask
focal_class.modifiers: protected
focal_class.parameters: (JsonNode n)
focal_class.return: ObjectNode
focal_class.signature: ObjectNode flattenTask(JsonNode n)
focal_class.class_method_signature: SwarmScanner.scanServicesForSwarm(String swarmClusterId)
focal_class.full_signature: public void scanServicesForSwarm(String swarmClusterId)
focal_class.identifier: scanServicesForSwarm
focal_class.modifiers: public
focal_class.parameters: (String swarmClusterId)
focal_class.return: void
focal_class.signature: void scanServicesForSwarm(String swarmClusterId)
focal_class.class_method_signature: SwarmScanner.scanNode(String nodeId)
focal_class.full_signature: public void scanNode(String nodeId)
focal_class.identifier: scanNode
focal_class.modifiers: public
focal_class.parameters: (String nodeId)
focal_class.return: void
focal_class.signature: void scanNode(String nodeId)
focal_class.class_method_signature: SwarmScanner.scanTask(String taskId)
focal_class.full_signature: public void scanTask(String taskId)
focal_class.identifier: scanTask
focal_class.modifiers: public
focal_class.parameters: (String taskId)
focal_class.return: void
focal_class.signature: void scanTask(String taskId)
focal_class.class_method_signature: SwarmScanner.deleteTask(String id)
focal_class.full_signature: public void deleteTask(String id)
focal_class.identifier: deleteTask
focal_class.modifiers: public
focal_class.parameters: (String id)
focal_class.return: void
focal_class.signature: void deleteTask(String id)
focal_class.class_method_signature: SwarmScanner.deleteNode(String id)
focal_class.full_signature: public void deleteNode(String id)
focal_class.identifier: deleteNode
focal_class.modifiers: public
focal_class.parameters: (String id)
focal_class.return: void
focal_class.signature: void deleteNode(String id)
focal_class.class_method_signature: SwarmScanner.checkNotEmpty(String val, String msg)
focal_class.full_signature: private void checkNotEmpty(String val, String msg)
focal_class.identifier: checkNotEmpty
focal_class.modifiers: private
focal_class.parameters: (String val, String msg)
focal_class.return: void
focal_class.signature: void checkNotEmpty(String val, String msg)
focal_class.class_method_signature: SwarmScanner.saveTask(JsonNode it)
focal_class.full_signature: protected long saveTask(JsonNode it)
focal_class.identifier: saveTask
focal_class.modifiers: protected
focal_class.parameters: (JsonNode it)
focal_class.return: long
focal_class.signature: long saveTask(JsonNode it)
focal_class.class_method_signature: SwarmScanner.scanTasksForSwarm(String swarmClusterId)
focal_class.full_signature: public void scanTasksForSwarm(String swarmClusterId)
focal_class.identifier: scanTasksForSwarm
focal_class.modifiers: public
focal_class.parameters: (String swarmClusterId)
focal_class.return: void
focal_class.signature: void scanTasksForSwarm(String swarmClusterId)
focal_class.class_method_signature: SwarmScanner.getSwarmClusterId()
focal_class.full_signature: public Optional<String> getSwarmClusterId()
focal_class.identifier: getSwarmClusterId
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Optional<String>
focal_class.signature: Optional<String> getSwarmClusterId()
focal_class.class_method_signature: SwarmScanner.scanService(String id)
focal_class.full_signature: public void scanService(String id)
focal_class.identifier: scanService
focal_class.modifiers: public
focal_class.parameters: (String id)
focal_class.return: void
focal_class.signature: void scanService(String id)
focal_class.class_method_signature: SwarmScanner.deleteService(String id)
focal_class.full_signature: public void deleteService(String id)
focal_class.identifier: deleteService
focal_class.modifiers: public
focal_class.parameters: (String id)
focal_class.return: void
focal_class.signature: void deleteService(String id)
focal_class.class_method_signature: SwarmScanner.removeDockerLabels(String neo4jLabel, String idName, String idVal, JsonNode intended,
  			JsonNode actual)
focal_class.full_signature: protected void removeDockerLabels(String neo4jLabel, String idName, String idVal, JsonNode intended,
  			JsonNode actual)
focal_class.identifier: removeDockerLabels
focal_class.modifiers: protected
focal_class.parameters: (String neo4jLabel, String idName, String idVal, JsonNode intended,
  			JsonNode actual)
focal_class.return: void
focal_class.signature: void removeDockerLabels(String neo4jLabel, String idName, String idVal, JsonNode intended,
  			JsonNode actual)
focal_class.class_method_signature: SwarmScanner.isNotFound(Throwable e)
focal_class.full_signature: protected boolean isNotFound(Throwable e)
focal_class.identifier: isNotFound
focal_class.modifiers: protected
focal_class.parameters: (Throwable e)
focal_class.return: boolean
focal_class.signature: boolean isNotFound(Throwable e)
focal_method.body: protected ObjectNode flattenTask(JsonNode n) {
  
  		ObjectNode out = new ObjectMapper().createObjectNode();
  		out.put("swarmClusterId", getSwarmClusterId().get());
  		out.put("taskId", n.path("ID").asText());
  		out.put("versionIndex", n.path("Version").path("Index").asText());
  		out.put("createdAt", n.path("CreatedAt").asText());
  		out.put("updatedAt", n.path("UpdatedAt").asText());
  		n.path("Labels").fields().forEachRemaining(it -> {
  			out.put(formatLabelKey(it.getKey()), it.getValue().asText());
  		});
  		n.path("Spec").path("ContainerSepc");
  		out.put("serviceId", n.path("ServiceID").asText());
  
  		out.put("swarmNodeId", n.path("NodeID").asText());
  		out.put("state", n.path("Status").path("State").asText());
  		out.put("message", n.path("Status").path("Message").asText());
  		out.put("containerId", n.path("Status").path("ContainerStatus").path("ContainerID").asText());
  		out.put("desiredState", n.path("DesiredState").asText());
  
  		n.path("Status").path("PortStatus").path("Ports").forEach(it -> {
  
  			String mode = it.path("PublishMode").asText();
  			String protocol = it.path("Protocol").asText();
  			if (mode.equals("host") && protocol.equals("tcp")) {
  
  				int targetPort = it.path("TargetPort").asInt();
  				int publishedPort = it.path("PublishedPort").asInt();
  				String key = String.format("hostTcpPortMap_%d", targetPort);
  				out.put(key, publishedPort);
  			}
  
  		});
  		;
  
  		return out;
  	}
focal_method.class_method_signature: SwarmScanner.flattenTask(JsonNode n)
focal_method.full_signature: protected ObjectNode flattenTask(JsonNode n)
focal_method.identifier: flattenTask
focal_method.invocations: createObjectNode put get getSwarmClusterId put asText path put asText path path put asText path put asText path forEachRemaining fields path put formatLabelKey getKey asText getValue path path put asText path put asText path put asText path path put asText path path put asText path path path put asText path forEach path path path asText path asText path equals equals asInt path asInt path format put
focal_method.modifiers: protected
focal_method.parameters: (JsonNode n)
focal_method.return: ObjectNode
focal_method.signature: ObjectNode flattenTask(JsonNode n)