@Test public void testPopulateStackHierarchy_noParents() 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\"}}"); doReturn(Collections.emptyList()).when(ambariMetaInfo).getStackParentVersions("stack", "1.0.0"); cmd.populateStackHierarchy(objectNode); JsonNode stackHierarchy = objectNode.get("Versions").get("stack_hierarchy"); assertNotNull(stackHierarchy); JsonNode stackName = stackHierarchy.get("stack_name"); assertNotNull(stackName); assertEquals("stack", stackName.asText()); ArrayNode stackVersions = (ArrayNode) stackHierarchy.get("stack_versions"); assertNotNull(stackVersions); assertEquals(0, stackVersions.size()); }
protected void populateStackHierarchy(ObjectNode root) { ObjectNode version = (ObjectNode) root.get("Versions"); TextNode stackName = (TextNode) version.get("stack_name"); TextNode stackVersion = (TextNode) version.get("stack_version"); ObjectNode stackHierarchy = version.putObject("stack_hierarchy"); stackHierarchy.put("stack_name", stackName); ArrayNode parents = stackHierarchy.putArray("stack_versions"); for (String parentVersion : metaInfo.getStackParentVersions(stackName.asText(), stackVersion.asText())) { parents.add(parentVersion); } }
StackAdvisorCommand extends BaseService { protected void populateStackHierarchy(ObjectNode root) { ObjectNode version = (ObjectNode) root.get("Versions"); TextNode stackName = (TextNode) version.get("stack_name"); TextNode stackVersion = (TextNode) version.get("stack_version"); ObjectNode stackHierarchy = version.putObject("stack_hierarchy"); stackHierarchy.put("stack_name", stackName); ArrayNode parents = stackHierarchy.putArray("stack_versions"); for (String parentVersion : metaInfo.getStackParentVersions(stackName.asText(), stackVersion.asText())) { parents.add(parentVersion); } } }
StackAdvisorCommand extends BaseService { protected void populateStackHierarchy(ObjectNode root) { ObjectNode version = (ObjectNode) root.get("Versions"); TextNode stackName = (TextNode) version.get("stack_name"); TextNode stackVersion = (TextNode) version.get("stack_version"); ObjectNode stackHierarchy = version.putObject("stack_hierarchy"); stackHierarchy.put("stack_name", stackName); ArrayNode parents = stackHierarchy.putArray("stack_versions"); for (String parentVersion : metaInfo.getStackParentVersions(stackName.asText(), stackVersion.asText())) { parents.add(parentVersion); } } @SuppressWarnings("unchecked")  StackAdvisorCommand(File recommendationsDir, String recommendationsArtifactsLifetime, String stackAdvisorScript, int requestId,
      StackAdvisorRunner saRunner, AmbariMetaInfo metaInfo); }
StackAdvisorCommand extends BaseService { protected void populateStackHierarchy(ObjectNode root) { ObjectNode version = (ObjectNode) root.get("Versions"); TextNode stackName = (TextNode) version.get("stack_name"); TextNode stackVersion = (TextNode) version.get("stack_version"); ObjectNode stackHierarchy = version.putObject("stack_hierarchy"); stackHierarchy.put("stack_name", stackName); ArrayNode parents = stackHierarchy.putArray("stack_versions"); for (String parentVersion : metaInfo.getStackParentVersions(stackName.asText(), stackVersion.asText())) { parents.add(parentVersion); } } @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 populateStackHierarchy(ObjectNode root) { ObjectNode version = (ObjectNode) root.get("Versions"); TextNode stackName = (TextNode) version.get("stack_name"); TextNode stackVersion = (TextNode) version.get("stack_version"); ObjectNode stackHierarchy = version.putObject("stack_hierarchy"); stackHierarchy.put("stack_name", stackName); ArrayNode parents = stackHierarchy.putArray("stack_versions"); for (String parentVersion : metaInfo.getStackParentVersions(stackName.asText(), stackVersion.asText())) { parents.add(parentVersion); } } @SuppressWarnings("unchecked")  StackAdvisorCommand(File recommendationsDir, String recommendationsArtifactsLifetime, String stackAdvisorScript, int requestId,
      StackAdvisorRunner saRunner, AmbariMetaInfo metaInfo); synchronized T invoke(StackAdvisorRequest request);  }