ClusterRestApi { @GET @Path("/" + RestConstants.NODE + "/{nodeName}/{intpName}") @SubmarineApi public Response getClusterNode(@PathParam("nodeName") String nodeName, @PathParam("intpName") String intpName){ ArrayList<HashMap<String, Object>> intpProcesses = new ArrayList<>(); Map<String, HashMap<String, Object>> intpMeta = null; intpMeta = clusterServer.getClusterMeta(ClusterMetaType.INTP_PROCESS_META, ""); for (Map.Entry<String, HashMap<String, Object>> intpMetaEntity : intpMeta.entrySet()) { String intpNodeName = (String) intpMetaEntity.getValue().get(ClusterMeta.NODE_NAME); if (null != intpNodeName && intpNodeName.equals(nodeName)) { HashMap<String, Object> node = new HashMap<String, Object>(); node.put(ClusterMeta.NODE_NAME, intpNodeName); node.put(ClusterMeta.PROPERTIES, intpMetaEntity.getValue()); HashMap<String, Object> properties = intpMetaEntity.getValue(); if (properties.containsKey(ClusterMeta.INTP_START_TIME)) { Object intpStartTime = properties.get(ClusterMeta.INTP_START_TIME); if (intpStartTime instanceof LocalDateTime) { LocalDateTime localDateTime = (LocalDateTime) intpStartTime; String dateTime = formatLocalDateTime(localDateTime); properties.put(ClusterMeta.INTP_START_TIME, dateTime); } else { properties.put(ClusterMeta.INTP_START_TIME, "Wrong time type!"); } } if (properties.containsKey(ClusterMeta.LATEST_HEARTBEAT)) { Object latestHeartbeat = properties.get(ClusterMeta.LATEST_HEARTBEAT); if (latestHeartbeat instanceof LocalDateTime) { LocalDateTime localDateTime = (LocalDateTime) latestHeartbeat; String dateTime = formatLocalDateTime(localDateTime); properties.put(ClusterMeta.LATEST_HEARTBEAT, dateTime); } else { properties.put(ClusterMeta.LATEST_HEARTBEAT, "Wrong time type!"); } } intpProcesses.add(node); } } return new JsonResponse.Builder<ArrayList<HashMap<String, Object>>>(Response.Status.OK) .success(true).result(intpProcesses).build(); }  @VisibleForTesting void setClusterServer(ClusterServer clusterServer); @GET @Path("/" + RestConstants.ADDRESS) @SubmarineApi Response getClusterAddress(); @GET @Path("/" + RestConstants.NODES) @SubmarineApi Response getClusterNodes(); @GET @Path("/" + RestConstants.NODE + "/{nodeName}/{intpName}") @SubmarineApi Response getClusterNode(@PathParam("nodeName") String nodeName,
                                 @PathParam("intpName") String intpName);  }
@Test public void testGetClusterNode() { when(mockClusterServer.getClusterMeta(ClusterMetaType.INTP_PROCESS_META, "")).thenReturn(clusterMetas); Response response = clusterRestApi.getClusterNode(nodeName1, ""); ArrayList<HashMap<String, Object>> result = getResultListFromResponse(response); Map<String, Object> properties = (LinkedTreeMap) result.get(0).get(ClusterMeta.PROPERTIES); assertEquals(clusterMetas.get(nodeName1).get(ClusterMeta.NODE_NAME), result.get(0).get(ClusterMeta.NODE_NAME)); assertEquals("ONLINE", properties.get("STATUS")); assertEquals(INTP_START_TIME.toString(), properties.get("INTP_START_TIME")); assertEquals(LATEST_HEARTBEAT.toString(), properties.get("LATEST_HEARTBEAT")); }