### Question:
StackAdvisorCommand extends BaseService { protected void populateAmbariServerInfo(ObjectNode root) { Map<String, String> serverProperties = metaInfo.getAmbariServerProperties(); if (serverProperties != null && !serverProperties.isEmpty()) { JsonNode serverPropertiesNode = mapper.convertValue(serverProperties, JsonNode.class); root.put(AMBARI_SERVER_PROPERTIES_PROPERTY, serverPropertiesNode); } } @SuppressWarnings("unchecked")  StackAdvisorCommand(File recommendationsDir, String recommendationsArtifactsLifetime, ServiceInfo.ServiceAdvisorType serviceAdvisorType, int requestId,
                             StackAdvisorRunner saRunner, AmbariMetaInfo metaInfo, AmbariServerConfigurationHandler ambariServerConfigurationHandler); synchronized T invoke(StackAdvisorRequest request, ServiceInfo.ServiceAdvisorType serviceAdvisorType);  }### Answer:
@Test public void testPopulateAmbariServerProperties() throws Exception { File file = mock(File.class); String recommendationsArtifactsLifetime = "1w"; StackAdvisorRunner stackAdvisorRunner = mock(StackAdvisorRunner.class); AmbariMetaInfo ambariMetaInfo = mock(AmbariMetaInfo.class); StackAdvisorCommand<TestResource> cmd = new TestStackAdvisorCommand(file, recommendationsArtifactsLifetime, ServiceInfo.ServiceAdvisorType.PYTHON, 1, stackAdvisorRunner, ambariMetaInfo); ObjectNode objectNode = (ObjectNode) cmd.mapper.readTree("{\"Versions\": " + "{\"stack_name\": \"stack\", \"stack_version\":\"1.0.0\"}}"); Map<String, String> props = Collections.singletonMap("a", "b"); doReturn(props).when(ambariMetaInfo).getAmbariServerProperties(); cmd.populateAmbariServerInfo(objectNode); JsonNode serverProperties = objectNode.get("ambari-server-properties"); assertNotNull(serverProperties); assertEquals("b", serverProperties.iterator().next().getTextValue()); }