@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, "test", 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()); }
protected void populateAmbariServerInfo(ObjectNode root) throws StackAdvisorException { Map<String, String> serverProperties = metaInfo.getAmbariServerProperties(); if (serverProperties != null && !serverProperties.isEmpty()) { JsonNode serverPropertiesNode = mapper.convertValue(serverProperties, JsonNode.class); root.put(AMBARI_SERVER_CONFIGURATIONS_PROPERTY, serverPropertiesNode); } }
StackAdvisorCommand extends BaseService { protected void populateAmbariServerInfo(ObjectNode root) throws StackAdvisorException { Map<String, String> serverProperties = metaInfo.getAmbariServerProperties(); if (serverProperties != null && !serverProperties.isEmpty()) { JsonNode serverPropertiesNode = mapper.convertValue(serverProperties, JsonNode.class); root.put(AMBARI_SERVER_CONFIGURATIONS_PROPERTY, serverPropertiesNode); } } }
StackAdvisorCommand extends BaseService { protected void populateAmbariServerInfo(ObjectNode root) throws StackAdvisorException { Map<String, String> serverProperties = metaInfo.getAmbariServerProperties(); if (serverProperties != null && !serverProperties.isEmpty()) { JsonNode serverPropertiesNode = mapper.convertValue(serverProperties, JsonNode.class); root.put(AMBARI_SERVER_CONFIGURATIONS_PROPERTY, serverPropertiesNode); } } @SuppressWarnings("unchecked")  StackAdvisorCommand(File recommendationsDir, String recommendationsArtifactsLifetime, String stackAdvisorScript, int requestId,
      StackAdvisorRunner saRunner, AmbariMetaInfo metaInfo); }
StackAdvisorCommand extends BaseService { protected void populateAmbariServerInfo(ObjectNode root) throws StackAdvisorException { Map<String, String> serverProperties = metaInfo.getAmbariServerProperties(); if (serverProperties != null && !serverProperties.isEmpty()) { JsonNode serverPropertiesNode = mapper.convertValue(serverProperties, JsonNode.class); root.put(AMBARI_SERVER_CONFIGURATIONS_PROPERTY, serverPropertiesNode); } } @SuppressWarnings("unchecked")  StackAdvisorCommand(File recommendationsDir, String recommendationsArtifactsLifetime, String stackAdvisorScript, int requestId,
      StackAdvisorRunner saRunner, AmbariMetaInfo metaInfo); synchronized T invoke(StackAdvisorRequest request); }
StackAdvisorCommand extends BaseService { protected void populateAmbariServerInfo(ObjectNode root) throws StackAdvisorException { Map<String, String> serverProperties = metaInfo.getAmbariServerProperties(); if (serverProperties != null && !serverProperties.isEmpty()) { JsonNode serverPropertiesNode = mapper.convertValue(serverProperties, JsonNode.class); root.put(AMBARI_SERVER_CONFIGURATIONS_PROPERTY, serverPropertiesNode); } } @SuppressWarnings("unchecked")  StackAdvisorCommand(File recommendationsDir, String recommendationsArtifactsLifetime, String stackAdvisorScript, int requestId,
      StackAdvisorRunner saRunner, AmbariMetaInfo metaInfo); synchronized T invoke(StackAdvisorRequest request);  }