### Question:
StackAdvisorCommand extends BaseService { void populateAmbariConfiguration(ObjectNode root) { root.put(AMBARI_SERVER_CONFIGURATIONS_PROPERTY, mapper.valueToTree(ambariServerConfigurationHandler.getConfigurations())); } @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 testPopulateLdapConfig() throws Exception { Map<String, Map<String, String>> storedConfig = Collections.singletonMap("ldap-configuration", Collections.singletonMap("authentication.ldap.secondaryUrl", "localhost:333")); TestStackAdvisorCommand command = new TestStackAdvisorCommand( temp.newFolder("recommendationDir"), "1w", ServiceInfo.ServiceAdvisorType.PYTHON, 0, mock(StackAdvisorRunner.class), mock(AmbariMetaInfo.class)); when(ambariServerConfigurationHandler.getConfigurations()).thenReturn(storedConfig); JsonNode servicesRootNode = json("{}"); command.populateAmbariConfiguration((ObjectNode)servicesRootNode); JsonNode expectedLdapConfig = json("{\"ambari-server-configuration\":{\"ldap-configuration\":{\"authentication.ldap.secondaryUrl\":\"localhost:333\"}}}"); assertEquals(expectedLdapConfig, servicesRootNode); }
@Test public void testPopulateLdapConfig_NoConfigs() throws Exception { TestStackAdvisorCommand command = new TestStackAdvisorCommand( temp.newFolder("recommendationDir"), "1w", ServiceInfo.ServiceAdvisorType.PYTHON, 0, mock(StackAdvisorRunner.class), mock(AmbariMetaInfo.class)); when(ambariServerConfigurationHandler.getConfigurations()).thenReturn(emptyMap()); JsonNode servicesRootNode = json("{}"); command.populateAmbariConfiguration((ObjectNode)servicesRootNode); JsonNode expectedLdapConfig = json("{\"ambari-server-configuration\":{}}"); assertEquals(expectedLdapConfig, servicesRootNode); }