@Test public void testCreateRecommendationCommand_returnsComponentLayoutRecommendationCommand() throws IOException, StackAdvisorException { Configuration configuration = mock(Configuration.class); when(configuration.getRecommendationsArtifactsRolloverMax()).thenReturn(100); StackAdvisorRunner saRunner = mock(StackAdvisorRunner.class); AmbariMetaInfo metaInfo = mock(AmbariMetaInfo.class); StackAdvisorHelper helper = new StackAdvisorHelper(configuration, saRunner, metaInfo); StackAdvisorRequestType requestType = StackAdvisorRequestType.HOST_GROUPS; StackAdvisorCommand<RecommendationResponse> command = helper .createRecommendationCommand(requestType); assertEquals(ComponentLayoutRecommendationCommand.class, command.getClass()); }
StackAdvisorCommand<RecommendationResponse> createRecommendationCommand( StackAdvisorRequestType requestType) throws StackAdvisorException { StackAdvisorCommand<RecommendationResponse> command; if (requestType == StackAdvisorRequestType.HOST_GROUPS) { command = new ComponentLayoutRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else if (requestType == StackAdvisorRequestType.CONFIGURATIONS) { command = new ConfigurationRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else if (requestType == StackAdvisorRequestType.CONFIGURATION_DEPENDENCIES) { command = new ConfigurationDependenciesRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else { throw new StackAdvisorRequestException(String.format("Unsupported request type, type=%s", requestType)); } return command; }
StackAdvisorHelper { StackAdvisorCommand<RecommendationResponse> createRecommendationCommand( StackAdvisorRequestType requestType) throws StackAdvisorException { StackAdvisorCommand<RecommendationResponse> command; if (requestType == StackAdvisorRequestType.HOST_GROUPS) { command = new ComponentLayoutRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else if (requestType == StackAdvisorRequestType.CONFIGURATIONS) { command = new ConfigurationRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else if (requestType == StackAdvisorRequestType.CONFIGURATION_DEPENDENCIES) { command = new ConfigurationDependenciesRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else { throw new StackAdvisorRequestException(String.format("Unsupported request type, type=%s", requestType)); } return command; } }
StackAdvisorHelper { StackAdvisorCommand<RecommendationResponse> createRecommendationCommand( StackAdvisorRequestType requestType) throws StackAdvisorException { StackAdvisorCommand<RecommendationResponse> command; if (requestType == StackAdvisorRequestType.HOST_GROUPS) { command = new ComponentLayoutRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else if (requestType == StackAdvisorRequestType.CONFIGURATIONS) { command = new ConfigurationRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else if (requestType == StackAdvisorRequestType.CONFIGURATION_DEPENDENCIES) { command = new ConfigurationDependenciesRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else { throw new StackAdvisorRequestException(String.format("Unsupported request type, type=%s", requestType)); } return command; } @Inject  StackAdvisorHelper(Configuration conf, StackAdvisorRunner saRunner,
                            AmbariMetaInfo metaInfo); }
StackAdvisorHelper { StackAdvisorCommand<RecommendationResponse> createRecommendationCommand( StackAdvisorRequestType requestType) throws StackAdvisorException { StackAdvisorCommand<RecommendationResponse> command; if (requestType == StackAdvisorRequestType.HOST_GROUPS) { command = new ComponentLayoutRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else if (requestType == StackAdvisorRequestType.CONFIGURATIONS) { command = new ConfigurationRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else if (requestType == StackAdvisorRequestType.CONFIGURATION_DEPENDENCIES) { command = new ConfigurationDependenciesRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else { throw new StackAdvisorRequestException(String.format("Unsupported request type, type=%s", requestType)); } return command; } @Inject  StackAdvisorHelper(Configuration conf, StackAdvisorRunner saRunner,
                            AmbariMetaInfo metaInfo); synchronized ValidationResponse validate(StackAdvisorRequest request); synchronized RecommendationResponse recommend(StackAdvisorRequest request); }
StackAdvisorHelper { StackAdvisorCommand<RecommendationResponse> createRecommendationCommand( StackAdvisorRequestType requestType) throws StackAdvisorException { StackAdvisorCommand<RecommendationResponse> command; if (requestType == StackAdvisorRequestType.HOST_GROUPS) { command = new ComponentLayoutRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else if (requestType == StackAdvisorRequestType.CONFIGURATIONS) { command = new ConfigurationRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else if (requestType == StackAdvisorRequestType.CONFIGURATION_DEPENDENCIES) { command = new ConfigurationDependenciesRecommendationCommand(recommendationsDir, recommendationsArtifactsLifetime, stackAdvisorScript, requestId, saRunner, metaInfo); } else { throw new StackAdvisorRequestException(String.format("Unsupported request type, type=%s", requestType)); } return command; } @Inject  StackAdvisorHelper(Configuration conf, StackAdvisorRunner saRunner,
                            AmbariMetaInfo metaInfo); synchronized ValidationResponse validate(StackAdvisorRequest request); synchronized RecommendationResponse recommend(StackAdvisorRequest request);  }