### Question:
TrackingInfoUtils { public static JsonObject getMicroservicesInfo(JsonArray microservices) { LoggingService.logInfo(MODULE_NAME, "Start getting microservice information"); JsonObject info = null; if(microservices != null){ info = Json.createObjectBuilder() .add("microservices", microservices) .add("microservicesCount", microservices.size()) .build(); } else { LoggingService.logError(MODULE_NAME, "can't get microservices info : option or value must not be null", new AgentSystemException("can't get microservices info : option or value must not be null")); info = Json.createObjectBuilder() .add("error", "can't get microservices info : microservices must not be null") .build(); } LoggingService.logInfo(MODULE_NAME, "Finished getting microservice information"); return info; }  static JsonObject getStartTrackingInfo(); static JsonObject getConfigUpdateInfo(String option, String newValue); static JsonObject getMicroservicesInfo(JsonArray microservices);  }### Answer:
@Test public void testGetMicroservicesInfoWhenInputIsEmpty() { JsonArray microservice = Json.createArrayBuilder().build(); assertTrue(TrackingInfoUtils.getMicroservicesInfo(microservice).containsKey("microservices")); assertTrue(TrackingInfoUtils.getMicroservicesInfo(microservice).containsKey("microservicesCount")); PowerMockito.verifyStatic(LoggingService.class, Mockito.atLeastOnce()); LoggingService.logInfo(MODULE_NAME, "Start getting microservice information"); PowerMockito.verifyStatic(LoggingService.class, Mockito.atLeastOnce()); LoggingService.logInfo(MODULE_NAME, "Finished getting microservice information"); }
@Test public void testGetMicroservicesInfoWhenInputIsNotEmpty() { JsonArray microservice = Json.createArrayBuilder().add(Json.createObjectBuilder().add("message", "message")).build(); assertTrue(TrackingInfoUtils.getMicroservicesInfo(microservice).containsKey("microservices")); assertTrue(TrackingInfoUtils.getMicroservicesInfo(microservice).containsKey("microservicesCount")); PowerMockito.verifyStatic(LoggingService.class, Mockito.atLeastOnce()); LoggingService.logInfo(MODULE_NAME, "Start getting microservice information"); PowerMockito.verifyStatic(LoggingService.class, Mockito.atLeastOnce()); LoggingService.logInfo(MODULE_NAME, "Finished getting microservice information"); }
@Test public void testGetMicroservicesInfoWhenInputIsNull() { JsonArray microservice = null; assertTrue(TrackingInfoUtils.getMicroservicesInfo(microservice).containsKey("error")); assertFalse(TrackingInfoUtils.getMicroservicesInfo(microservice).containsKey("microservices")); assertFalse(TrackingInfoUtils.getMicroservicesInfo(microservice).containsKey("microservicesCount")); PowerMockito.verifyStatic(LoggingService.class, Mockito.atLeastOnce()); LoggingService.logInfo(MODULE_NAME, "Start getting microservice information"); PowerMockito.verifyStatic(LoggingService.class, Mockito.atLeastOnce()); LoggingService.logError(eq(MODULE_NAME), eq("can't get microservices info : option or value must not be null"), any()); PowerMockito.verifyStatic(LoggingService.class, Mockito.atLeastOnce()); LoggingService.logInfo(MODULE_NAME, "Finished getting microservice information"); }