ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [07/13] ambari git commit: AMBARI-21450 - Fixing Unit Test Compilation Issues From trunk Merge (jonathanhurley)
Date Wed, 19 Jul 2017 14:20:09 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/56362fd6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java
index ce45ffe..64d7527 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -18,25 +18,22 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import junit.framework.Assert;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.MaintenanceStateHelper;
 import org.apache.ambari.server.controller.ResourceProviderFactory;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.junit.Test;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
+import junit.framework.Assert;
 
 /**
  * Abstract controller resource provider test.
@@ -44,34 +41,28 @@ import static org.junit.Assert.assertEquals;
 public class AbstractControllerResourceProviderTest {
   @Test
   public void testGetResourceProvider() throws Exception {
-    Set<String> propertyIds = new HashSet<String>();
-    propertyIds.add("foo");
-    propertyIds.add("cat1/foo");
-    propertyIds.add("cat2/bar");
-    propertyIds.add("cat2/baz");
-    propertyIds.add("cat3/sub1/bam");
-    propertyIds.add("cat4/sub2/sub3/bat");
-    propertyIds.add("cat5/subcat5/map");
-
-    Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
-
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
 
     ResourceProviderFactory factory = createMock(ResourceProviderFactory.class);
 
     MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);
-    ResourceProvider serviceResourceProvider = new ServiceResourceProvider(propertyIds, keyPropertyIds, managementController, maintenanceStateHelper);
-    expect(factory.getServiceResourceProvider(propertyIds, keyPropertyIds, managementController)).andReturn(serviceResourceProvider);
+    RepositoryVersionDAO repositoryVersionDAO = createNiceMock(RepositoryVersionDAO.class);
+
+    ResourceProvider serviceResourceProvider = new ServiceResourceProvider(managementController,
+        maintenanceStateHelper, repositoryVersionDAO);
+
+    expect(factory.getServiceResourceProvider(managementController)).andReturn(
+        serviceResourceProvider);
 
     AbstractControllerResourceProvider.init(factory);
 
-    replay(managementController, factory, maintenanceStateHelper);
+    replay(managementController, factory, maintenanceStateHelper, repositoryVersionDAO);
 
     AbstractResourceProvider provider =
         (AbstractResourceProvider) AbstractControllerResourceProvider.getResourceProvider(
             Resource.Type.Service,
-            propertyIds,
-            keyPropertyIds,
+            null,
+            null,
             managementController);
 
     Assert.assertTrue(provider instanceof ServiceResourceProvider);
@@ -128,4 +119,4 @@ public class AbstractControllerResourceProviderTest {
 
     assertEquals(ClusterKerberosDescriptorResourceProvider.class, provider.getClass());
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/56362fd6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
index ed16d68..f6177b5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -53,6 +53,7 @@ import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
 import org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
+import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.state.SecurityType;
 import org.easymock.EasyMock;
 import org.easymock.IArgumentMatcher;
@@ -66,7 +67,7 @@ public class AbstractResourceProviderTest {
 
   @Test
   public void testCheckPropertyIds() {
-    Set<String> propertyIds = new HashSet<String>();
+    Set<String> propertyIds = new HashSet<>();
     propertyIds.add("foo");
     propertyIds.add("cat1/foo");
     propertyIds.add("cat2/bar");
@@ -75,15 +76,12 @@ public class AbstractResourceProviderTest {
     propertyIds.add("cat4/sub2/sub3/bat");
     propertyIds.add("cat5/subcat5/map");
 
-    Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
+    Map<Resource.Type, String> keyPropertyIds = new HashMap<>();
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
-    MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);
-    replay(maintenanceStateHelper);
-    AbstractResourceProvider provider = new ServiceResourceProvider(
-            propertyIds,
-            keyPropertyIds,
-            managementController, maintenanceStateHelper);
+
+    AbstractResourceProvider provider = new HostComponentProcessResourceProvider(propertyIds,
+        keyPropertyIds, managementController);
 
     Set<String> unsupported = provider.checkPropertyIds(Collections.singleton("foo"));
     Assert.assertTrue(unsupported.isEmpty());
@@ -105,7 +103,7 @@ public class AbstractResourceProviderTest {
 
   @Test
   public void testGetPropertyIds() {
-    Set<String> propertyIds = new HashSet<String>();
+    Set<String> propertyIds = new HashSet<>();
     propertyIds.add("p1");
     propertyIds.add("foo");
     propertyIds.add("cat1/foo");
@@ -114,16 +112,13 @@ public class AbstractResourceProviderTest {
     propertyIds.add("cat3/sub1/bam");
     propertyIds.add("cat4/sub2/sub3/bat");
 
-    Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
-
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);
-    replay(maintenanceStateHelper);
+    RepositoryVersionDAO repositoryVersionDAO = createNiceMock(RepositoryVersionDAO.class);
+    replay(maintenanceStateHelper, repositoryVersionDAO);
 
-    AbstractResourceProvider provider = new ServiceResourceProvider(
-            propertyIds,
-            keyPropertyIds,
-            managementController, maintenanceStateHelper);
+    AbstractResourceProvider provider = new HostComponentProcessResourceProvider(propertyIds,
+        keyPropertyIds, managementController);
 
     Set<String> supportedPropertyIds = provider.getPropertyIds();
     Assert.assertTrue(supportedPropertyIds.containsAll(propertyIds));
@@ -131,16 +126,13 @@ public class AbstractResourceProviderTest {
 
   @Test
   public void testGetRequestStatus() {
-    Set<String> propertyIds = new HashSet<String>();
-    Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);
-    replay(maintenanceStateHelper);
+    RepositoryVersionDAO repositoryVersionDAO = createNiceMock(RepositoryVersionDAO.class);
+    replay(maintenanceStateHelper, repositoryVersionDAO);
 
-    AbstractResourceProvider provider = new ServiceResourceProvider(
-            propertyIds,
-            keyPropertyIds,
-            managementController, maintenanceStateHelper);
+    AbstractResourceProvider provider = new ServiceResourceProvider(managementController,
+        maintenanceStateHelper, repositoryVersionDAO);
 
     RequestStatus status = provider.getRequestStatus(null);
 
@@ -177,7 +169,7 @@ public class AbstractResourceProviderTest {
   public void testGetPropertyMaps() throws Exception {
     AbstractResourceProvider provider = new TestResourceProvider();
 
-    Map<String, Object> updatePropertyMap = new HashMap<String, Object>();
+    Map<String, Object> updatePropertyMap = new HashMap<>();
     updatePropertyMap.put("SomeProperty", "SomeUpdateValue");
     updatePropertyMap.put("SomeOtherProperty", 99);
 
@@ -358,7 +350,7 @@ public class AbstractResourceProviderTest {
       EasyMock.reportMatcher(new StackConfigurationRequestSetMatcher(stackName, stackVersion, serviceName, propertyName));
       return null;
     }
-    
+
     public static Set<StackConfigurationDependencyRequest> getStackConfigurationDependencyRequestSet(String stackName, String stackVersion,
         String serviceName, String propertyName, String dependencyName)
     {
@@ -468,7 +460,7 @@ public class AbstractResourceProviderTest {
     private final HostRequest hostRequest;
 
     public HostRequestSetMatcher(String hostname, String clusterName, Map<String, String> hostAttributes) {
-      hostRequest = new HostRequest(hostname, clusterName, hostAttributes);
+      hostRequest = new HostRequest(hostname, clusterName);
       add(hostRequest);
     }
 
@@ -488,8 +480,7 @@ public class AbstractResourceProviderTest {
 
       return request instanceof HostRequest &&
           eq(((HostRequest) request).getClusterName(), hostRequest.getClusterName()) &&
-          eq(((HostRequest) request).getHostname(), hostRequest.getHostname()) &&
-          eq(((HostRequest) request).getHostAttributes(), hostRequest.getHostAttributes());
+          eq(((HostRequest) request).getHostname(), hostRequest.getHostname());
     }
 
     @Override
@@ -797,26 +788,26 @@ public class AbstractResourceProviderTest {
   private static Resource.Type testResourceType = new Resource.Type("testResource");
 
   private static Set<String> pkPropertyIds =
-      new HashSet<String>(Arrays.asList(new String[]{
-          "ClusterName",
-          "ResourceName"}));
+    new HashSet<>(Arrays.asList(new String[]{
+      "ClusterName",
+      "ResourceName"}));
 
   private static Set<String> propertyIds =
-      new HashSet<String>(Arrays.asList(new String[]{
-          "ClusterName",
-          "ResourceName",
-          "SomeProperty",
-          "SomeOtherProperty"}));
+    new HashSet<>(Arrays.asList(new String[]{
+      "ClusterName",
+      "ResourceName",
+      "SomeProperty",
+      "SomeOtherProperty"}));
 
   private static Map<Resource.Type, String> keyPropertyIds =
-      new HashMap<Resource.Type, String>();
+    new HashMap<>();
 
   static {
     keyPropertyIds.put(Resource.Type.Cluster, "ClusterName");
     keyPropertyIds.put(testResourceType, "ResourceName" );
   }
 
-  private static Set<Resource> allResources = new HashSet<Resource>();
+  private static Set<Resource> allResources = new HashSet<>();
 
   static {
     Resource resource = new ResourceImpl(testResourceType);
@@ -870,7 +861,7 @@ public class AbstractResourceProviderTest {
     public Set<Resource> getResources(Request request, Predicate predicate)
         throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
 
-      Set<Resource> resources = new HashSet<Resource>();
+      Set<Resource> resources = new HashSet<>();
 
       for(Resource resource : allResources) {
         if (predicate.evaluate(resource)) {
@@ -892,4 +883,4 @@ public class AbstractResourceProviderTest {
       return new RequestStatusImpl(null);
     }
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/56362fd6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
index 54d8168..9de5795 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
@@ -250,8 +250,10 @@ public class ClientConfigResourceProviderTest {
     HashMap<String, ServiceOsSpecific> serviceOsSpecificHashMap = new HashMap<String, ServiceOsSpecific>();
     serviceOsSpecificHashMap.put("key",serviceOsSpecific);
 
-    ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse(clusterName, serviceName, componentName, displayName, hostName, publicHostname,desiredState, "", null, null, null);
-
+    ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse(clusterName, serviceName,
+        componentName, displayName, hostName, publicHostname, desiredState, "", null, null, null,
+        null);
+    
     Set<ServiceComponentHostResponse> responses = new LinkedHashSet<ServiceComponentHostResponse>();
     responses.add(shr1);
 
@@ -500,8 +502,10 @@ public class ClientConfigResourceProviderTest {
     HashMap<String, ServiceOsSpecific> serviceOsSpecificHashMap = new HashMap<String, ServiceOsSpecific>();
     serviceOsSpecificHashMap.put("key",serviceOsSpecific);
 
-    ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse(clusterName, serviceName, componentName, displayName, hostName, publicHostName, desiredState, "", null, null, null);
-
+    ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse(clusterName, serviceName,
+        componentName, displayName, hostName, publicHostName, desiredState, "", null, null, null,
+        null);
+    
     Set<ServiceComponentHostResponse> responses = new LinkedHashSet<ServiceComponentHostResponse>();
     responses.add(shr1);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/56362fd6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
index bf1efb7..4d5bd64 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CompatibleRepositoryVersionResourceProviderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -49,7 +49,6 @@ import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
-import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.orm.entities.StackEntity;
@@ -84,7 +83,6 @@ public class CompatibleRepositoryVersionResourceProviderTest {
   @Before
   public void before() throws Exception {
     final AmbariMetaInfo ambariMetaInfo = EasyMock.createMock(AmbariMetaInfo.class);
-    final ClusterVersionDAO clusterVersionDAO = EasyMock.createMock(ClusterVersionDAO.class);
 
     StackEntity hdp11Stack = new StackEntity();
     hdp11Stack.setStackName("HDP");
@@ -117,7 +115,7 @@ public class CompatibleRepositoryVersionResourceProviderTest {
     final StackInfo stack1 = new StackInfo() {
       @Override
       public Map<String, UpgradePack> getUpgradePacks() {
-        Map<String, UpgradePack> map = new HashMap<String, UpgradePack>();
+        Map<String, UpgradePack> map = new HashMap<>();
 
         UpgradePack pack1 = new UpgradePack() {
 
@@ -191,7 +189,7 @@ public class CompatibleRepositoryVersionResourceProviderTest {
     final StackInfo stack2 = new StackInfo() {
       @Override
       public Map<String, UpgradePack> getUpgradePacks() {
-        Map<String, UpgradePack> map = new HashMap<String, UpgradePack>();
+        Map<String, UpgradePack> map = new HashMap<>();
 
         UpgradePack pack = new UpgradePack() {
           @Override
@@ -221,7 +219,6 @@ public class CompatibleRepositoryVersionResourceProviderTest {
       protected void configure() {
         super.configure();
         bind(AmbariMetaInfo.class).toInstance(ambariMetaInfo);
-        bind(ClusterVersionDAO.class).toInstance(clusterVersionDAO);
         bind(RepositoryVersionDAO.class).toInstance(repoVersionDAO);
         requestStaticInjection(CompatibleRepositoryVersionResourceProvider.class);
       }
@@ -421,4 +418,4 @@ public class CompatibleRepositoryVersionResourceProviderTest {
 
   }
 
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/56362fd6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
index 9f97e55..827e427 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -18,8 +18,31 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import com.google.gson.Gson;
-import com.google.inject.Injector;
+import static org.easymock.EasyMock.anyBoolean;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ObjectNotFoundException;
 import org.apache.ambari.server.ServiceComponentNotFoundException;
@@ -45,13 +68,13 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentFactory;
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.State;
-import org.apache.log4j.Logger;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.junit.Assert;
@@ -60,37 +83,13 @@ import org.junit.Test;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.easymock.EasyMock.anyBoolean;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import com.google.gson.Gson;
+import com.google.inject.Injector;
 
 /**
  * Tests for the component resource provider.
  */
 public class ComponentResourceProviderTest {
-  private static final Logger LOG = Logger.getLogger(ComponentResourceProviderTest.class);
-
   private static final long CLUSTER_ID = 100;
   private static final String CLUSTER_NAME = "Cluster100";
   private static final String SERVICE_NAME = "Service100";
@@ -139,7 +138,7 @@ public class ComponentResourceProviderTest {
     expect(cluster.getService("Service100")).andReturn(service).anyTimes();
     expect(cluster.getClusterId()).andReturn(2L).anyTimes();
 
-    expect(service.getDesiredStackVersion()).andReturn(stackId).anyTimes();
+    expect(service.getDesiredStackId()).andReturn(stackId).anyTimes();
     expect(service.getName()).andReturn("Service100").anyTimes();
 
     expect(stackId.getStackName()).andReturn("HDP").anyTimes();
@@ -159,15 +158,14 @@ public class ComponentResourceProviderTest {
 
     SecurityContextHolder.getContext().setAuthentication(authentication);
 
-    ResourceProvider provider = new ComponentResourceProvider(PropertyHelper.getPropertyIds(type),
-        PropertyHelper.getKeyPropertyIds(type),
-        managementController, maintenanceStateHelper);
+    ResourceProvider provider = new ComponentResourceProvider(managementController,
+        maintenanceStateHelper);
 
     // add the property map to a set for the request.  add more maps for multiple creates
-    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+    Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
 
     // Service 1: create a map of properties for the request
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties = new LinkedHashMap<>();
 
     // add properties to the request map
     properties.put(ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -213,10 +211,10 @@ public class ComponentResourceProviderTest {
     ServiceComponent serviceComponent1 = createNiceMock(ServiceComponent.class);
     ServiceComponent serviceComponent2 = createNiceMock(ServiceComponent.class);
     ServiceComponent serviceComponent3 = createNiceMock(ServiceComponent.class);
-    StackId stackId = createNiceMock(StackId.class);
+    StackId stackId = new StackId("FOO-1.0");
     final ComponentInfo componentInfo1 = createNiceMock(ComponentInfo.class);
     final ComponentInfo componentInfo2 = createNiceMock(ComponentInfo.class);
-    Map <String, Integer> serviceComponentStateCountMap = new HashMap <String, Integer>();
+    Map <String, Integer> serviceComponentStateCountMap = new HashMap<>();
     serviceComponentStateCountMap.put("startedCount", 1);
     serviceComponentStateCountMap.put("installedCount", 0);
     serviceComponentStateCountMap.put("installFailedCount", 0);
@@ -224,7 +222,7 @@ public class ComponentResourceProviderTest {
     serviceComponentStateCountMap.put("unknownCount", 1);
     serviceComponentStateCountMap.put("totalCount", 2);
 
-    Map<String, ServiceComponent> serviceComponentMap = new HashMap<String, ServiceComponent>();
+    Map<String, ServiceComponent> serviceComponentMap = new HashMap<>();
     serviceComponentMap.put("Component101", serviceComponent1);
     serviceComponentMap.put("Component102", serviceComponent2);
     serviceComponentMap.put("Component103", serviceComponent3);
@@ -233,45 +231,48 @@ public class ComponentResourceProviderTest {
     expect(managementController.getClusters()).andReturn(clusters);
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo);
     expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
-    expect(cluster.getDesiredStackVersion()).andReturn(stackId);
     expect(serviceComponent1.getName()).andReturn("Component100");
+    expect(serviceComponent1.getDesiredStackId()).andReturn(stackId).anyTimes();
     expect(serviceComponent2.getName()).andReturn("Component101");
+    expect(serviceComponent2.getDesiredStackId()).andReturn(stackId).anyTimes();
     expect(serviceComponent3.getName()).andReturn("Component102");
+    expect(serviceComponent3.getDesiredStackId()).andReturn(stackId).anyTimes();
 
     expect(cluster.getServices()).andReturn(Collections.singletonMap("Service100", service)).anyTimes();
 
     expect(service.getServiceComponents()).andReturn(serviceComponentMap).anyTimes();
 
     expect(serviceComponent1.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component100", null, "", serviceComponentStateCountMap,
-              true /* recovery enabled */, "Component100 Client"));
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component100", stackId, "", serviceComponentStateCountMap,
+              true /* recovery enabled */, "Component100 Client", null, null));
     expect(serviceComponent2.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, "", serviceComponentStateCountMap,
-              false /* recovery not enabled */, "Component101 Client"));
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", stackId, "", serviceComponentStateCountMap,
+              false /* recovery not enabled */, "Component101 Client", null, null));
     expect(serviceComponent3.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, "", serviceComponentStateCountMap,
-              true /* recovery enabled */, "Component102 Client"));
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", stackId, "", serviceComponentStateCountMap,
+              true /* recovery enabled */, "Component102 Client", "1.1", RepositoryVersionState.CURRENT));
 
-    expect(ambariMetaInfo.getComponent(null, null, null, "Component100")).andReturn(componentInfo1);
-    expect(ambariMetaInfo.getComponent(null, null, null, "Component101")).andReturn(componentInfo2);
-    expect(ambariMetaInfo.getComponent(null, null, null, "Component102")).andReturn(componentInfo1);
+    expect(ambariMetaInfo.getComponent("FOO", "1.0", null, "Component100")).andReturn(
+        componentInfo1);
+    expect(ambariMetaInfo.getComponent("FOO", "1.0", null, "Component101")).andReturn(
+        componentInfo2);
+    expect(ambariMetaInfo.getComponent("FOO", "1.0", null, "Component102")).andReturn(
+        componentInfo1);
 
     expect(componentInfo1.getCategory()).andReturn("MASTER").anyTimes();
     expect(componentInfo2.getCategory()).andReturn("SLAVE").anyTimes();
 
     // replay
     replay(managementController, clusters, cluster, ambariMetaInfo, service,
-      serviceComponent1, serviceComponent2, serviceComponent3, stackId,
+        serviceComponent1, serviceComponent2, serviceComponent3,
       componentInfo1, componentInfo2);
 
     SecurityContextHolder.getContext().setAuthentication(authentication);
 
-    ResourceProvider provider = new ComponentResourceProvider(
-        PropertyHelper.getPropertyIds(type),
-        PropertyHelper.getKeyPropertyIds(type),
-        managementController, maintenanceStateHelper);
+    ResourceProvider provider = new ComponentResourceProvider(managementController,
+        maintenanceStateHelper);
 
-    Set<String> propertyIds = new HashSet<String>();
+    Set<String> propertyIds = new HashSet<>();
 
     propertyIds.add(ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID);
     propertyIds.add(ComponentResourceProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID);
@@ -283,6 +284,8 @@ public class ComponentResourceProviderTest {
     propertyIds.add(ComponentResourceProvider.COMPONENT_INIT_COUNT_PROPERTY_ID);
     propertyIds.add(ComponentResourceProvider.COMPONENT_UNKNOWN_COUNT_PROPERTY_ID);
     propertyIds.add(ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID);
+    propertyIds.add(ComponentResourceProvider.COMPONENT_DESIRED_VERSION);
+    propertyIds.add(ComponentResourceProvider.COMPONENT_REPOSITORY_STATE);
 
     Predicate predicate = new PredicateBuilder()
       .property(ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID)
@@ -315,12 +318,22 @@ public class ComponentResourceProviderTest {
           ComponentResourceProvider.COMPONENT_UNKNOWN_COUNT_PROPERTY_ID));
       Assert.assertEquals(String.valueOf(true), resource.getPropertyValue(
         ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID));
+
+      if (resource.getPropertyValue(
+          ComponentResourceProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID).equals("Component102")) {
+        Assert.assertNotNull(resource.getPropertyValue(ComponentResourceProvider.COMPONENT_REPOSITORY_STATE));
+        Assert.assertNotNull(resource.getPropertyValue(ComponentResourceProvider.COMPONENT_DESIRED_VERSION));
+        Assert.assertEquals(RepositoryVersionState.CURRENT, resource.getPropertyValue(ComponentResourceProvider.COMPONENT_REPOSITORY_STATE));
+        Assert.assertEquals("1.1", resource.getPropertyValue(ComponentResourceProvider.COMPONENT_DESIRED_VERSION));
+      } else {
+        Assert.assertNull(resource.getPropertyValue(ComponentResourceProvider.COMPONENT_REPOSITORY_STATE));
+        Assert.assertNull(resource.getPropertyValue(ComponentResourceProvider.COMPONENT_DESIRED_VERSION));
+      }
     }
 
     // verify
-    verify(managementController, clusters, cluster, ambariMetaInfo, service,
-      serviceComponent1, serviceComponent2, serviceComponent3, stackId,
-      componentInfo1, componentInfo2);
+    verify(managementController, clusters, cluster, ambariMetaInfo, service, serviceComponent1,
+        serviceComponent2, serviceComponent3, componentInfo1, componentInfo2);
   }
 
   @Test
@@ -356,14 +369,14 @@ public class ComponentResourceProviderTest {
     ServiceComponent serviceComponent3 = createNiceMock(ServiceComponent.class);
     ServiceComponentHost serviceComponentHost = createNiceMock(ServiceComponentHost.class);
     RequestStatusResponse requestStatusResponse = createNiceMock(RequestStatusResponse.class);
-    StackId stackId = createNiceMock(StackId.class);
+    StackId stackId = new StackId("stackName-1");
 
-    Map<String, ServiceComponent> serviceComponentMap = new HashMap<String, ServiceComponent>();
+    Map<String, ServiceComponent> serviceComponentMap = new HashMap<>();
     serviceComponentMap.put("Component101", serviceComponent1);
     serviceComponentMap.put("Component102", serviceComponent2);
     serviceComponentMap.put("Component103", serviceComponent3);
 
-    Map <String, Integer> serviceComponentStateCountMap = new HashMap <String, Integer>();
+    Map <String, Integer> serviceComponentStateCountMap = new HashMap<>();
     serviceComponentStateCountMap.put("startedCount", 0);
     serviceComponentStateCountMap.put("installedCount", 1);
     serviceComponentStateCountMap.put("installFailedCount", 0);
@@ -377,10 +390,7 @@ public class ComponentResourceProviderTest {
     expect(managementController.getEffectiveMaintenanceState(
         capture(EasyMock.<ServiceComponentHost>newCapture()))).andReturn(MaintenanceState.OFF).anyTimes();
 
-    expect(stackId.getStackName()).andReturn("stackName").anyTimes();
-    expect(stackId.getStackVersion()).andReturn("1").anyTimes();
     expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
-    expect(cluster.getDesiredStackVersion()).andReturn(stackId);
 
     expect(cluster.getService("Service100")).andReturn(service).anyTimes();
     expect(service.getName()).andReturn("Service100").anyTimes();
@@ -389,8 +399,11 @@ public class ComponentResourceProviderTest {
     expect(service.getServiceComponent("Component103")).andReturn(serviceComponent2).anyTimes();
 
     expect(serviceComponent1.getName()).andReturn("Component101").anyTimes();
+    expect(serviceComponent1.getDesiredStackId()).andReturn(stackId).anyTimes();
     expect(serviceComponent2.getName()).andReturn("Component102").anyTimes();
+    expect(serviceComponent2.getDesiredStackId()).andReturn(stackId).anyTimes();
     expect(serviceComponent3.getName()).andReturn("Component103").anyTimes();
+    expect(serviceComponent3.getDesiredStackId()).andReturn(stackId).anyTimes();
 
     expect(cluster.getServices()).andReturn(Collections.singletonMap("Service100", service)).anyTimes();
     expect(cluster.getClusterId()).andReturn(2L).anyTimes();
@@ -405,14 +418,14 @@ public class ComponentResourceProviderTest {
     expect(component3Info.getCategory()).andReturn(null);
 
     expect(serviceComponent1.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, "", serviceComponentStateCountMap,
-              false /* recovery not enabled */, "Component101 Client"));
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", stackId, "", serviceComponentStateCountMap,
+              false /* recovery not enabled */, "Component101 Client", null, null));
     expect(serviceComponent2.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, "", serviceComponentStateCountMap,
-              false /* recovery not enabled */, "Component102 Client"));
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", stackId, "", serviceComponentStateCountMap,
+              false /* recovery not enabled */, "Component102 Client", null, null));
     expect(serviceComponent3.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component103", null, "", serviceComponentStateCountMap,
-              false /* recovery not enabled */, "Component103 Client"));
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component103", stackId, "", serviceComponentStateCountMap,
+              false /* recovery not enabled */, "Component103 Client", null, null));
     expect(serviceComponent1.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
     expect(serviceComponent2.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
     expect(serviceComponent3.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
@@ -438,23 +451,21 @@ public class ComponentResourceProviderTest {
     expect(managementController.createAndPersistStages(capture(clusterCapture), capture(requestPropertiesCapture), capture(requestParametersCapture), capture(changedServicesCapture), capture(changedCompsCapture), capture(changedScHostsCapture), capture(ignoredScHostsCapture), anyBoolean(), anyBoolean()
     )).andReturn(requestStatusResponse);
 
-    Map<String, String> mapRequestProps = new HashMap<String, String>();
+    Map<String, String> mapRequestProps = new HashMap<>();
     mapRequestProps.put("context", "Called from a test");
 
 
     // replay
     replay(managementController, clusters, cluster, ambariMetaInfo, service, component1Info,
         component2Info, component3Info, serviceComponent1, serviceComponent2, serviceComponent3,
-        serviceComponentHost, requestStatusResponse, stackId, maintenanceStateHelper);
+        serviceComponentHost, requestStatusResponse, maintenanceStateHelper);
 
     SecurityContextHolder.getContext().setAuthentication(authentication);
 
-    ResourceProvider provider = new ComponentResourceProvider(
-        PropertyHelper.getPropertyIds(type),
-        PropertyHelper.getKeyPropertyIds(type),
-        managementController, maintenanceStateHelper);
+    ResourceProvider provider = new ComponentResourceProvider(managementController,
+        maintenanceStateHelper);
 
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties = new LinkedHashMap<>();
 
     properties.put(ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID, String.valueOf(true) /* recovery enabled */);
     properties.put(ComponentResourceProvider.COMPONENT_STATE_PROPERTY_ID, "STARTED");
@@ -471,7 +482,7 @@ public class ComponentResourceProviderTest {
     // verify
     verify(managementController, clusters, cluster, ambariMetaInfo, service, component1Info,
         component2Info, component3Info, serviceComponent1, serviceComponent2, serviceComponent3,
-        serviceComponentHost, requestStatusResponse, stackId, maintenanceStateHelper);
+        serviceComponentHost, requestStatusResponse, maintenanceStateHelper);
   }
 
   @Test
@@ -536,10 +547,8 @@ public class ComponentResourceProviderTest {
 
     SecurityContextHolder.getContext().setAuthentication(authentication);
 
-    ResourceProvider provider = new ComponentResourceProvider(
-                PropertyHelper.getPropertyIds(type),
-                PropertyHelper.getKeyPropertyIds(type),
-                managementController, maintenanceStateHelper);
+    ResourceProvider provider = new ComponentResourceProvider(managementController,
+        maintenanceStateHelper);
 
     AbstractResourceProviderTest.TestObserver observer = new AbstractResourceProviderTest.TestObserver();
 
@@ -593,10 +602,8 @@ public class ComponentResourceProviderTest {
 
     SecurityContextHolder.getContext().setAuthentication(authentication);
 
-    ResourceProvider provider = new ComponentResourceProvider(
-                PropertyHelper.getPropertyIds(type),
-                PropertyHelper.getKeyPropertyIds(type),
-                managementController,maintenanceStateHelper);
+    ResourceProvider provider = new ComponentResourceProvider(managementController,
+        maintenanceStateHelper);
 
     AbstractResourceProviderTest.TestObserver observer = new AbstractResourceProviderTest.TestObserver();
 
@@ -676,12 +683,12 @@ public class ComponentResourceProviderTest {
     ServiceComponent serviceComponent1 = createMock(ServiceComponent.class);
     ServiceComponentHost serviceComponentHost = createMock(ServiceComponentHost.class);
     RequestStatusResponse requestStatusResponse = createNiceMock(RequestStatusResponse.class);
-    StackId stackId = createMock(StackId.class);
+    StackId stackId = new StackId("stackName-1");
 
-    Map<String, ServiceComponent> serviceComponentMap = new HashMap<String, ServiceComponent>();
+    Map<String, ServiceComponent> serviceComponentMap = new HashMap<>();
     serviceComponentMap.put("Component101", serviceComponent1);
 
-    Map <String, Integer> serviceComponentStateCountMap = new HashMap <String, Integer>();
+    Map <String, Integer> serviceComponentStateCountMap = new HashMap<>();
     serviceComponentStateCountMap.put("startedCount", 0);
     serviceComponentStateCountMap.put("installedCount", 1);
     serviceComponentStateCountMap.put("installFailedCount", 0);
@@ -696,12 +703,8 @@ public class ComponentResourceProviderTest {
     expect(managementController.getEffectiveMaintenanceState(
         capture(EasyMock.<ServiceComponentHost>newCapture()))).andReturn(MaintenanceState.OFF).anyTimes();
 
-    expect(stackId.getStackName()).andReturn("stackName").anyTimes();
-    expect(stackId.getStackVersion()).andReturn("1").anyTimes();
-
     expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
 
-    expect(cluster.getDesiredStackVersion()).andReturn(stackId);
     expect(cluster.getResourceId()).andReturn(4l).atLeastOnce();
     expect(cluster.getServices()).andReturn(Collections.singletonMap("Service100", service)).anyTimes();
     expect(cluster.getClusterId()).andReturn(2L).anyTimes();
@@ -712,6 +715,7 @@ public class ComponentResourceProviderTest {
 
     expect(serviceComponent1.getName()).andReturn("Component101").atLeastOnce();
     expect(serviceComponent1.isRecoveryEnabled()).andReturn(false).atLeastOnce();
+    expect(serviceComponent1.getDesiredStackId()).andReturn(stackId).anyTimes();
     serviceComponent1.setRecoveryEnabled(true);
     expectLastCall().once();
 
@@ -721,8 +725,8 @@ public class ComponentResourceProviderTest {
     expect(component1Info.getCategory()).andReturn(null);
 
     expect(serviceComponent1.convertToResponse()).andReturn(
-        new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, "", serviceComponentStateCountMap,
-            false /* recovery not enabled */, "Component101 Client"));
+        new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", stackId, "", serviceComponentStateCountMap,
+            false /* recovery not enabled */, "Component101 Client", null, null));
     expect(serviceComponent1.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
 
     expect(serviceComponentHost.getState()).andReturn(State.INSTALLED).anyTimes();
@@ -744,21 +748,19 @@ public class ComponentResourceProviderTest {
     expect(managementController.createAndPersistStages(capture(clusterCapture), capture(requestPropertiesCapture), capture(requestParametersCapture), capture(changedServicesCapture), capture(changedCompsCapture), capture(changedScHostsCapture), capture(ignoredScHostsCapture), anyBoolean(), anyBoolean()
     )).andReturn(requestStatusResponse);
 
-    Map<String, String> mapRequestProps = new HashMap<String, String>();
+    Map<String, String> mapRequestProps = new HashMap<>();
     mapRequestProps.put("context", "Called from a test");
 
     // replay
     replay(managementController, clusters, cluster, ambariMetaInfo, service, component1Info,
-        serviceComponent1, serviceComponentHost, requestStatusResponse, stackId, maintenanceStateHelper);
+        serviceComponent1, serviceComponentHost, requestStatusResponse, maintenanceStateHelper);
 
     SecurityContextHolder.getContext().setAuthentication(authentication);
 
-    ResourceProvider provider = new ComponentResourceProvider(
-        PropertyHelper.getPropertyIds(type),
-        PropertyHelper.getKeyPropertyIds(type),
-        managementController, maintenanceStateHelper);
+    ResourceProvider provider = new ComponentResourceProvider(managementController,
+        maintenanceStateHelper);
 
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties = new LinkedHashMap<>();
 
     properties.put(ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID, String.valueOf(true) /* recovery enabled */);
 
@@ -772,7 +774,7 @@ public class ComponentResourceProviderTest {
 
     // verify
     verify(managementController, clusters, cluster, ambariMetaInfo, service, component1Info,
-        serviceComponent1, serviceComponentHost, requestStatusResponse, stackId, maintenanceStateHelper);
+        serviceComponent1, serviceComponentHost, requestStatusResponse, maintenanceStateHelper);
   }
 
   @Test
@@ -793,7 +795,7 @@ public class ComponentResourceProviderTest {
     ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
         null, String.valueOf(true /* recovery enabled */));
 
-    Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
+    Set<ServiceComponentRequest> setRequests = new HashSet<>();
     setRequests.add(request1);
 
     // expectations
@@ -807,13 +809,13 @@ public class ComponentResourceProviderTest {
     // getComponents
     expect(clusters.getCluster("cluster1")).andReturn(cluster);
     expect(cluster.getService("service1")).andReturn(service);
-    expect(cluster.getDesiredStackVersion()).andReturn(stackId).anyTimes();
     expect(service.getName()).andReturn("service1").anyTimes();
     expect(service.getServiceComponent("component1")).andReturn(component);
 
     expect(ambariMetaInfo.getComponent("stackName", "1", "service1", "component1")).andReturn(componentInfo);
     expect(componentInfo.getCategory()).andReturn(null);
 
+    expect(component.getDesiredStackId()).andReturn(stackId).anyTimes();
     expect(component.convertToResponse()).andReturn(response);
     // replay mocks
     replay(clusters, cluster, service, componentInfo, component, response, ambariMetaInfo, stackId, managementController);
@@ -861,7 +863,7 @@ public class ComponentResourceProviderTest {
     ServiceComponentRequest request5 = new ServiceComponentRequest("cluster1", "service2", null, null,
               String.valueOf(true /* recovery enabled */));
 
-    Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
+    Set<ServiceComponentRequest> setRequests = new HashSet<>();
     setRequests.add(request1);
     setRequests.add(request2);
     setRequests.add(request3);
@@ -895,7 +897,9 @@ public class ComponentResourceProviderTest {
     expect(service.getServiceComponent("component4")).andReturn(component2);
 
     expect(component1.convertToResponse()).andReturn(response1);
+    expect(component1.getDesiredStackId()).andReturn(stackId).anyTimes();
     expect(component2.convertToResponse()).andReturn(response2);
+    expect(component2.getDesiredStackId()).andReturn(stackId).anyTimes();
     // replay mocks
     replay(clusters, cluster, service, component3Info, component4Info, component1,  component2, response1,
         response2, ambariMetaInfo, stackId, managementController);
@@ -922,10 +926,7 @@ public class ComponentResourceProviderTest {
             anyObject(ServiceComponentHost.class))).andReturn(true).anyTimes();
     replay(maintenanceStateHelper);
 
-    return new ComponentResourceProvider(
-        PropertyHelper.getPropertyIds(type),
-        PropertyHelper.getKeyPropertyIds(type),
-        managementController, maintenanceStateHelper);
+    return new ComponentResourceProvider(managementController, maintenanceStateHelper);
   }
 
   /**
@@ -945,7 +946,7 @@ public class ComponentResourceProviderTest {
     ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
         null, String.valueOf(true /* recovery enabled */));
 
-    Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
+    Set<ServiceComponentRequest> setRequests = new HashSet<>();
     setRequests.add(request1);
 
     // expectations
@@ -997,4 +998,4 @@ public class ComponentResourceProviderTest {
     ComponentResourceProvider provider = getComponentResourceProvider(controller);
     return provider.updateComponents(requests, requestProperties, runSmokeTest);
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/56362fd6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
index ec9da09..6a25d91 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -134,10 +134,10 @@ public class HostComponentResourceProviderTest {
         managementController);
 
     // add the property map to a set for the request.  add more maps for multiple creates
-    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
+    Set<Map<String, Object>> propertySet = new LinkedHashSet<>();
 
     // Service 1: create a map of properties for the request
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties = new LinkedHashMap<>();
 
     // add properties to the request map
     properties.put(HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -180,26 +180,36 @@ public class HostComponentResourceProviderTest {
 
     AbstractControllerResourceProvider.init(resourceProviderFactory);
 
-    Set<ServiceComponentHostResponse> allResponse = new HashSet<ServiceComponentHostResponse>();
+    Set<ServiceComponentHostResponse> allResponse = new HashSet<>();
     StackId stackId = new StackId("HDP-0.1");
     StackId stackId2 = new StackId("HDP-0.2");
+
+    String repositoryVersion2 = "0.2-1234";
+
     allResponse.add(new ServiceComponentHostResponse(
-        "Cluster100", "Service100", "Component100", "Component 100", "Host100", "Host100", State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
-        stackId2.getStackId(), null));
+        "Cluster100", "Service100", "Component100", "Component 100", "Host100", "Host100",
+        State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
+        stackId2.getStackId(), repositoryVersion2, null));
+
     allResponse.add(new ServiceComponentHostResponse(
-        "Cluster100", "Service100", "Component101", "Component 101", "Host100", "Host100", State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
-        stackId2.getStackId(), null));
+        "Cluster100", "Service100", "Component101", "Component 101", "Host100", "Host100",
+        State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
+        stackId2.getStackId(), repositoryVersion2, null));
 
     allResponse.add(new ServiceComponentHostResponse(
-        "Cluster100", "Service100", "Component102", "Component 102", "Host100","Host100", State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
-        stackId2.getStackId(), null));
-    Map<String, String> expectedNameValues = new HashMap<String, String>();
+        "Cluster100", "Service100", "Component102", "Component 102", "Host100", "Host100",
+        State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
+        stackId2.getStackId(), repositoryVersion2, null));
+
+    Map<String, String> expectedNameValues = new HashMap<>();
     expectedNameValues.put(
         HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
     expectedNameValues.put(
         HostComponentResourceProvider.HOST_COMPONENT_STATE_PROPERTY_ID, State.INSTALLED.toString());
     expectedNameValues.put(
-        HostComponentResourceProvider.HOST_COMPONENT_STACK_ID_PROPERTY_ID, stackId.getStackId());
+        HostComponentResourceProvider.HOST_COMPONENT_VERSION_PROPERTY_ID, repositoryVersion2);
+    expectedNameValues.put(
+        HostComponentResourceProvider.HOST_COMPONENT_DESIRED_REPOSITORY_VERSION, repositoryVersion2);
     expectedNameValues.put(
         HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID, State.STARTED.toString());
     expectedNameValues.put(
@@ -214,12 +224,13 @@ public class HostComponentResourceProviderTest {
         eq(managementController))).
         andReturn(hostComponentResourceProvider).anyTimes();
 
-    Set<String> propertyIds = new HashSet<String>();
+    Set<String> propertyIds = new HashSet<>();
 
     propertyIds.add(HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID);
     propertyIds.add(HostComponentResourceProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID);
     propertyIds.add(HostComponentResourceProvider.HOST_COMPONENT_STATE_PROPERTY_ID);
-    propertyIds.add(HostComponentResourceProvider.HOST_COMPONENT_STACK_ID_PROPERTY_ID);
+    propertyIds.add(HostComponentResourceProvider.HOST_COMPONENT_VERSION_PROPERTY_ID);
+    propertyIds.add(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_REPOSITORY_VERSION);
     propertyIds.add(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID);
     propertyIds.add(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STACK_ID_PROPERTY_ID);
 
@@ -227,7 +238,7 @@ public class HostComponentResourceProviderTest {
         HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").toPredicate();
     Request request = PropertyHelper.getReadRequest(propertyIds);
 
-    Set<Resource> hostsComponentResources = new HashSet<Resource>();
+    Set<Resource> hostsComponentResources = new HashSet<>();
 
     Resource hostsComponentResource1 = new ResourceImpl(Resource.Type.HostComponent);
     hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -236,9 +247,11 @@ public class HostComponentResourceProviderTest {
     hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, "Component100");
     hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_STATE_PROPERTY_ID, State.INSTALLED.name());
     hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID, State.STARTED.name());
-    hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_STACK_ID_PROPERTY_ID, stackId.getStackId());
+    hostsComponentResource1.setProperty(
+        HostComponentResourceProvider.HOST_COMPONENT_VERSION_PROPERTY_ID, repositoryVersion2);
     hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STACK_ID_PROPERTY_ID, stackId2.getStackId());
     hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_UPGRADE_STATE_PROPERTY_ID, UpgradeState.NONE.name());
+    hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_REPOSITORY_VERSION, repositoryVersion2);
 
     Resource hostsComponentResource2 = new ResourceImpl(Resource.Type.HostComponent);
     hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -247,9 +260,11 @@ public class HostComponentResourceProviderTest {
     hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, "Component101");
     hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_STATE_PROPERTY_ID, State.INSTALLED.name());
     hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID, State.STARTED.name());
-    hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_STACK_ID_PROPERTY_ID, stackId.getStackId());
+    hostsComponentResource2.setProperty(
+        HostComponentResourceProvider.HOST_COMPONENT_VERSION_PROPERTY_ID, repositoryVersion2);
     hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STACK_ID_PROPERTY_ID, stackId2.getStackId());
     hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_UPGRADE_STATE_PROPERTY_ID, UpgradeState.NONE.name());
+    hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_REPOSITORY_VERSION, repositoryVersion2);
 
     Resource hostsComponentResource3 = new ResourceImpl(Resource.Type.HostComponent);
     hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -258,9 +273,11 @@ public class HostComponentResourceProviderTest {
     hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, "Component102");
     hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_STATE_PROPERTY_ID, State.INSTALLED.name());
     hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID, State.STARTED.name());
-    hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_STACK_ID_PROPERTY_ID, stackId.getStackId());
+    hostsComponentResource3.setProperty(
+        HostComponentResourceProvider.HOST_COMPONENT_VERSION_PROPERTY_ID, repositoryVersion2);
     hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STACK_ID_PROPERTY_ID, stackId2.getStackId());
     hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_UPGRADE_STATE_PROPERTY_ID, UpgradeState.NONE.name());
+    hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_REPOSITORY_VERSION, repositoryVersion2);
 
     hostsComponentResources.add(hostsComponentResource1);
     hostsComponentResources.add(hostsComponentResource2);
@@ -283,7 +300,7 @@ public class HostComponentResourceProviderTest {
     Set<Resource> resources = provider.getResources(request, predicate);
 
     Assert.assertEquals(3, resources.size());
-    Set<String> names = new HashSet<String>();
+    Set<String> names = new HashSet<>();
     for (Resource resource : resources) {
       for (String key : expectedNameValues.keySet()) {
         Assert.assertEquals(expectedNameValues.get(key), resource.getPropertyValue(key));
@@ -332,12 +349,13 @@ public class HostComponentResourceProviderTest {
     MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);
 
 
-    Map<String, String> mapRequestProps = new HashMap<String, String>();
+    Map<String, String> mapRequestProps = new HashMap<>();
     mapRequestProps.put("context", "Called from a test");
 
-    Set<ServiceComponentHostResponse> nameResponse = new HashSet<ServiceComponentHostResponse>();
+    Set<ServiceComponentHostResponse> nameResponse = new HashSet<>();
     nameResponse.add(new ServiceComponentHostResponse(
-        "Cluster102", "Service100", "Component100", "Component 100", "Host100", "Host100","INSTALLED", "", "", "", null));
+        "Cluster102", "Service100", "Component100", "Component 100", "Host100", "Host100",
+        "INSTALLED", "", "", "", "", null));
 
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
@@ -358,8 +376,8 @@ public class HostComponentResourceProviderTest {
     expect(managementController.getHostComponents(
         EasyMock.<Set<ServiceComponentHostRequest>>anyObject())).andReturn(nameResponse).once();
 
-    Map<String, Map<State, List<ServiceComponentHost>>> changedHosts = new HashMap<String, Map<State, List<ServiceComponentHost>>>();
-    List<ServiceComponentHost> changedComponentHosts = new ArrayList<ServiceComponentHost>();
+    Map<String, Map<State, List<ServiceComponentHost>>> changedHosts = new HashMap<>();
+    List<ServiceComponentHost> changedComponentHosts = new ArrayList<>();
     changedComponentHosts.add(componentHost);
     changedHosts.put("Component100", Collections.singletonMap(State.STARTED, changedComponentHosts));
 
@@ -387,7 +405,7 @@ public class HostComponentResourceProviderTest {
 
     SecurityContextHolder.getContext().setAuthentication(authentication);
 
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties = new LinkedHashMap<>();
 
     properties.put(HostComponentResourceProvider.HOST_COMPONENT_STATE_PROPERTY_ID, "STARTED");
 
@@ -471,7 +489,7 @@ public class HostComponentResourceProviderTest {
 
   @Test
   public void testCheckPropertyIds() throws Exception {
-    Set<String> propertyIds = new HashSet<String>();
+    Set<String> propertyIds = new HashSet<>();
     propertyIds.add("foo");
     propertyIds.add("cat1/foo");
     propertyIds.add("cat2/bar");
@@ -480,7 +498,7 @@ public class HostComponentResourceProviderTest {
     propertyIds.add("cat4/sub2/sub3/bat");
     propertyIds.add("cat5/subcat5/map");
 
-    Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
+    Map<Resource.Type, String> keyPropertyIds = new HashMap<>();
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     Injector injector = createNiceMock(Injector.class);
@@ -533,12 +551,13 @@ public class HostComponentResourceProviderTest {
     MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);
 
 
-    Map<String, String> mapRequestProps = new HashMap<String, String>();
+    Map<String, String> mapRequestProps = new HashMap<>();
     mapRequestProps.put("context", "Called from a test");
 
-    Set<ServiceComponentHostResponse> nameResponse = new HashSet<ServiceComponentHostResponse>();
+    Set<ServiceComponentHostResponse> nameResponse = new HashSet<>();
     nameResponse.add(new ServiceComponentHostResponse(
-        "Cluster102", "Service100", "Component100", "Component 100", "Host100", "Host100","INSTALLED", "", "", "", null));
+        "Cluster102", "Service100", "Component100", "Component 100", "Host100", "Host100",
+        "INSTALLED", "", "", "", "", null));
 
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
@@ -557,8 +576,8 @@ public class HostComponentResourceProviderTest {
     expect(managementController.getHostComponents(
         EasyMock.<Set<ServiceComponentHostRequest>>anyObject())).andReturn(Collections.<ServiceComponentHostResponse>emptySet()).once();
 
-    Map<String, Map<State, List<ServiceComponentHost>>> changedHosts = new HashMap<String, Map<State, List<ServiceComponentHost>>>();
-    List<ServiceComponentHost> changedComponentHosts = new ArrayList<ServiceComponentHost>();
+    Map<String, Map<State, List<ServiceComponentHost>>> changedHosts = new HashMap<>();
+    List<ServiceComponentHost> changedComponentHosts = new ArrayList<>();
     changedComponentHosts.add(componentHost);
     changedHosts.put("Component100", Collections.singletonMap(State.STARTED, changedComponentHosts));
 
@@ -580,7 +599,7 @@ public class HostComponentResourceProviderTest {
 
     SecurityContextHolder.getContext().setAuthentication(authentication);
 
-    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+    Map<String, Object> properties = new LinkedHashMap<>();
 
     properties.put(HostComponentResourceProvider.HOST_COMPONENT_STATE_PROPERTY_ID, "STARTED");
 
@@ -650,4 +669,4 @@ public class HostComponentResourceProviderTest {
     }
 
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/56362fd6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
index 4a57092..f133784 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -47,6 +47,9 @@ import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.OrmTestHelper;
+import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.security.TestAuthenticationFactory;
 import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.state.Cluster;
@@ -83,6 +86,11 @@ public class JMXHostProviderTest {
   private static final String MAPREDUCE_HTTPS_POLICY = "mapreduce.jobhistory.http.policy";
   private static final String MAPREDUCE_HTTPS_PORT = "mapreduce.jobhistory.webapp.https.address";
 
+  private final String STACK_VERSION = "2.0.6";
+  private final String REPO_VERSION = "2.0.6-1234";
+  private final StackId STACK_ID = new StackId("HDP", STACK_VERSION);
+  private RepositoryVersionEntity m_repositoryVersion;
+
   @Before
   public void setup() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
@@ -90,6 +98,10 @@ public class JMXHostProviderTest {
     injector.getInstance(GuiceJpaInitializer.class);
     clusters = injector.getInstance(Clusters.class);
     controller = injector.getInstance(AmbariManagementController.class);
+    OrmTestHelper ormTestHelper = injector.getInstance(OrmTestHelper.class);
+
+    m_repositoryVersion = ormTestHelper.getOrCreateRepositoryVersion(STACK_ID, REPO_VERSION);
+    Assert.assertNotNull(m_repositoryVersion);
 
     // Set the authenticated user
     // TODO: remove this or replace the authenticated user to test authorization rules
@@ -104,17 +116,22 @@ public class JMXHostProviderTest {
     SecurityContextHolder.getContext().setAuthentication(null);
   }
 
-  private void createService(String clusterName,
-                             String serviceName, State desiredState)
+  private void createService(String clusterName, String serviceName, State desiredState)
       throws AmbariException, AuthorizationException {
     String dStateStr = null;
+
     if (desiredState != null) {
       dStateStr = desiredState.toString();
     }
-    ServiceRequest r1 = new ServiceRequest(clusterName, serviceName, dStateStr);
-    Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
+
+    ServiceRequest r1 = new ServiceRequest(clusterName, serviceName, STACK_ID.getStackId(),
+        REPO_VERSION, dStateStr);
+
+    Set<ServiceRequest> requests = new HashSet<>();
     requests.add(r1);
-    ServiceResourceProviderTest.createServices(controller, requests);
+
+    ServiceResourceProviderTest.createServices(controller,
+        injector.getInstance(RepositoryVersionDAO.class), requests);
   }
 
   private void createServiceComponent(String clusterName,
@@ -127,7 +144,7 @@ public class JMXHostProviderTest {
     ServiceComponentRequest r = new ServiceComponentRequest(clusterName,
       serviceName, componentName, dStateStr);
     Set<ServiceComponentRequest> requests =
-      new HashSet<ServiceComponentRequest>();
+      new HashSet<>();
     requests.add(r);
     ComponentResourceProviderTest.createComponents(controller, requests);
   }
@@ -142,7 +159,7 @@ public class JMXHostProviderTest {
     ServiceComponentHostRequest r = new ServiceComponentHostRequest(clusterName,
       serviceName, componentName, hostname, dStateStr);
     Set<ServiceComponentHostRequest> requests =
-      new HashSet<ServiceComponentHostRequest>();
+      new HashSet<>();
     requests.add(r);
     controller.createHostComponents(requests);
   }
@@ -168,13 +185,13 @@ public class JMXHostProviderTest {
 
     String host1 = "h1";
     clusters.addHost(host1);
-    Map<String, String> hostAttributes = new HashMap<String, String>();
+    Map<String, String> hostAttributes = new HashMap<>();
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "5.9");
     clusters.getHost("h1").setHostAttributes(hostAttributes);
     String host2 = "h2";
     clusters.addHost(host2);
-    hostAttributes = new HashMap<String, String>();
+    hostAttributes = new HashMap<>();
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6.3");
     clusters.getHost("h2").setHostAttributes(hostAttributes);
@@ -194,7 +211,7 @@ public class JMXHostProviderTest {
 
     // Create configs
     if (version1) {
-      Map<String, String> configs = new HashMap<String, String>();
+      Map<String, String> configs = new HashMap<>();
       configs.put(NAMENODE_PORT_V1, "localhost:${ambari.dfs.datanode.http.port}");
       configs.put(DATANODE_PORT, "localhost:70075");
       configs.put("ambari.dfs.datanode.http.port", "70070");
@@ -206,7 +223,7 @@ public class JMXHostProviderTest {
       controller.updateClusters(Collections.singleton(crequest), new HashMap<String,String>());
 
     } else {
-      Map<String, String> configs = new HashMap<String, String>();
+      Map<String, String> configs = new HashMap<>();
       configs.put(NAMENODE_PORT_V2, "localhost:70071");
       configs.put(DATANODE_PORT, "localhost:70075");
 
@@ -266,13 +283,13 @@ public class JMXHostProviderTest {
 
     String host1 = "h1";
     clusters.addHost(host1);
-    Map<String, String> hostAttributes = new HashMap<String, String>();
+    Map<String, String> hostAttributes = new HashMap<>();
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "5.9");
     clusters.getHost("h1").setHostAttributes(hostAttributes);
     String host2 = "h2";
     clusters.addHost(host2);
-    hostAttributes = new HashMap<String, String>();
+    hostAttributes = new HashMap<>();
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6.3");
     clusters.getHost("h2").setHostAttributes(hostAttributes);
@@ -305,7 +322,7 @@ public class JMXHostProviderTest {
       host2, null);
 
     // Create configs
-    Map<String, String> configs = new HashMap<String, String>();
+    Map<String, String> configs = new HashMap<>();
     configs.put(NAMENODE_PORT_V1, "localhost:${ambari.dfs.datanode.http.port}");
     configs.put(DATANODE_PORT, "localhost:70075");
     configs.put("ambari.dfs.datanode.http.port", "70070");
@@ -313,18 +330,18 @@ public class JMXHostProviderTest {
     configs.put(DATANODE_HTTPS_PORT, "50475");
     configs.put(HDFS_HTTPS_POLICY, "HTTPS_ONLY");
 
-    Map<String, String> yarnConfigs = new HashMap<String, String>();
+    Map<String, String> yarnConfigs = new HashMap<>();
     yarnConfigs.put(RESOURCEMANAGER_PORT, "8088");
     yarnConfigs.put(NODEMANAGER_PORT, "8042");
     yarnConfigs.put(RESOURCEMANAGER_HTTPS_PORT, "8090");
     yarnConfigs.put(NODEMANAGER_HTTPS_PORT, "8044");
     yarnConfigs.put(YARN_HTTPS_POLICY, "HTTPS_ONLY");
 
-    Map<String, String> mapreduceConfigs = new HashMap<String, String>();
+    Map<String, String> mapreduceConfigs = new HashMap<>();
     mapreduceConfigs.put(MAPREDUCE_HTTPS_PORT, "19889");
     mapreduceConfigs.put(MAPREDUCE_HTTPS_POLICY, "HTTPS_ONLY");
 
-    Map<String, String> hbaseConfigs = new HashMap<String, String>();
+    Map<String, String> hbaseConfigs = new HashMap<>();
     hbaseConfigs.put("hbase.ssl.enabled", "true");
 
     ConfigurationRequest cr1 = new ConfigurationRequest(clusterName,
@@ -379,13 +396,13 @@ public class JMXHostProviderTest {
 
     String host1 = "h1";
     clusters.addHost(host1);
-    Map<String, String> hostAttributes = new HashMap<String, String>();
+    Map<String, String> hostAttributes = new HashMap<>();
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "5.9");
     clusters.getHost("h1").setHostAttributes(hostAttributes);
     String host2 = "h2";
     clusters.addHost(host2);
-    hostAttributes = new HashMap<String, String>();
+    hostAttributes = new HashMap<>();
     hostAttributes.put("os_family", "redhat");
     hostAttributes.put("os_release_version", "6.3");
     clusters.getHost("h2").setHostAttributes(hostAttributes);
@@ -406,7 +423,7 @@ public class JMXHostProviderTest {
         host2, null);
 
     // Create configs
-    Map<String, String> configs = new HashMap<String, String>();
+    Map<String, String> configs = new HashMap<>();
     configs.put("dfs.internal.nameservices", "ns");
     configs.put("dfs.namenode.http-address", "h1:50070");
     configs.put("dfs.namenode.http-address.ns.nn1", "h1:50071");
@@ -513,7 +530,7 @@ public class JMXHostProviderTest {
     Service serviceMock = createNiceMock(Service.class);
     ServiceComponent serviceComponentMock = createNiceMock(ServiceComponent.class);
 
-    Map<String, ServiceComponentHost> hostComponents = new HashMap<String, ServiceComponentHost>();
+    Map<String, ServiceComponentHost> hostComponents = new HashMap<>();
     hostComponents.put("host1", null);
 
     expect(managementControllerMock.getClusters()).andReturn(clustersMock).anyTimes();
@@ -612,7 +629,7 @@ public class JMXHostProviderTest {
     // Non default port addresses
     Assert.assertEquals("8088", providerModule.getPort("c1", "RESOURCEMANAGER", "localhost"));
 
-    Map<String, String> yarnConfigs = new HashMap<String, String>();
+    Map<String, String> yarnConfigs = new HashMap<>();
     yarnConfigs.put(RESOURCEMANAGER_PORT, "localhost:50030");
     yarnConfigs.put(NODEMANAGER_PORT, "localhost:11111");
     ConfigurationRequest cr2 = new ConfigurationRequest("c1",
@@ -640,14 +657,15 @@ public class JMXHostProviderTest {
 
     Injector injector = createNiceMock(Injector.class);
     MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);
+    RepositoryVersionDAO repositoryVersionDAO = createNiceMock(RepositoryVersionDAO.class);
+
     {
       expect(injector.getInstance(Clusters.class)).andReturn(null);
       replay(maintenanceStateHelper, injector);
     }
 
-    ResourceProvider serviceResourceProvider = new ServiceResourceProvider(PropertyHelper
-      .getPropertyIds(Resource.Type.Service),
-      PropertyHelper.getKeyPropertyIds(Resource.Type.Service), controller, maintenanceStateHelper);
+    ResourceProvider serviceResourceProvider = new ServiceResourceProvider(controller,
+        maintenanceStateHelper, repositoryVersionDAO);
 
     ResourceProvider hostCompResourceProvider = new
       HostComponentResourceProvider(PropertyHelper.getPropertyIds(Resource
@@ -678,4 +696,4 @@ public class JMXHostProviderTest {
     }
 
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/56362fd6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceComponentResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceComponentResourceProviderTest.java
index 1b742af..99a3374 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceComponentResourceProviderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -18,9 +18,16 @@
 
 package org.apache.ambari.server.controller.internal;
 
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
+
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.RootServiceComponentRequest;
 import org.apache.ambari.server.controller.RootServiceComponentResponse;
@@ -32,10 +39,6 @@ import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.easymock.EasyMock;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -47,14 +50,16 @@ public class RootServiceComponentResourceProviderTest {
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
 
-    Set<RootServiceComponentResponse> allResponse = new HashSet<RootServiceComponentResponse>();
-    allResponse.add(new RootServiceComponentResponse("component1", "1.1.1", Collections.<String,String>emptyMap()));
-    allResponse.add(new RootServiceComponentResponse("component2", "1.1.1", Collections.<String,String>emptyMap()));
-    allResponse.add(new RootServiceComponentResponse("component3", "1.1.1", Collections.<String,String>emptyMap()));
-    allResponse.add(new RootServiceComponentResponse(RootServiceResponseFactory.Components.AMBARI_SERVER.name(), "1.1.1", Collections.<String,String>emptyMap()));
+    Set<RootServiceComponentResponse> allResponse = new HashSet<>();
+    String serviceName = RootServiceResponseFactory.Services.AMBARI.name();
+    Map<String, String> emptyMap = Collections.emptyMap();
+    allResponse.add(new RootServiceComponentResponse(serviceName, "component1", "1.1.1", emptyMap));
+    allResponse.add(new RootServiceComponentResponse(serviceName, "component2", "1.1.1", emptyMap));
+    allResponse.add(new RootServiceComponentResponse(serviceName, "component3", "1.1.1", emptyMap));
+    allResponse.add(new RootServiceComponentResponse(serviceName, RootServiceResponseFactory.Components.AMBARI_SERVER.name(), "1.1.1", emptyMap));
 
-    Set<RootServiceComponentResponse> nameResponse = new HashSet<RootServiceComponentResponse>();
-    nameResponse.add(new RootServiceComponentResponse("component4", "1.1.1", Collections.<String,String>emptyMap()));
+    Set<RootServiceComponentResponse> nameResponse = new HashSet<>();
+    nameResponse.add(new RootServiceComponentResponse(serviceName, "component4", "1.1.1", emptyMap));
 
 
     // set expectations
@@ -69,7 +74,7 @@ public class RootServiceComponentResourceProviderTest {
         PropertyHelper.getKeyPropertyIds(type),
         managementController);
 
-    Set<String> propertyIds = new HashSet<String>();
+    Set<String> propertyIds = new HashSet<>();
 
     propertyIds.add(RootServiceComponentResourceProvider.SERVICE_NAME_PROPERTY_ID);
     propertyIds.add(RootServiceComponentResourceProvider.COMPONENT_NAME_PROPERTY_ID);
@@ -94,7 +99,7 @@ public class RootServiceComponentResourceProviderTest {
         Assert.assertNull(server_clock);
       }
       
-      Assert.assertTrue(allResponse.contains(new RootServiceComponentResponse(componentName, componentVersion, Collections.<String,String>emptyMap())));
+      Assert.assertTrue(allResponse.contains(new RootServiceComponentResponse(serviceName, componentName, componentVersion, emptyMap)));
     }
 
     // get service named service4
@@ -112,4 +117,4 @@ public class RootServiceComponentResourceProviderTest {
     verify(managementController);
   }
 
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/56362fd6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceHostComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceHostComponentResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceHostComponentResourceProviderTest.java
index cb7051c..1ddaa29 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceHostComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceHostComponentResourceProviderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -43,7 +43,7 @@ import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.HostHealthStatus;
+import org.easymock.EasyMock;
 import org.junit.Test;
 
 public class RootServiceHostComponentResourceProviderTest {
@@ -56,7 +56,6 @@ public class RootServiceHostComponentResourceProviderTest {
     Clusters clusters = createNiceMock(Clusters.class);
     Cluster cluster = createNiceMock(Cluster.class);
     Host host1 = createNiceMock(Host.class);
-    HostHealthStatus healthStatus = createNiceMock(HostHealthStatus.class);
 
     HostResponse hostResponse1 = createNiceMock(HostResponse.class);
 
@@ -64,13 +63,13 @@ public class RootServiceHostComponentResourceProviderTest {
 
     AbstractRootServiceResponseFactory factory = createNiceMock(AbstractRootServiceResponseFactory.class);
 
-    List<Host> hosts = new LinkedList<Host>();
+    List<Host> hosts = new LinkedList<>();
     hosts.add(host1);
 
-    Set<Cluster> clusterSet = new HashSet<Cluster>();
+    Set<Cluster> clusterSet = new HashSet<>();
     clusterSet.add(cluster);
 
-    Set<RootServiceHostComponentResponse> responseSet = new HashSet<RootServiceHostComponentResponse>();
+    Set<RootServiceHostComponentResponse> responseSet = new HashSet<>();
     responseSet.add(response);
 
     // set expectations
@@ -78,7 +77,7 @@ public class RootServiceHostComponentResourceProviderTest {
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(clusters.getHosts()).andReturn(hosts).anyTimes();
 
-    expect(factory.getRootServiceHostComponent((RootServiceHostComponentRequest) anyObject(), (Set<HostResponse>) anyObject())).
+    expect(factory.getRootServiceHostComponent((RootServiceHostComponentRequest) anyObject(), EasyMock.<Set<HostResponse>>anyObject())).
         andReturn(responseSet).anyTimes();
 
     expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
@@ -91,16 +90,13 @@ public class RootServiceHostComponentResourceProviderTest {
 
     expect(hostResponse1.getClusterName()).andReturn("Cluster100").anyTimes();
     expect(hostResponse1.getHostname()).andReturn("Host100").anyTimes();
-    expect(hostResponse1.getHealthStatus()).andReturn(healthStatus).anyTimes();
-
-    expect(healthStatus.getHealthStatus()).andReturn(HostHealthStatus.HealthStatus.HEALTHY).anyTimes();
-    expect(healthStatus.getHealthReport()).andReturn("HEALTHY").anyTimes();
+    expect(hostResponse1.getHealthReport()).andReturn("HEALTHY").anyTimes();
 
     // replay
     replay(managementController, clusters, cluster,
         host1,
         hostResponse1,
-        healthStatus, factory, response);
+        factory, response);
 
 
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
@@ -109,7 +105,7 @@ public class RootServiceHostComponentResourceProviderTest {
         PropertyHelper.getKeyPropertyIds(type),
         managementController);
 
-    Set<String> propertyIds = new HashSet<String>();
+    Set<String> propertyIds = new HashSet<>();
 
     propertyIds.add(RootServiceHostComponentResourceProvider.SERVICE_NAME_PROPERTY_ID);
     propertyIds.add(RootServiceHostComponentResourceProvider.HOST_NAME_PROPERTY_ID);
@@ -128,7 +124,7 @@ public class RootServiceHostComponentResourceProviderTest {
     verify(managementController, clusters, cluster,
         host1,
         hostResponse1,
-        healthStatus, factory, response);
+        factory, response);
   }
 
-}
+}
\ No newline at end of file


Mime
View raw message