ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lpus...@apache.org
Subject [1/3] ambari git commit: AMBARI-20755 topology configuration type validation on blueprint deployments
Date Fri, 14 Apr 2017 19:13:38 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 80e3cf0fe -> a9cda4f1f


http://git-wip-us.apache.org/repos/asf/ambari/blob/a9cda4f1/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
index 85826f2..581eea1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequestTest.java
@@ -50,8 +50,6 @@ import org.apache.ambari.server.topology.Configuration;
 import org.apache.ambari.server.topology.HostGroupInfo;
 import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
 import org.apache.ambari.server.topology.TopologyRequest;
-import org.apache.ambari.server.topology.TopologyValidator;
-import org.apache.ambari.server.topology.validators.RequiredPasswordValidator;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -112,7 +110,6 @@ public class ProvisionClusterRequestTest {
     assertSame(blueprint, provisionClusterRequest.getBlueprint());
     Map<String, HostGroupInfo> hostGroupInfo = provisionClusterRequest.getHostGroupInfo();
     assertEquals(1, hostGroupInfo.size());
-    assertEquals(3, provisionClusterRequest.getTopologyValidators().size());
 
     // group1
     // host info
@@ -164,7 +161,6 @@ public class ProvisionClusterRequestTest {
     assertSame(blueprint, provisionClusterRequest.getBlueprint());
     Map<String, HostGroupInfo> hostGroupInfo = provisionClusterRequest.getHostGroupInfo();
     assertEquals(1, hostGroupInfo.size());
-    assertEquals(3, provisionClusterRequest.getTopologyValidators().size());
 
     // group2
     HostGroupInfo group2Info = hostGroupInfo.get("group2");
@@ -216,7 +212,6 @@ public class ProvisionClusterRequestTest {
     assertSame(blueprint, provisionClusterRequest.getBlueprint());
     Map<String, HostGroupInfo> hostGroupInfo = provisionClusterRequest.getHostGroupInfo();
     assertEquals(2, hostGroupInfo.size());
-    assertEquals(3, provisionClusterRequest.getTopologyValidators().size());
 
     // group1
     // host info
@@ -367,33 +362,6 @@ public class ProvisionClusterRequestTest {
     new ProvisionClusterRequest(properties, null);
   }
 
-  @Test
-  public void testGetValidators_noDefaultPassword() throws Exception {
-    Map<String, Object> properties = createBlueprintRequestProperties(CLUSTER_NAME, BLUEPRINT_NAME);
-    //properties.put("default_password", "pwd");
-    TopologyRequest request = new ProvisionClusterRequest(properties, null);
-    List<TopologyValidator> validators = request.getTopologyValidators();
-
-    assertEquals(3, validators.size());
-    TopologyValidator pwdValidator = validators.get(0);
-
-    TopologyValidator noDefaultPwdValidator = new RequiredPasswordValidator(null);
-    assertEquals(pwdValidator, noDefaultPwdValidator);
-  }
-
-  @Test
-  public void testGetValidators_defaultPassword() throws Exception {
-    Map<String, Object> properties = createBlueprintRequestProperties(CLUSTER_NAME, BLUEPRINT_NAME);
-    properties.put("default_password", "pwd");
-    TopologyRequest request = new ProvisionClusterRequest(properties, null);
-    List<TopologyValidator> validators = request.getTopologyValidators();
-
-    assertEquals(3, validators.size());
-    TopologyValidator pwdValidator = validators.get(0);
-
-    TopologyValidator defaultPwdValidator = new RequiredPasswordValidator("pwd");
-    assertEquals(pwdValidator, defaultPwdValidator);
-  }
 
   @Test(expected = InvalidTopologyTemplateException.class)
   public void testInvalidPredicateProperty() throws Exception {

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9cda4f1/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java
index 7f70ee0..5fbaed9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ScaleClusterRequestTest.java
@@ -116,7 +116,6 @@ public class ScaleClusterRequestTest {
     assertSame(blueprint, scaleClusterRequest.getBlueprint());
     Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo();
     assertEquals(1, hostGroupInfo.size());
-    assertEquals(0, scaleClusterRequest.getTopologyValidators().size());
 
     // group1
     // host info
@@ -147,7 +146,6 @@ public class ScaleClusterRequestTest {
     assertSame(blueprint, scaleClusterRequest.getBlueprint());
     Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo();
     assertEquals(1, hostGroupInfo.size());
-    assertEquals(0, scaleClusterRequest.getTopologyValidators().size());
 
     // group1
     // host info
@@ -176,7 +174,6 @@ public class ScaleClusterRequestTest {
     assertSame(blueprint, scaleClusterRequest.getBlueprint());
     Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo();
     assertEquals(1, hostGroupInfo.size());
-    assertEquals(0, scaleClusterRequest.getTopologyValidators().size());
 
     // group2
     // host info
@@ -203,7 +200,6 @@ public class ScaleClusterRequestTest {
     assertSame(blueprint, scaleClusterRequest.getBlueprint());
     Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo();
     assertEquals(1, hostGroupInfo.size());
-    assertEquals(0, scaleClusterRequest.getTopologyValidators().size());
 
     // group2
     // host info
@@ -226,7 +222,6 @@ public class ScaleClusterRequestTest {
     assertSame(blueprint, scaleClusterRequest.getBlueprint());
     Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo();
     assertEquals(1, hostGroupInfo.size());
-    assertEquals(0, scaleClusterRequest.getTopologyValidators().size());
 
     // group3
     // host info
@@ -253,7 +248,6 @@ public class ScaleClusterRequestTest {
     assertSame(blueprint, scaleClusterRequest.getBlueprint());
     Map<String, HostGroupInfo> hostGroupInfo = scaleClusterRequest.getHostGroupInfo();
     assertEquals(3, hostGroupInfo.size());
-    assertEquals(0, scaleClusterRequest.getTopologyValidators().size());
 
     // group
     // host info

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9cda4f1/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java
index 4acd04b..6bcd6bc 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterDeployWithStartOnlyTest.java
@@ -17,6 +17,19 @@
  */
 package org.apache.ambari.server.topology;
 
+import static org.easymock.EasyMock.anyBoolean;
+import static org.easymock.EasyMock.anyLong;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.anyString;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.isNull;
+import static org.easymock.EasyMock.newCapture;
+import static org.junit.Assert.assertEquals;
+
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -41,7 +54,6 @@ import org.apache.ambari.server.controller.internal.ProvisionAction;
 import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
 import org.apache.ambari.server.controller.internal.Stack;
 import org.apache.ambari.server.controller.spi.ClusterController;
-import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.orm.entities.TopologyLogicalRequestEntity;
 import org.apache.ambari.server.security.encryption.CredentialStoreService;
@@ -50,6 +62,7 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.SecurityType;
 import org.apache.ambari.server.topology.tasks.ConfigureClusterTaskFactory;
+import org.apache.ambari.server.topology.validators.TopologyValidatorService;
 import org.easymock.Capture;
 import org.easymock.EasyMockRule;
 import org.easymock.EasyMockSupport;
@@ -65,27 +78,9 @@ import org.powermock.api.easymock.PowerMock;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
-import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
-import static org.easymock.EasyMock.anyBoolean;
-import static org.easymock.EasyMock.anyLong;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.anyString;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.isA;
-import static org.easymock.EasyMock.isNull;
-import static org.easymock.EasyMock.newCapture;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-
 @RunWith(PowerMockRunner.class)
 @PrepareForTest(AmbariServer.class)
-public class ClusterDeployWithStartOnlyTest {
+public class ClusterDeployWithStartOnlyTest extends EasyMockSupport {
   private static final String CLUSTER_NAME = "test-cluster";
   private static final long CLUSTER_ID = 1;
   private static final String BLUEPRINT_NAME = "test-bp";
@@ -107,7 +102,6 @@ public class ClusterDeployWithStartOnlyTest {
   @Mock(type = MockType.NICE)
   private ProvisionClusterRequest request;
   private PersistedTopologyRequest persistedTopologyRequest;
-//  @Mock(type = MockType.STRICT)
   private LogicalRequestFactory logicalRequestFactory;
   @Mock(type = MockType.DEFAULT)
   private LogicalRequest logicalRequest;
@@ -162,6 +156,10 @@ public class ClusterDeployWithStartOnlyTest {
   @Mock(type = MockType.STRICT)
   private Future mockFuture;
 
+  @Mock
+  private TopologyValidatorService topologyValidatorServiceMock;
+
+
   private final Configuration stackConfig = new Configuration(new HashMap<String, Map<String, String>>(),
     new HashMap<String, Map<String, Map<String, String>>>());
   private final Configuration bpConfiguration = new Configuration(new HashMap<String, Map<String, String>>(),
@@ -180,19 +178,19 @@ public class ClusterDeployWithStartOnlyTest {
 
   private HostGroupInfo group1Info = new HostGroupInfo("group1");
   private HostGroupInfo group2Info = new HostGroupInfo("group2");
-  private Map<String, HostGroupInfo> groupInfoMap = new HashMap<String, HostGroupInfo>();
+  private Map<String, HostGroupInfo> groupInfoMap = new HashMap<>();
 
   private Collection<String> group1Components = Arrays.asList("component1", "component2", "component3");
   private Collection<String> group2Components = Arrays.asList("component3", "component4");
 
-  private Map<String, Collection<String>> group1ServiceComponents = new HashMap<String, Collection<String>>();
-  private Map<String, Collection<String>> group2ServiceComponents = new HashMap<String, Collection<String>>();
+  private Map<String, Collection<String>> group1ServiceComponents = new HashMap<>();
+  private Map<String, Collection<String>> group2ServiceComponents = new HashMap<>();
 
-  private Map<String, Collection<String>> serviceComponents = new HashMap<String, Collection<String>>();
+  private Map<String, Collection<String>> serviceComponents = new HashMap<>();
 
   private String predicate = "Hosts/host_name=foo";
 
-  private List<TopologyValidator> topologyValidators = new ArrayList<TopologyValidator>();
+  private List<TopologyValidator> topologyValidators = new ArrayList<>();
 
   private Capture<ClusterTopology> clusterTopologyCapture;
   private Capture<Map<String, Object>> configRequestPropertiesCapture;
@@ -214,7 +212,7 @@ public class ClusterDeployWithStartOnlyTest {
     topoConfiguration.setProperty("service2-site", "s2-prop", "s2-prop-value");
     topoConfiguration.setProperty("cluster-env", "g-prop", "g-prop-value");
 
-    //clusterRequestCapture = new Capture<ClusterRequest>();
+    //clusterRequestCapture = EasyMock.newCapture();
     // group 1 has fqdn specified
     group1Info.addHost("host1");
     group1Info.setConfiguration(topoGroup1Config);
@@ -226,7 +224,7 @@ public class ClusterDeployWithStartOnlyTest {
     groupInfoMap.put("group1", group1Info);
     groupInfoMap.put("group2", group2Info);
 
-    Map<String, HostGroup> groupMap = new HashMap<String, HostGroup>();
+    Map<String, HostGroup> groupMap = new HashMap<>();
     groupMap.put("group1", group1);
     groupMap.put("group2", group2);
 
@@ -291,7 +289,6 @@ public class ClusterDeployWithStartOnlyTest {
     expect(request.getDescription()).andReturn("Provision Cluster Test").anyTimes();
     expect(request.getConfiguration()).andReturn(topoConfiguration).anyTimes();
     expect(request.getHostGroupInfo()).andReturn(groupInfoMap).anyTimes();
-    expect(request.getTopologyValidators()).andReturn(topologyValidators).anyTimes();
     expect(request.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY);
     expect(request.getProvisionAction()).andReturn(ProvisionAction.START_ONLY).anyTimes();
     expect(request.getSecurityConfiguration()).andReturn(null).anyTimes();
@@ -392,7 +389,6 @@ public class ClusterDeployWithStartOnlyTest {
     ambariContext.persistInstallStateForUI(CLUSTER_NAME, STACK_NAME, STACK_VERSION);
     expectLastCall().once();
 
-    expect(clusterController.ensureResourceProvider(anyObject(Resource.Type.class))).andReturn(resourceProvider);
     expect(executor.submit(anyObject(AsyncCallableService.class))).andReturn(mockFuture).times(2);
 
     persistedTopologyRequest = new PersistedTopologyRequest(1, request);
@@ -402,12 +398,9 @@ public class ClusterDeployWithStartOnlyTest {
     persistedState.persistLogicalRequest((LogicalRequest) anyObject(), anyLong());
     expectLastCall().once();
 
-    replay(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory, logicalRequest,
-      configurationRequest, configurationRequest2, configurationRequest3, requestStatusResponse, executor,
-      persistedState, securityConfigurationFactory, credentialStoreService, clusterController, resourceProvider,
-      mockFuture, managementController, clusters, cluster, hostRoleCommandInstallComponent3,
-      hostRoleCommandInstallComponent4, hostRoleCommandStartComponent1, hostRoleCommandStartComponent2,
-      serviceComponentInfo, clientComponentInfo);
+    topologyValidatorServiceMock.validateTopologyConfiguration(anyObject(ClusterTopology.class));
+
+    replayAll();
 
     Class clazz = TopologyManager.class;
 
@@ -420,17 +413,8 @@ public class ClusterDeployWithStartOnlyTest {
 
   @After
   public void tearDown() {
-    verify(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
-      logicalRequest, configurationRequest, configurationRequest2, configurationRequest3,
-      requestStatusResponse, executor, persistedState, mockFuture,
-      managementController, clusters, cluster, hostRoleCommandInstallComponent3, hostRoleCommandInstallComponent4,
-      hostRoleCommandStartComponent1, hostRoleCommandStartComponent2);
-
-    reset(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
-      logicalRequest, configurationRequest, configurationRequest2, configurationRequest3,
-      requestStatusResponse, executor, persistedState, mockFuture,
-      managementController, clusters, cluster, hostRoleCommandInstallComponent3, hostRoleCommandInstallComponent4,
-      hostRoleCommandStartComponent1, hostRoleCommandStartComponent2);
+    verifyAll();
+    resetAll();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9cda4f1/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java
index a6c315e..0631b03 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartOnComponentLevelTest.java
@@ -18,6 +18,19 @@
 package org.apache.ambari.server.topology;
 
 
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_AND_START;
+import static org.easymock.EasyMock.anyBoolean;
+import static org.easymock.EasyMock.anyLong;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.anyString;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.isNull;
+import static org.easymock.EasyMock.newCapture;
+
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -42,7 +55,6 @@ import org.apache.ambari.server.controller.internal.ProvisionAction;
 import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
 import org.apache.ambari.server.controller.internal.Stack;
 import org.apache.ambari.server.controller.spi.ClusterController;
-import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.orm.entities.TopologyLogicalRequestEntity;
 import org.apache.ambari.server.security.encryption.CredentialStoreService;
@@ -51,6 +63,7 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.SecurityType;
 import org.apache.ambari.server.topology.tasks.ConfigureClusterTaskFactory;
+import org.apache.ambari.server.topology.validators.TopologyValidatorService;
 import org.easymock.Capture;
 import org.easymock.EasyMockRule;
 import org.easymock.EasyMockSupport;
@@ -66,26 +79,9 @@ import org.powermock.api.easymock.PowerMock;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
-import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_AND_START;
-import static org.easymock.EasyMock.anyBoolean;
-import static org.easymock.EasyMock.anyLong;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.anyString;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.isA;
-import static org.easymock.EasyMock.isNull;
-import static org.easymock.EasyMock.newCapture;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-
 @RunWith(PowerMockRunner.class)
 @PrepareForTest(AmbariServer.class)
-public class ClusterInstallWithoutStartOnComponentLevelTest {
+public class ClusterInstallWithoutStartOnComponentLevelTest extends EasyMockSupport {
   private static final String CLUSTER_NAME = "test-cluster";
   private static final long CLUSTER_ID = 1;
   private static final String BLUEPRINT_NAME = "test-bp";
@@ -107,7 +103,7 @@ public class ClusterInstallWithoutStartOnComponentLevelTest {
   @Mock(type = MockType.NICE)
   private ProvisionClusterRequest request;
   private PersistedTopologyRequest persistedTopologyRequest;
-//  @Mock(type = MockType.STRICT)
+  //  @Mock(type = MockType.STRICT)
   private LogicalRequestFactory logicalRequestFactory;
   @Mock(type = MockType.DEFAULT)
   private LogicalRequest logicalRequest;
@@ -157,6 +153,9 @@ public class ClusterInstallWithoutStartOnComponentLevelTest {
   @Mock(type = MockType.STRICT)
   private Future mockFuture;
 
+  @Mock
+  private TopologyValidatorService topologyValidatorServiceMock;
+
   private final Configuration stackConfig = new Configuration(new HashMap<String, Map<String, String>>(),
     new HashMap<String, Map<String, Map<String, String>>>());
   private final Configuration bpConfiguration = new Configuration(new HashMap<String, Map<String, String>>(),
@@ -175,19 +174,19 @@ public class ClusterInstallWithoutStartOnComponentLevelTest {
 
   private HostGroupInfo group1Info = new HostGroupInfo("group1");
   private HostGroupInfo group2Info = new HostGroupInfo("group2");
-  private Map<String, HostGroupInfo> groupInfoMap = new HashMap<String, HostGroupInfo>();
+  private Map<String, HostGroupInfo> groupInfoMap = new HashMap<>();
 
   private Collection<String> group1Components = Arrays.asList("component1", "component2", "component3");
   private Collection<String> group2Components = Arrays.asList("component3", "component4");
 
-  private Map<String, Collection<String>> group1ServiceComponents = new HashMap<String, Collection<String>>();
-  private Map<String, Collection<String>> group2ServiceComponents = new HashMap<String, Collection<String>>();
+  private Map<String, Collection<String>> group1ServiceComponents = new HashMap<>();
+  private Map<String, Collection<String>> group2ServiceComponents = new HashMap<>();
 
-  private Map<String, Collection<String>> serviceComponents = new HashMap<String, Collection<String>>();
+  private Map<String, Collection<String>> serviceComponents = new HashMap<>();
 
   private String predicate = "Hosts/host_name=foo";
 
-  private List<TopologyValidator> topologyValidators = new ArrayList<TopologyValidator>();
+  private List<TopologyValidator> topologyValidators = new ArrayList<>();
 
   private Capture<ClusterTopology> clusterTopologyCapture;
   private Capture<Map<String, Object>> configRequestPropertiesCapture;
@@ -209,7 +208,7 @@ public class ClusterInstallWithoutStartOnComponentLevelTest {
     topoConfiguration.setProperty("service2-site", "s2-prop", "s2-prop-value");
     topoConfiguration.setProperty("cluster-env", "g-prop", "g-prop-value");
 
-    //clusterRequestCapture = new Capture<ClusterRequest>();
+    //clusterRequestCapture = EasyMock.newCapture();
     // group 1 has fqdn specified
     group1Info.addHost("host1");
     group1Info.setConfiguration(topoGroup1Config);
@@ -221,7 +220,7 @@ public class ClusterInstallWithoutStartOnComponentLevelTest {
     groupInfoMap.put("group1", group1Info);
     groupInfoMap.put("group2", group2Info);
 
-    Map<String, HostGroup> groupMap = new HashMap<String, HostGroup>();
+    Map<String, HostGroup> groupMap = new HashMap<>();
     groupMap.put("group1", group1);
     groupMap.put("group2", group2);
 
@@ -286,7 +285,6 @@ public class ClusterInstallWithoutStartOnComponentLevelTest {
     expect(request.getDescription()).andReturn("Provision Cluster Test").anyTimes();
     expect(request.getConfiguration()).andReturn(topoConfiguration).anyTimes();
     expect(request.getHostGroupInfo()).andReturn(groupInfoMap).anyTimes();
-    expect(request.getTopologyValidators()).andReturn(topologyValidators).anyTimes();
     expect(request.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY);
     expect(request.getProvisionAction()).andReturn(INSTALL_AND_START).anyTimes();
     expect(request.getSecurityConfiguration()).andReturn(null).anyTimes();
@@ -368,7 +366,6 @@ public class ClusterInstallWithoutStartOnComponentLevelTest {
     ambariContext.persistInstallStateForUI(CLUSTER_NAME, STACK_NAME, STACK_VERSION);
     expectLastCall().once();
 
-    expect(clusterController.ensureResourceProvider(anyObject(Resource.Type.class))).andReturn(resourceProvider);
     expect(executor.submit(anyObject(AsyncCallableService.class))).andReturn(mockFuture).times(2);
 
     persistedTopologyRequest = new PersistedTopologyRequest(1, request);
@@ -378,10 +375,9 @@ public class ClusterInstallWithoutStartOnComponentLevelTest {
     persistedState.persistLogicalRequest((LogicalRequest) anyObject(), anyLong());
     expectLastCall().once();
 
-    replay(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory, logicalRequest,
-      configurationRequest, configurationRequest2, configurationRequest3, requestStatusResponse, executor,
-      persistedState, securityConfigurationFactory, credentialStoreService, clusterController, resourceProvider,
-      mockFuture, managementController, clusters, cluster, hostRoleCommand, serviceComponentInfo, clientComponentInfo);
+    topologyValidatorServiceMock.validateTopologyConfiguration(anyObject(ClusterTopology.class));
+
+    replayAll();
 
     Class clazz = TopologyManager.class;
 
@@ -394,15 +390,8 @@ public class ClusterInstallWithoutStartOnComponentLevelTest {
 
   @After
   public void tearDown() {
-    verify(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
-      logicalRequest, configurationRequest, configurationRequest2, configurationRequest3,
-      requestStatusResponse, executor, persistedState, mockFuture,
-      managementController, clusters, cluster, hostRoleCommand);
-
-    reset(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
-      logicalRequest, configurationRequest, configurationRequest2, configurationRequest3,
-      requestStatusResponse, executor, persistedState, mockFuture,
-      managementController, clusters, cluster, hostRoleCommand);
+    verifyAll();
+    resetAll();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9cda4f1/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java
index 759adb5..c074d78 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterInstallWithoutStartTest.java
@@ -18,6 +18,19 @@
 package org.apache.ambari.server.topology;
 
 
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
+import static org.easymock.EasyMock.anyBoolean;
+import static org.easymock.EasyMock.anyLong;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.anyString;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.isNull;
+import static org.easymock.EasyMock.newCapture;
+
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -42,7 +55,6 @@ import org.apache.ambari.server.controller.internal.ProvisionAction;
 import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
 import org.apache.ambari.server.controller.internal.Stack;
 import org.apache.ambari.server.controller.spi.ClusterController;
-import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.orm.entities.TopologyLogicalRequestEntity;
 import org.apache.ambari.server.security.encryption.CredentialStoreService;
@@ -51,6 +63,7 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.SecurityType;
 import org.apache.ambari.server.topology.tasks.ConfigureClusterTaskFactory;
+import org.apache.ambari.server.topology.validators.TopologyValidatorService;
 import org.easymock.Capture;
 import org.easymock.EasyMockRule;
 import org.easymock.EasyMockSupport;
@@ -66,27 +79,9 @@ import org.powermock.api.easymock.PowerMock;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
-import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
-import static org.apache.ambari.server.controller.internal.ProvisionAction.START_ONLY;
-import static org.easymock.EasyMock.anyBoolean;
-import static org.easymock.EasyMock.anyLong;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.anyString;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.isA;
-import static org.easymock.EasyMock.isNull;
-import static org.easymock.EasyMock.newCapture;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-
 @RunWith(PowerMockRunner.class)
 @PrepareForTest(AmbariServer.class)
-public class ClusterInstallWithoutStartTest {
+public class ClusterInstallWithoutStartTest extends EasyMockSupport {
   private static final String CLUSTER_NAME = "test-cluster";
   private static final long CLUSTER_ID = 1;
   private static final String BLUEPRINT_NAME = "test-bp";
@@ -107,8 +102,9 @@ public class ClusterInstallWithoutStartTest {
 
   @Mock(type = MockType.NICE)
   private ProvisionClusterRequest request;
+
   private PersistedTopologyRequest persistedTopologyRequest;
-//  @Mock(type = MockType.STRICT)
+  //  @Mock(type = MockType.STRICT)
   private LogicalRequestFactory logicalRequestFactory;
   @Mock(type = MockType.DEFAULT)
   private LogicalRequest logicalRequest;
@@ -158,6 +154,9 @@ public class ClusterInstallWithoutStartTest {
   @Mock(type = MockType.STRICT)
   private Future mockFuture;
 
+  @Mock
+  private TopologyValidatorService topologyValidatorServiceMock;
+
   private final Configuration stackConfig = new Configuration(new HashMap<String, Map<String, String>>(),
     new HashMap<String, Map<String, Map<String, String>>>());
   private final Configuration bpConfiguration = new Configuration(new HashMap<String, Map<String, String>>(),
@@ -176,19 +175,19 @@ public class ClusterInstallWithoutStartTest {
 
   private HostGroupInfo group1Info = new HostGroupInfo("group1");
   private HostGroupInfo group2Info = new HostGroupInfo("group2");
-  private Map<String, HostGroupInfo> groupInfoMap = new HashMap<String, HostGroupInfo>();
+  private Map<String, HostGroupInfo> groupInfoMap = new HashMap<>();
 
   private Collection<String> group1Components = Arrays.asList("component1", "component2", "component3");
   private Collection<String> group2Components = Arrays.asList("component3", "component4");
 
-  private Map<String, Collection<String>> group1ServiceComponents = new HashMap<String, Collection<String>>();
-  private Map<String, Collection<String>> group2ServiceComponents = new HashMap<String, Collection<String>>();
+  private Map<String, Collection<String>> group1ServiceComponents = new HashMap<>();
+  private Map<String, Collection<String>> group2ServiceComponents = new HashMap<>();
 
-  private Map<String, Collection<String>> serviceComponents = new HashMap<String, Collection<String>>();
+  private Map<String, Collection<String>> serviceComponents = new HashMap<>();
 
   private String predicate = "Hosts/host_name=foo";
 
-  private List<TopologyValidator> topologyValidators = new ArrayList<TopologyValidator>();
+  private List<TopologyValidator> topologyValidators = new ArrayList<>();
 
   private Capture<ClusterTopology> clusterTopologyCapture;
   private Capture<Map<String, Object>> configRequestPropertiesCapture;
@@ -210,7 +209,7 @@ public class ClusterInstallWithoutStartTest {
     topoConfiguration.setProperty("service2-site", "s2-prop", "s2-prop-value");
     topoConfiguration.setProperty("cluster-env", "g-prop", "g-prop-value");
 
-    //clusterRequestCapture = new Capture<ClusterRequest>();
+    //clusterRequestCapture = EasyMock.newCapture();
     // group 1 has fqdn specified
     group1Info.addHost("host1");
     group1Info.setConfiguration(topoGroup1Config);
@@ -222,7 +221,7 @@ public class ClusterInstallWithoutStartTest {
     groupInfoMap.put("group1", group1Info);
     groupInfoMap.put("group2", group2Info);
 
-    Map<String, HostGroup> groupMap = new HashMap<String, HostGroup>();
+    Map<String, HostGroup> groupMap = new HashMap<>();
     groupMap.put("group1", group1);
     groupMap.put("group2", group2);
 
@@ -287,7 +286,7 @@ public class ClusterInstallWithoutStartTest {
     expect(request.getDescription()).andReturn("Provision Cluster Test").anyTimes();
     expect(request.getConfiguration()).andReturn(topoConfiguration).anyTimes();
     expect(request.getHostGroupInfo()).andReturn(groupInfoMap).anyTimes();
-    expect(request.getTopologyValidators()).andReturn(topologyValidators).anyTimes();
+
     expect(request.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY);
     expect(request.getProvisionAction()).andReturn(INSTALL_ONLY).anyTimes();
     expect(request.getSecurityConfiguration()).andReturn(null).anyTimes();
@@ -336,7 +335,7 @@ public class ClusterInstallWithoutStartTest {
 
     expect(ambariContext.getPersistedTopologyState()).andReturn(persistedState).anyTimes();
     //todo: don't ignore param
-    ambariContext.createAmbariResources(isA(ClusterTopology.class), eq(CLUSTER_NAME), (SecurityType) isNull(), (String)isNull());
+    ambariContext.createAmbariResources(isA(ClusterTopology.class), eq(CLUSTER_NAME), (SecurityType) isNull(), (String) isNull());
     expectLastCall().once();
     expect(ambariContext.getNextRequestId()).andReturn(1L).once();
     expect(ambariContext.isClusterKerberosEnabled(CLUSTER_ID)).andReturn(false).anyTimes();
@@ -362,7 +361,6 @@ public class ClusterInstallWithoutStartTest {
     ambariContext.persistInstallStateForUI(CLUSTER_NAME, STACK_NAME, STACK_VERSION);
     expectLastCall().once();
 
-    expect(clusterController.ensureResourceProvider(anyObject(Resource.Type.class))).andReturn(resourceProvider);
     expect(executor.submit(anyObject(AsyncCallableService.class))).andReturn(mockFuture).times(2);
 
     persistedTopologyRequest = new PersistedTopologyRequest(1, request);
@@ -372,10 +370,9 @@ public class ClusterInstallWithoutStartTest {
     persistedState.persistLogicalRequest((LogicalRequest) anyObject(), anyLong());
     expectLastCall().once();
 
-    replay(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory, logicalRequest,
-      configurationRequest, configurationRequest2, configurationRequest3, requestStatusResponse, executor,
-      persistedState, securityConfigurationFactory, credentialStoreService, clusterController, resourceProvider,
-      mockFuture, managementController, clusters, cluster, hostRoleCommand, serviceComponentInfo, clientComponentInfo);
+    topologyValidatorServiceMock.validateTopologyConfiguration(anyObject(ClusterTopology.class));
+
+    replayAll();
 
     Class clazz = TopologyManager.class;
 
@@ -388,15 +385,8 @@ public class ClusterInstallWithoutStartTest {
 
   @After
   public void tearDown() {
-    verify(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
-      logicalRequest, configurationRequest, configurationRequest2, configurationRequest3,
-      requestStatusResponse, executor, persistedState, mockFuture,
-      managementController, clusters, cluster, hostRoleCommand);
-
-    reset(blueprint, stack, request, group1, group2, ambariContext, logicalRequestFactory,
-      logicalRequest, configurationRequest, configurationRequest2, configurationRequest3,
-      requestStatusResponse, executor, persistedState, mockFuture,
-      managementController, clusters, cluster, hostRoleCommand);
+    verifyAll();
+    resetAll();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9cda4f1/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
index 95e58ae..89dafce 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
@@ -18,27 +18,22 @@
 
 package org.apache.ambari.server.topology;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import static org.easymock.EasyMock.expect;
+import static org.powermock.api.easymock.PowerMock.createNiceMock;
+import static org.powermock.api.easymock.PowerMock.replay;
+import static org.powermock.api.easymock.PowerMock.reset;
+import static org.powermock.api.easymock.PowerMock.verify;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.notNull;
-import static org.powermock.api.easymock.PowerMock.createNiceMock;
-import static org.powermock.api.easymock.PowerMock.createStrictMock;
-import static org.powermock.api.easymock.PowerMock.replay;
-import static org.powermock.api.easymock.PowerMock.reset;
-import static org.powermock.api.easymock.PowerMock.verify;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Unit tests for ClusterTopologyImpl.
@@ -54,16 +49,19 @@ public class ClusterTopologyImplTest {
   private static final HostGroup group2 = createNiceMock(HostGroup.class);
   private static final HostGroup group3 = createNiceMock(HostGroup.class);
   private static final HostGroup group4 = createNiceMock(HostGroup.class);
-  private final Map<String, HostGroupInfo> hostGroupInfoMap = new HashMap<String, HostGroupInfo>();
-  private final Map<String, HostGroup> hostGroupMap = new HashMap<String, HostGroup>();
-  private final List<TopologyValidator> topologyValidators = new ArrayList<TopologyValidator>();
-  private static Configuration configuration;
+  private final Map<String, HostGroupInfo> hostGroupInfoMap = new HashMap<>();
+  private final Map<String, HostGroup> hostGroupMap = new HashMap<>();
+
+  private Configuration configuration;
+  private Configuration bpconfiguration;
 
   @Before
   public void setUp() throws Exception {
 
     configuration = new Configuration(new HashMap<String, Map<String, String>>(),
-        new HashMap<String, Map<String, Map<String, String>>>());
+      new HashMap<String, Map<String, Map<String, String>>>());
+    bpconfiguration = new Configuration(new HashMap<String, Map<String, String>>(),
+      new HashMap<String, Map<String, Map<String, String>>>());
 
     HostGroupInfo group1Info = new HostGroupInfo("group1");
     HostGroupInfo group2Info = new HostGroupInfo("group2");
@@ -75,15 +73,19 @@ public class ClusterTopologyImplTest {
     hostGroupInfoMap.put("group4", group4Info);
 
     group1Info.setConfiguration(configuration);
-    Collection<String> group1Hosts = new HashSet<String>();
+    Collection<String> group1Hosts = new HashSet<>();
     group1Hosts.add("host1");
     group1Hosts.add("host2");
     group1Info.addHosts(group1Hosts);
 
     group2Info.setConfiguration(configuration);
-    Collection<String> group2Hosts = new HashSet<String>();
+    Collection<String> group2Hosts = new HashSet<>();
     group2Hosts.add("host3");
     group2Info.addHosts(group2Hosts);
+    Collection<String> group4Hosts = new HashSet<>();
+    group4Hosts.add("host4");
+    group4Hosts.add("host5");
+    group4Info.addHosts(group4Hosts);
 
     group3Info.setConfiguration(configuration);
     group3Info.setRequestedCount(5);
@@ -92,26 +94,26 @@ public class ClusterTopologyImplTest {
     group4Info.setRequestedCount(5);
     group4Info.setPredicate(predicate);
 
-    expect(blueprint.getConfiguration()).andReturn(configuration).anyTimes();
+    expect(blueprint.getConfiguration()).andReturn(bpconfiguration).anyTimes();
 
     hostGroupMap.put("group1", group1);
     hostGroupMap.put("group2", group2);
     hostGroupMap.put("group3", group3);
     hostGroupMap.put("group4", group4);
 
-    Set<Component> group1Components = new HashSet<Component>();
+    Set<Component> group1Components = new HashSet<>();
     group1Components.add(new Component("component1"));
     group1Components.add(new Component("component2"));
 
-    Set<String> group1ComponentNames = new HashSet<String>();
+    Set<String> group1ComponentNames = new HashSet<>();
     group1ComponentNames.add("component1");
     group1ComponentNames.add("component2");
 
-    Set<Component> group2Components = new HashSet<Component>();
+    Set<Component> group2Components = new HashSet<>();
     group2Components.add(new Component("component3"));
-    Set<Component> group3Components = new HashSet<Component>();
+    Set<Component> group3Components = new HashSet<>();
     group3Components.add(new Component("component4"));
-    Set<Component> group4Components = new HashSet<Component>();
+    Set<Component> group4Components = new HashSet<>();
     group4Components.add(new Component("component5"));
 
     expect(blueprint.getHostGroups()).andReturn(hostGroupMap).anyTimes();
@@ -133,7 +135,7 @@ public class ClusterTopologyImplTest {
     expect(group1.getComponentNames()).andReturn(group1ComponentNames).anyTimes();
     expect(group2.getComponentNames()).andReturn(Collections.singletonList("component3")).anyTimes();
     expect(group3.getComponentNames()).andReturn(Collections.singletonList("component4")).anyTimes();
-    expect(group4.getComponentNames()).andReturn(Collections.singletonList("component5")).anyTimes();
+    expect(group4.getComponentNames()).andReturn(Collections.singletonList("NAMENODE")).anyTimes();
   }
 
   @After
@@ -141,7 +143,7 @@ public class ClusterTopologyImplTest {
     verify(blueprint, group1, group2, group3, group4);
     reset(blueprint, group1, group2, group3, group4);
 
-    topologyValidators.clear();
+
     hostGroupInfoMap.clear();
     hostGroupMap.clear();
   }
@@ -150,36 +152,7 @@ public class ClusterTopologyImplTest {
     replay(blueprint, group1, group2, group3, group4);
   }
 
-  @Test(expected = InvalidTopologyException.class)
-  public void testCreate_validatorFails() throws Exception {
-    TestTopologyRequest request = new TestTopologyRequest(TopologyRequest.Type.PROVISION);
-
-    TopologyValidator validator = createStrictMock(TopologyValidator.class);
-    topologyValidators.add(validator);
-
-    validator.validate((ClusterTopology) notNull());
-    expectLastCall().andThrow(new InvalidTopologyException("test"));
-
-    replayAll();
-    replay(validator);
-    // should throw exception due to validation failure
-    new ClusterTopologyImpl(null, request);
-  }
-
-  @Test
-     public void testCreate_validatorSuccess() throws Exception {
-    TestTopologyRequest request = new TestTopologyRequest(TopologyRequest.Type.PROVISION);
-
-    TopologyValidator validator = createStrictMock(TopologyValidator.class);
-    topologyValidators.add(validator);
 
-    validator.validate((ClusterTopology) notNull());
-
-    replayAll();
-    replay(validator);
-
-    new ClusterTopologyImpl(null, request);
-  }
 
   @Test(expected = InvalidTopologyException.class)
   public void testCreate_duplicateHosts() throws Exception {
@@ -197,13 +170,7 @@ public class ClusterTopologyImplTest {
   public void test_GetHostAssigmentForComponents() throws Exception {
     TestTopologyRequest request = new TestTopologyRequest(TopologyRequest.Type.PROVISION);
 
-    TopologyValidator validator = createStrictMock(TopologyValidator.class);
-    topologyValidators.add(validator);
-
-    validator.validate((ClusterTopology) notNull());
-
     replayAll();
-    replay(validator);
 
     new ClusterTopologyImpl(null, request).getHostAssignmentsForComponent("component1");
   }
@@ -236,7 +203,7 @@ public class ClusterTopologyImplTest {
 
     @Override
     public Configuration getConfiguration() {
-      return configuration;
+      return bpconfiguration;
     }
 
     @Override
@@ -245,11 +212,6 @@ public class ClusterTopologyImplTest {
     }
 
     @Override
-    public List<TopologyValidator> getTopologyValidators() {
-      return topologyValidators;
-    }
-
-    @Override
     public String getDescription() {
       return "Test Request";
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9cda4f1/ambari-server/src/test/java/org/apache/ambari/server/topology/RequiredPasswordValidatorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/RequiredPasswordValidatorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/RequiredPasswordValidatorTest.java
index a077a7e..44831c4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/RequiredPasswordValidatorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/RequiredPasswordValidatorTest.java
@@ -20,10 +20,6 @@ package org.apache.ambari.server.topology;
 
 import static junit.framework.Assert.assertEquals;
 import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.powermock.api.easymock.PowerMock.createNiceMock;
-import static org.powermock.api.easymock.PowerMock.verify;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -35,20 +31,37 @@ import java.util.Map;
 import org.apache.ambari.server.controller.internal.Stack;
 import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.topology.validators.RequiredPasswordValidator;
+import org.easymock.EasyMockRule;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
+import org.easymock.TestSubject;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 
 /**
  * Unit tests for RequiredPasswordValidator.
  */
-public class RequiredPasswordValidatorTest {
+public class RequiredPasswordValidatorTest extends EasyMockSupport {
 
-  private static final ClusterTopology topology = createNiceMock(ClusterTopology.class);
-  private static final Blueprint blueprint = createNiceMock(Blueprint.class);
-  private static final Stack stack = createNiceMock(Stack.class);
-  private static final HostGroup group1 = createNiceMock(HostGroup.class);
-  private static final HostGroup group2 = createNiceMock(HostGroup.class);
+  @Rule
+  public EasyMockRule mocks = new EasyMockRule(this);
+
+  @Mock
+  private ClusterTopology topology;
+
+  @Mock
+  private Blueprint blueprint;
+
+  @Mock
+  private Stack stack;
+
+  @Mock
+  private HostGroup group1;
+
+  @Mock
+  private HostGroup group2;
 
   private static Configuration stackDefaults;
   private static Configuration bpClusterConfig;
@@ -71,30 +84,33 @@ public class RequiredPasswordValidatorTest {
   private static final Collection<Stack.ConfigProperty> service2RequiredPwdConfigs = new HashSet<Stack.ConfigProperty>();
   private static final Collection<Stack.ConfigProperty> service3RequiredPwdConfigs = new HashSet<Stack.ConfigProperty>();
 
+  @TestSubject
+  private RequiredPasswordValidator validator = new RequiredPasswordValidator();
+
 
   @Before
   public void setup() {
 
     stackDefaults = new Configuration(new HashMap<String, Map<String, String>>(),
-        new HashMap<String, Map<String, Map<String, String>>>());
+      new HashMap<String, Map<String, Map<String, String>>>());
 
     bpClusterConfig = new Configuration(new HashMap<String, Map<String, String>>(),
-        new HashMap<String, Map<String, Map<String, String>>>(), stackDefaults);
+      new HashMap<String, Map<String, Map<String, String>>>(), stackDefaults);
 
     topoClusterConfig = new Configuration(new HashMap<String, Map<String, String>>(),
-        new HashMap<String, Map<String, Map<String, String>>>(), bpClusterConfig);
+      new HashMap<String, Map<String, Map<String, String>>>(), bpClusterConfig);
 
     bpGroup1Config = new Configuration(new HashMap<String, Map<String, String>>(),
-        new HashMap<String, Map<String, Map<String, String>>>(), topoClusterConfig);
+      new HashMap<String, Map<String, Map<String, String>>>(), topoClusterConfig);
 
     bpGroup2Config = new Configuration(new HashMap<String, Map<String, String>>(),
-        new HashMap<String, Map<String, Map<String, String>>>(), topoClusterConfig);
+      new HashMap<String, Map<String, Map<String, String>>>(), topoClusterConfig);
 
     topoGroup1Config = new Configuration(new HashMap<String, Map<String, String>>(),
-        new HashMap<String, Map<String, Map<String, String>>>(), bpGroup1Config);
+      new HashMap<String, Map<String, Map<String, String>>>(), bpGroup1Config);
 
     topoGroup2Config = new Configuration(new HashMap<String, Map<String, String>>(),
-        new HashMap<String, Map<String, Map<String, String>>>(), bpGroup2Config);
+      new HashMap<String, Map<String, Map<String, String>>>(), bpGroup2Config);
 
     service1RequiredPwdConfigs.clear();
     service2RequiredPwdConfigs.clear();
@@ -149,45 +165,57 @@ public class RequiredPasswordValidatorTest {
     expect(stack.getRequiredConfigurationProperties("service2", PropertyInfo.PropertyType.PASSWORD)).andReturn(service2RequiredPwdConfigs).anyTimes();
     expect(stack.getRequiredConfigurationProperties("service3", PropertyInfo.PropertyType.PASSWORD)).andReturn(service3RequiredPwdConfigs).anyTimes();
 
-    replay(topology, blueprint, stack, group1, group2);
   }
 
   @After
   public void tearDown() {
-    verify(topology, blueprint, stack, group1, group2);
-    reset(topology, blueprint, stack, group1, group2);
+    verifyAll();
+    resetAll();
   }
 
 
   @Test
   public void testValidate_noRequiredProps__noDefaultPwd() throws Exception {
-    TopologyValidator validator = new RequiredPasswordValidator(null);
+    // GIVEN
     // no required pwd properties so shouldn't throw an exception
+    expect(topology.getDefaultPassword()).andReturn(null);
+    replayAll();
+
+    // WHEN
     validator.validate(topology);
   }
 
   @Test
   public void testValidate_noRequiredProps__defaultPwd() throws Exception {
-    TopologyValidator validator = new RequiredPasswordValidator("pwd");
-    // no required pwd properties so shouldn't throw an exception
+    // GIVEN
+    expect(topology.getDefaultPassword()).andReturn("pwd");
+    replayAll();
+
+    // WHEN
     validator.validate(topology);
+
   }
 
   @Test(expected = InvalidTopologyException.class)
   public void testValidate_missingPwd__NoDefaultPwd() throws Exception {
+    expect(topology.getDefaultPassword()).andReturn(null);
+    replayAll();
+
     Stack.ConfigProperty pwdProp = new Stack.ConfigProperty("test-type", "pwdProp", null);
     service1RequiredPwdConfigs.add(pwdProp);
 
-    TopologyValidator validator = new RequiredPasswordValidator(null);
+
     validator.validate(topology);
   }
 
   @Test
   public void testValidate_missingPwd__defaultPwd() throws Exception {
+    expect(topology.getDefaultPassword()).andReturn("default-pwd");
+    replayAll();
+
     Stack.ConfigProperty pwdProp = new Stack.ConfigProperty("test-type", "pwdProp", null);
     service1RequiredPwdConfigs.add(pwdProp);
 
-    TopologyValidator validator = new RequiredPasswordValidator("default-pwd");
     // default value should be set
     validator.validate(topology);
 
@@ -197,62 +225,78 @@ public class RequiredPasswordValidatorTest {
 
   @Test
   public void testValidate_pwdPropertyInTopoGroupConfig__NoDefaultPwd() throws Exception {
+    expect(topology.getDefaultPassword()).andReturn(null);
+    replayAll();
+
     Stack.ConfigProperty pwdProp = new Stack.ConfigProperty("test-type", "pwdProp", null);
     service3RequiredPwdConfigs.add(pwdProp);
     // group2 has a component from service 3
     topoGroup2Config.getProperties().put("test-type", Collections.singletonMap("pwdProp", "secret"));
 
-    TopologyValidator validator = new RequiredPasswordValidator(null);
     validator.validate(topology);
   }
 
   @Test
   public void testValidate_pwdPropertyInTopoClusterConfig__NoDefaultPwd() throws Exception {
+    expect(topology.getDefaultPassword()).andReturn(null);
+    replayAll();
+
     Stack.ConfigProperty pwdProp = new Stack.ConfigProperty("test-type", "pwdProp", null);
     service3RequiredPwdConfigs.add(pwdProp);
     // group2 has a component from service 3
     topoClusterConfig.getProperties().put("test-type", Collections.singletonMap("pwdProp", "secret"));
 
-    TopologyValidator validator = new RequiredPasswordValidator(null);
     validator.validate(topology);
   }
 
   @Test
   public void testValidate_pwdPropertyInBPGroupConfig__NoDefaultPwd() throws Exception {
+    expect(topology.getDefaultPassword()).andReturn(null);
+    replayAll();
+
     Stack.ConfigProperty pwdProp = new Stack.ConfigProperty("test-type", "pwdProp", null);
     service3RequiredPwdConfigs.add(pwdProp);
     // group2 has a component from service 3
     bpGroup2Config.getProperties().put("test-type", Collections.singletonMap("pwdProp", "secret"));
 
-    TopologyValidator validator = new RequiredPasswordValidator(null);
+
     validator.validate(topology);
   }
 
   @Test
   public void testValidate_pwdPropertyInBPClusterConfig__NoDefaultPwd() throws Exception {
+    expect(topology.getDefaultPassword()).andReturn(null);
+    replayAll();
+
     Stack.ConfigProperty pwdProp = new Stack.ConfigProperty("test-type", "pwdProp", null);
     service3RequiredPwdConfigs.add(pwdProp);
     // group2 has a component from service 3
     bpClusterConfig.getProperties().put("test-type", Collections.singletonMap("pwdProp", "secret"));
 
-    TopologyValidator validator = new RequiredPasswordValidator(null);
+
     validator.validate(topology);
   }
 
   @Test(expected = InvalidTopologyException.class)
   public void testValidate_pwdPropertyInStackConfig__NoDefaultPwd() throws Exception {
+    expect(topology.getDefaultPassword()).andReturn(null);
+    replayAll();
+
     Stack.ConfigProperty pwdProp = new Stack.ConfigProperty("test-type", "pwdProp", null);
     service3RequiredPwdConfigs.add(pwdProp);
     // group2 has a component from service 3
     stackDefaults.getProperties().put("test-type", Collections.singletonMap("pwdProp", "secret"));
 
-    TopologyValidator validator = new RequiredPasswordValidator(null);
+
     // because stack config is ignored for validation, an exception should be thrown
     validator.validate(topology);
   }
 
   @Test
   public void testValidate_twoRequiredPwdOneSpecified__defaultPwd() throws Exception {
+    expect(topology.getDefaultPassword()).andReturn("default-pwd");
+    replayAll();
+
     Stack.ConfigProperty pwdProp = new Stack.ConfigProperty("test-type", "pwdProp", null);
     Stack.ConfigProperty pwdProp2 = new Stack.ConfigProperty("test2-type", "pwdProp2", null);
     service1RequiredPwdConfigs.add(pwdProp);
@@ -260,7 +304,6 @@ public class RequiredPasswordValidatorTest {
 
     topoClusterConfig.getProperties().put("test2-type", Collections.singletonMap("pwdProp2", "secret"));
 
-    TopologyValidator validator = new RequiredPasswordValidator("default-pwd");
     // default value should be set
     validator.validate(topology);
 
@@ -271,6 +314,9 @@ public class RequiredPasswordValidatorTest {
 
   @Test
   public void testValidate_twoRequiredPwdTwoSpecified__noDefaultPwd() throws Exception {
+    expect(topology.getDefaultPassword()).andReturn("default-pwd");
+    replayAll();
+
     Stack.ConfigProperty pwdProp = new Stack.ConfigProperty("test-type", "pwdProp", null);
     Stack.ConfigProperty pwdProp2 = new Stack.ConfigProperty("test2-type", "pwdProp2", null);
     service1RequiredPwdConfigs.add(pwdProp);
@@ -279,7 +325,6 @@ public class RequiredPasswordValidatorTest {
     topoClusterConfig.getProperties().put("test2-type", Collections.singletonMap("pwdProp2", "secret2"));
     topoClusterConfig.getProperties().put("test-type", Collections.singletonMap("pwdProp", "secret1"));
 
-    TopologyValidator validator = new RequiredPasswordValidator(null);
     // default value should be set
     validator.validate(topology);
 
@@ -290,12 +335,14 @@ public class RequiredPasswordValidatorTest {
 
   @Test
   public void testValidate_multipleMissingPwd__defaultPwd() throws Exception {
+    expect(topology.getDefaultPassword()).andReturn("default-pwd");
+    replayAll();
+
     Stack.ConfigProperty pwdProp = new Stack.ConfigProperty("test-type", "pwdProp", null);
     Stack.ConfigProperty pwdProp2 = new Stack.ConfigProperty("test2-type", "pwdProp2", null);
     service1RequiredPwdConfigs.add(pwdProp);
     service3RequiredPwdConfigs.add(pwdProp2);
 
-    TopologyValidator validator = new RequiredPasswordValidator("default-pwd");
     // default value should be set
     validator.validate(topology);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9cda4f1/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
index 120ac2f..0c1a13d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/TopologyManagerTest.java
@@ -67,6 +67,7 @@ import org.apache.ambari.server.stack.NoSuchStackException;
 import org.apache.ambari.server.state.SecurityType;
 import org.apache.ambari.server.state.quicklinksprofile.QuickLinksProfile;
 import org.apache.ambari.server.topology.tasks.ConfigureClusterTaskFactory;
+import org.apache.ambari.server.topology.validators.TopologyValidatorService;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.easymock.EasyMockRule;
@@ -160,6 +161,9 @@ public class TopologyManagerTest {
   @Mock(type = MockType.STRICT)
   private Future mockFuture;
 
+  @Mock
+  private TopologyValidatorService topologyValidatorService;
+
   private final Configuration stackConfig = new Configuration(new HashMap<String, Map<String, String>>(),
       new HashMap<String, Map<String, Map<String, String>>>());
   private final Configuration bpConfiguration = new Configuration(new HashMap<String, Map<String, String>>(),
@@ -280,7 +284,6 @@ public class TopologyManagerTest {
     expect(request.getDescription()).andReturn("Provision Cluster Test").anyTimes();
     expect(request.getConfiguration()).andReturn(topoConfiguration).anyTimes();
     expect(request.getHostGroupInfo()).andReturn(groupInfoMap).anyTimes();
-    expect(request.getTopologyValidators()).andReturn(topologyValidators).anyTimes();
 
     expect(request.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.NEVER_APPLY).anyTimes();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9cda4f1/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/HiveServiceValidatorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/HiveServiceValidatorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/HiveServiceValidatorTest.java
index 745b01b..3308333 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/HiveServiceValidatorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/HiveServiceValidatorTest.java
@@ -122,6 +122,7 @@ public class HiveServiceValidatorTest extends EasyMockSupport {
     Collection<String> configTypes = Arrays.asList("hive-env", "core-site", "hadoop-env");
     EasyMock.expect(clusterTopologyMock.getBlueprint()).andReturn(blueprintMock).anyTimes();
     EasyMock.expect(blueprintMock.getServices()).andReturn(blueprintServices).anyTimes();
+    EasyMock.expect(blueprintMock.getComponents("HIVE")).andReturn(Collections.<String>emptyList()).anyTimes();
     EasyMock.expect(clusterTopologyMock.getConfiguration()).andReturn(configurationMock);
     EasyMock.expect(configurationMock.getAllConfigTypes()).andReturn(configTypes);
 
@@ -140,9 +141,11 @@ public class HiveServiceValidatorTest extends EasyMockSupport {
   public void testShouldValidationPassWhenDefaultsAreUsedAndMsqlComponentIsListed() throws Exception {
     // GIVEN
     Collection<String> blueprintServices = Arrays.asList("HIVE", "HDFS", "MYSQL_SERVER");
+    Collection<String> hiveComponents = Arrays.asList("MYSQL_SERVER");
     Collection<String> configTypes = Arrays.asList("hive-env", "core-site", "hadoop-env");
     EasyMock.expect(clusterTopologyMock.getBlueprint()).andReturn(blueprintMock).anyTimes();
     EasyMock.expect(blueprintMock.getServices()).andReturn(blueprintServices).anyTimes();
+    EasyMock.expect(blueprintMock.getComponents("HIVE")).andReturn(hiveComponents).anyTimes();
     EasyMock.expect(clusterTopologyMock.getConfiguration()).andReturn(configurationMock);
     EasyMock.expect(configurationMock.getAllConfigTypes()).andReturn(configTypes);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9cda4f1/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidatorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidatorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidatorTest.java
new file mode 100644
index 0000000..4a70448
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidatorTest.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.topology.validators;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.ambari.server.controller.internal.Stack;
+import org.apache.ambari.server.topology.Blueprint;
+import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.Configuration;
+import org.apache.ambari.server.topology.InvalidTopologyException;
+import org.easymock.EasyMock;
+import org.easymock.EasyMockRule;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
+import org.easymock.TestSubject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class StackConfigTypeValidatorTest extends EasyMockSupport {
+
+  @Rule
+  public EasyMockRule mocks = new EasyMockRule(this);
+
+  @Mock
+  private Configuration clusterConfigurationMock;
+
+  @Mock
+  private Configuration stackConfigurationMock;
+
+  @Mock
+  private Blueprint blueprintMock;
+
+  @Mock
+  private Stack stackMock;
+
+  @Mock
+  private ClusterTopology clusterTopologyMock;
+
+  private Set<String> clusterRequestConfigTypes;
+
+  @TestSubject
+  private StackConfigTypeValidator stackConfigTypeValidator = new StackConfigTypeValidator();
+
+  @Before
+  public void before() {
+    EasyMock.expect(clusterTopologyMock.getConfiguration()).andReturn(clusterConfigurationMock).anyTimes();
+    EasyMock.expect(clusterTopologyMock.getBlueprint()).andReturn(blueprintMock).anyTimes();
+
+    EasyMock.expect(blueprintMock.getStack()).andReturn(stackMock).anyTimes();
+  }
+
+  @After
+  public void after() {
+    resetAll();
+  }
+
+
+  @Test(expected = InvalidTopologyException.class)
+  public void testShouldValidationFailWhenUnknownConfigTypeComesIn() throws Exception {
+    // GIVEN
+    EasyMock.expect(stackMock.getConfiguration()).andReturn(stackConfigurationMock);
+    EasyMock.expect(stackConfigurationMock.getAllConfigTypes()).andReturn(new HashSet<>(Arrays.asList("core-site", "yarn-site")));
+    EasyMock.expect(clusterConfigurationMock.getAllConfigTypes()).andReturn(new HashSet<>(Arrays.asList("invalid-site")));
+
+    replayAll();
+
+    // WHEN
+    stackConfigTypeValidator.validate(clusterTopologyMock);
+
+    // THEN
+    // exception is thrown
+
+  }
+
+  @Test
+  public void testShouldValidationPassifNoConfigTypesomeIn() throws Exception {
+    // GIVEN
+    EasyMock.expect(stackMock.getConfiguration()).andReturn(stackConfigurationMock);
+    EasyMock.expect(stackConfigurationMock.getAllConfigTypes()).andReturn(new HashSet<>(Arrays.asList("core-site", "yarn-site")));
+    EasyMock.expect(clusterConfigurationMock.getAllConfigTypes()).andReturn(new HashSet<>(Collections.<String>emptyList()));
+
+    replayAll();
+
+    // WHEN
+    stackConfigTypeValidator.validate(clusterTopologyMock);
+
+    // THEN
+    // no exception is thrown
+
+  }
+
+  @Test(expected = InvalidTopologyException.class)
+  public void testShouldValidationFailIfMultipleInvalidConfigTypesComeIn() throws Exception {
+    // GIVEN
+    EasyMock.expect(stackMock.getConfiguration()).andReturn(stackConfigurationMock);
+    EasyMock.expect(stackConfigurationMock.getAllConfigTypes()).andReturn(new HashSet<>(Arrays.asList("core-site", "yarn-site")));
+    EasyMock.expect(clusterConfigurationMock.getAllConfigTypes()).andReturn(new HashSet<>(Arrays.asList("invalid-site-1", "invalid-default")));
+
+    replayAll();
+
+    // WHEN
+    stackConfigTypeValidator.validate(clusterTopologyMock);
+
+    // THEN
+    // no exception is thrown
+
+  }
+}
\ No newline at end of file


Mime
View raw message