|
@@ -36,6 +36,7 @@ import org.apache.ambari.server.actionmanager.ActionDBAccessorImpl;
|
|
|
import org.apache.ambari.server.actionmanager.ActionManager;
|
|
|
import org.apache.ambari.server.api.services.AmbariMetaInfo;
|
|
|
import org.apache.ambari.server.configuration.Configuration;
|
|
|
+import org.apache.ambari.server.controller.spi.Resource;
|
|
|
import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
|
|
|
import org.apache.ambari.server.orm.entities.LdapSyncSpecEntity;
|
|
|
import org.apache.ambari.server.security.authorization.Users;
|
|
@@ -43,11 +44,13 @@ import org.apache.ambari.server.security.ldap.AmbariLdapDataPopulator;
|
|
|
import org.apache.ambari.server.security.ldap.LdapBatchDto;
|
|
|
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.Host;
|
|
|
import org.apache.ambari.server.state.MaintenanceState;
|
|
|
import org.apache.ambari.server.state.Service;
|
|
|
import org.apache.ambari.server.state.ServiceComponent;
|
|
|
import org.apache.ambari.server.state.ServiceComponentHost;
|
|
|
+import org.apache.ambari.server.state.ServiceComponentImpl;
|
|
|
import org.apache.ambari.server.state.ServiceInfo;
|
|
|
import org.apache.ambari.server.state.ServiceOsSpecific;
|
|
|
import org.apache.ambari.server.state.StackId;
|
|
@@ -83,6 +86,8 @@ import static org.easymock.EasyMock.replay;
|
|
|
import static org.easymock.EasyMock.reset;
|
|
|
import static org.easymock.EasyMock.verify;
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
+import static org.junit.Assert.assertNotNull;
|
|
|
+import static org.junit.Assert.assertNull;
|
|
|
import static org.junit.Assert.assertSame;
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
import static org.junit.Assert.fail;
|
|
@@ -175,7 +180,6 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
|
|
|
ClusterRequest request1 = new ClusterRequest(null, "cluster1", "1", Collections.<String>emptySet());
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
@@ -208,6 +212,181 @@ public class AmbariManagementControllerImplTest {
|
|
|
verify(injector, clusters, cluster, response);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testGetClientHostForRunningAction_componentIsNull() throws Exception {
|
|
|
+ Injector injector = createNiceMock(Injector.class);
|
|
|
+
|
|
|
+ Cluster cluster = createNiceMock(Cluster.class);
|
|
|
+ Service service = createNiceMock(Service.class);
|
|
|
+ ServiceComponent component = null;
|
|
|
+
|
|
|
+ replay(cluster, service, injector);
|
|
|
+
|
|
|
+ AmbariManagementControllerImpl controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
+ String host = controller.getClientHostForRunningAction(cluster, service, component);
|
|
|
+
|
|
|
+ assertNull(host);
|
|
|
+ verify(cluster, service, injector);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testGetClientHostForRunningAction_componentMapIsEmpty() throws Exception {
|
|
|
+ Injector injector = createNiceMock(Injector.class);
|
|
|
+
|
|
|
+ Cluster cluster = createNiceMock(Cluster.class);
|
|
|
+ Service service = createNiceMock(Service.class);
|
|
|
+ ServiceComponent component = createNiceMock(ServiceComponent.class);
|
|
|
+ Map<String, ServiceComponentHost> hostMap = new HashMap<String, ServiceComponentHost>();
|
|
|
+ expect(component.getServiceComponentHosts()).andReturn(hostMap);
|
|
|
+
|
|
|
+ replay(cluster, service, component, injector);
|
|
|
+
|
|
|
+ AmbariManagementControllerImpl controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
+ String host = controller.getClientHostForRunningAction(cluster, service, component);
|
|
|
+
|
|
|
+ verify(cluster, service, component, injector);
|
|
|
+ assertNull(host);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testGetClientHostForRunningAction_returnsHelathyHost() throws Exception {
|
|
|
+ Injector injector = createNiceMock(Injector.class);
|
|
|
+ ActionManager actionManager = createNiceMock(ActionManager.class);
|
|
|
+
|
|
|
+ Cluster cluster = createNiceMock(Cluster.class);
|
|
|
+ Service service = createNiceMock(Service.class);
|
|
|
+ ServiceComponent component = createNiceMock(ServiceComponent.class);
|
|
|
+ Map<String, ServiceComponentHost> hostMap = createNiceMock(Map.class);
|
|
|
+ Set<String> hostsSet = createNiceMock(Set.class);
|
|
|
+ expect(hostMap.isEmpty()).andReturn(false);
|
|
|
+ expect(hostMap.keySet()).andReturn(hostsSet);
|
|
|
+ expect(component.getServiceComponentHosts()).andReturn(hostMap).times(2);
|
|
|
+
|
|
|
+ replay(cluster, service, component, injector, actionManager, hostMap, hostsSet);
|
|
|
+
|
|
|
+ AmbariManagementControllerImpl controller = createMockBuilder(AmbariManagementControllerImpl.class)
|
|
|
+ .addMockedMethod("filterHostsForAction")
|
|
|
+ .addMockedMethod("getHealthyHost")
|
|
|
+ .withConstructor(actionManager, clusters, injector)
|
|
|
+ .createMock();
|
|
|
+ expect(controller.getHealthyHost(hostsSet)).andReturn("healthy_host");
|
|
|
+ controller.filterHostsForAction(hostsSet, service, cluster, Resource.Type.Cluster);
|
|
|
+ expectLastCall().once();
|
|
|
+
|
|
|
+ replay(controller);
|
|
|
+ String host = controller.getClientHostForRunningAction(cluster, service, component);
|
|
|
+
|
|
|
+ assertEquals("healthy_host", host);
|
|
|
+ verify(controller, cluster, service, component, injector, hostMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testGetClientHostForRunningAction_clientComponent() throws Exception {
|
|
|
+ Injector injector = createNiceMock(Injector.class);
|
|
|
+ Cluster cluster = createNiceMock(Cluster.class);
|
|
|
+ Service service = createNiceMock(Service.class);
|
|
|
+ StackId stackId = createNiceMock(StackId.class);
|
|
|
+ ServiceComponent component = createNiceMock(ServiceComponent.class);
|
|
|
+
|
|
|
+ expect(service.getName()).andReturn("service");
|
|
|
+ expect(service.getServiceComponent("component")).andReturn(component);
|
|
|
+ expect(service.getDesiredStackVersion()).andReturn(stackId);
|
|
|
+ expect(stackId.getStackName()).andReturn("stack");
|
|
|
+ expect(stackId.getStackVersion()).andReturn("1.0");
|
|
|
+
|
|
|
+ ServiceInfo serviceInfo = createNiceMock(ServiceInfo.class);
|
|
|
+ ComponentInfo compInfo = createNiceMock(ComponentInfo.class);
|
|
|
+ expect(serviceInfo.getClientComponent()).andReturn(compInfo);
|
|
|
+ expect(compInfo.getName()).andReturn("component");
|
|
|
+ expect(ambariMetaInfo.getServiceInfo("stack", "1.0", "service")).andReturn(serviceInfo);
|
|
|
+
|
|
|
+ replay(injector, cluster, service, component, serviceInfo, compInfo, ambariMetaInfo, stackId);
|
|
|
+
|
|
|
+ AmbariManagementControllerImpl controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
+ ServiceComponent resultComponent = controller.getClientComponentForRunningAction(cluster, service);
|
|
|
+
|
|
|
+ assertNotNull(resultComponent);
|
|
|
+ assertEquals(component, resultComponent);
|
|
|
+ verify(injector, cluster, service, component, serviceInfo, compInfo, ambariMetaInfo, stackId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testGetClientHostForRunningAction_clientComponentThrowsException() throws Exception {
|
|
|
+ Injector injector = createNiceMock(Injector.class);
|
|
|
+ Cluster cluster = createNiceMock(Cluster.class);
|
|
|
+ Service service = createNiceMock(Service.class);
|
|
|
+ StackId stackId = createNiceMock(StackId.class);
|
|
|
+ ServiceComponent component1 = createNiceMock(ServiceComponent.class);
|
|
|
+ ServiceComponent component2 = createNiceMock(ServiceComponent.class);
|
|
|
+
|
|
|
+ expect(service.getName()).andReturn("service");
|
|
|
+ expect(service.getServiceComponent("component")).andThrow(
|
|
|
+ new ServiceComponentNotFoundException("cluster", "service", "component"));
|
|
|
+ expect(service.getDesiredStackVersion()).andReturn(stackId);
|
|
|
+ expect(stackId.getStackName()).andReturn("stack");
|
|
|
+ expect(stackId.getStackVersion()).andReturn("1.0");
|
|
|
+ Map<String, ServiceComponent> componentsMap = new HashMap<String, ServiceComponent>();
|
|
|
+ componentsMap.put("component1", component1);
|
|
|
+ componentsMap.put("component2", component2);
|
|
|
+ expect(service.getServiceComponents()).andReturn(componentsMap);
|
|
|
+ expect(component1.getServiceComponentHosts()).andReturn(Collections.EMPTY_MAP);
|
|
|
+ expect(component2.getServiceComponentHosts()).andReturn(
|
|
|
+ Collections.<String, ServiceComponentHost>singletonMap("anyHost", null));
|
|
|
+
|
|
|
+ ServiceInfo serviceInfo = createNiceMock(ServiceInfo.class);
|
|
|
+ ComponentInfo compInfo = createNiceMock(ComponentInfo.class);
|
|
|
+ expect(serviceInfo.getClientComponent()).andReturn(compInfo);
|
|
|
+ expect(compInfo.getName()).andReturn("component");
|
|
|
+ expect(ambariMetaInfo.getServiceInfo("stack", "1.0", "service")).andReturn(serviceInfo);
|
|
|
+
|
|
|
+ replay(injector, cluster, service, component1, component2, serviceInfo, compInfo, ambariMetaInfo, stackId);
|
|
|
+
|
|
|
+ AmbariManagementControllerImpl controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
+ ServiceComponent resultComponent = controller.getClientComponentForRunningAction(cluster, service);
|
|
|
+
|
|
|
+ assertNotNull(resultComponent);
|
|
|
+ assertEquals(component2, resultComponent);
|
|
|
+ verify(injector, cluster, service, component1, component2, serviceInfo, compInfo, ambariMetaInfo, stackId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testGetClientHostForRunningAction_noClientComponent() throws Exception {
|
|
|
+ Injector injector = createNiceMock(Injector.class);
|
|
|
+ Cluster cluster = createNiceMock(Cluster.class);
|
|
|
+ Service service = createNiceMock(Service.class);
|
|
|
+ StackId stackId = createNiceMock(StackId.class);
|
|
|
+ ServiceComponent component1 = createNiceMock(ServiceComponent.class);
|
|
|
+ ServiceComponent component2 = createNiceMock(ServiceComponent.class);
|
|
|
+
|
|
|
+ expect(service.getName()).andReturn("service");
|
|
|
+ expect(service.getDesiredStackVersion()).andReturn(stackId);
|
|
|
+ expect(stackId.getStackName()).andReturn("stack");
|
|
|
+ expect(stackId.getStackVersion()).andReturn("1.0");
|
|
|
+ Map<String, ServiceComponent> componentsMap = new HashMap<String, ServiceComponent>();
|
|
|
+ componentsMap.put("component1", component1);
|
|
|
+ componentsMap.put("component2", component2);
|
|
|
+ expect(service.getServiceComponents()).andReturn(componentsMap);
|
|
|
+ expect(component1.getServiceComponentHosts()).andReturn(Collections.EMPTY_MAP);
|
|
|
+ expect(component2.getServiceComponentHosts()).andReturn(
|
|
|
+ Collections.<String, ServiceComponentHost>singletonMap("anyHost", null));
|
|
|
+
|
|
|
+ ServiceInfo serviceInfo = createNiceMock(ServiceInfo.class);
|
|
|
+ expect(serviceInfo.getClientComponent()).andReturn(null);
|
|
|
+ expect(ambariMetaInfo.getServiceInfo("stack", "1.0", "service")).andReturn(serviceInfo);
|
|
|
+
|
|
|
+ replay(injector, cluster, service, component1, component2, serviceInfo, ambariMetaInfo, stackId);
|
|
|
+
|
|
|
+ AmbariManagementControllerImpl controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
+ ServiceComponent resultComponent = controller.getClientComponentForRunningAction(cluster, service);
|
|
|
+
|
|
|
+ assertNotNull(resultComponent);
|
|
|
+ assertEquals(component2, resultComponent);
|
|
|
+ verify(injector, cluster, service, component1, component2, serviceInfo, ambariMetaInfo, stackId);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Ensure that ClusterNotFoundException is propagated in case where there is a single request.
|
|
|
*/
|
|
@@ -216,7 +395,6 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
|
|
|
// requests
|
|
|
ClusterRequest request1 = new ClusterRequest(null, "cluster1", "1", Collections.<String>emptySet());
|
|
@@ -259,7 +437,6 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
Cluster cluster2 = createNiceMock(Cluster.class);
|
|
@@ -319,7 +496,6 @@ public class AmbariManagementControllerImplTest {
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
ActionManager actionManager = createNiceMock(ActionManager.class);
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
ClusterRequest clusterRequest = createNiceMock(ClusterRequest.class);
|
|
|
|
|
|
// requests
|
|
@@ -359,7 +535,6 @@ public class AmbariManagementControllerImplTest {
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
ActionManager actionManager = createNiceMock(ActionManager.class);
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
ClusterRequest clusterRequest = createNiceMock(ClusterRequest.class);
|
|
|
|
|
|
// requests
|
|
@@ -397,9 +572,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
StackId stack = createNiceMock(StackId.class);
|
|
|
- AmbariMetaInfo metaInfo = createStrictMock(AmbariMetaInfo.class);
|
|
|
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
final Host host = createNiceMock(Host.class);
|
|
@@ -435,7 +608,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(stack.getStackName()).andReturn("stackName");
|
|
|
expect(stack.getStackVersion()).andReturn("stackVersion");
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
expect(cluster.getService("service1")).andReturn(service);
|
|
|
expect(service.getServiceComponent("component1")).andReturn(component);
|
|
|
expect(component.getName()).andReturn("component1");
|
|
@@ -449,15 +622,11 @@ public class AmbariManagementControllerImplTest {
|
|
|
|
|
|
// replay mocks
|
|
|
replay(maintHelper, injector, clusters, cluster, host, response, stack,
|
|
|
- metaInfo, service, component, componentHost);
|
|
|
+ ambariMetaInfo, service, component, componentHost);
|
|
|
|
|
|
//test
|
|
|
AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
- //need to set private field 'ambariMetaInfo' which is injected at runtime
|
|
|
- Class<?> c = controller.getClass();
|
|
|
- Field f = c.getDeclaredField("ambariMetaInfo");
|
|
|
- f.setAccessible(true);
|
|
|
- f.set(controller, metaInfo);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
|
|
|
Set<ServiceComponentHostResponse> setResponses = controller.getHostComponents(setRequests);
|
|
|
|
|
@@ -466,7 +635,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
assertEquals(1, setResponses.size());
|
|
|
assertTrue(setResponses.contains(response));
|
|
|
|
|
|
- verify(injector, clusters, cluster, host, response, stack, metaInfo, service, component, componentHost);
|
|
|
+ verify(injector, clusters, cluster, host, response, stack, ambariMetaInfo, service, component, componentHost);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -474,9 +643,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
StackId stack = createNiceMock(StackId.class);
|
|
|
- AmbariMetaInfo metaInfo = createStrictMock(AmbariMetaInfo.class);
|
|
|
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
Host host = createNiceMock(Host.class);
|
|
@@ -506,23 +673,19 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(stack.getStackName()).andReturn("stackName");
|
|
|
expect(stack.getStackVersion()).andReturn("stackVersion");
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
expect(cluster.getService("service1")).andReturn(service);
|
|
|
expect(service.getServiceComponent("component1")).andReturn(component);
|
|
|
expect(component.getName()).andReturn("component1").anyTimes();
|
|
|
expect(component.getServiceComponentHosts()).andReturn(null);
|
|
|
|
|
|
// replay mocks
|
|
|
- replay(maintHelper, injector, clusters, cluster, host, stack, metaInfo,
|
|
|
+ replay(maintHelper, injector, clusters, cluster, host, stack, ambariMetaInfo,
|
|
|
service, component);
|
|
|
|
|
|
//test
|
|
|
AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
- //need to set private field 'ambariMetaInfo' which is injected at runtime
|
|
|
- Class<?> c = controller.getClass();
|
|
|
- Field f = c.getDeclaredField("ambariMetaInfo");
|
|
|
- f.setAccessible(true);
|
|
|
- f.set(controller, metaInfo);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
|
|
|
try {
|
|
|
controller.getHostComponents(setRequests);
|
|
@@ -533,7 +696,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
|
|
|
// assert and verify
|
|
|
assertSame(controller, controllerCapture.getValue());
|
|
|
- verify(injector, clusters, cluster, host, stack, metaInfo, service, component);
|
|
|
+ verify(injector, clusters, cluster, host, stack, ambariMetaInfo, service, component);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -541,9 +704,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
StackId stack = createNiceMock(StackId.class);
|
|
|
- AmbariMetaInfo metaInfo = createNiceMock(AmbariMetaInfo.class);
|
|
|
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
final Host host = createNiceMock(Host.class);
|
|
@@ -598,7 +759,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(stack.getStackName()).andReturn("stackName").anyTimes();
|
|
|
expect(stack.getStackVersion()).andReturn("stackVersion").anyTimes();
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
expect(service.getServiceComponent("component1")).andReturn(component);
|
|
|
expect(component.getName()).andReturn("component1");
|
|
|
expect(component.getServiceComponentHosts()).andReturn(
|
|
@@ -608,13 +769,13 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(componentHost1.convertToResponse()).andReturn(response1);
|
|
|
expect(componentHost1.getHostName()).andReturn("host1");
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component2")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component2")).andReturn("service1");
|
|
|
expect(service.getServiceComponent("component2")).andReturn(component2);
|
|
|
expect(component2.getName()).andReturn("component2");
|
|
|
expect(component2.getServiceComponentHosts()).andReturn(null);
|
|
|
expect(componentHost2.getHostName()).andReturn("host1");
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component3")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component3")).andReturn("service1");
|
|
|
expect(service.getServiceComponent("component3")).andReturn(component3);
|
|
|
expect(component3.getName()).andReturn("component3");
|
|
|
expect(component3.getServiceComponentHosts()).andReturn(
|
|
@@ -625,16 +786,12 @@ public class AmbariManagementControllerImplTest {
|
|
|
|
|
|
// replay mocks
|
|
|
replay(stateHelper, injector, clusters, cluster, host, stack,
|
|
|
- metaInfo, service, component, component2, component3, componentHost1,
|
|
|
+ ambariMetaInfo, service, component, component2, component3, componentHost1,
|
|
|
componentHost2, response1, response2);
|
|
|
|
|
|
//test
|
|
|
AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
- //need to set private field 'ambariMetaInfo' which is injected at runtime
|
|
|
- Class<?> c = controller.getClass();
|
|
|
- Field f = c.getDeclaredField("ambariMetaInfo");
|
|
|
- f.setAccessible(true);
|
|
|
- f.set(controller, metaInfo);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
|
|
|
Set<ServiceComponentHostResponse> setResponses = controller.getHostComponents(setRequests);
|
|
|
|
|
@@ -644,7 +801,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
assertTrue(setResponses.contains(response1));
|
|
|
assertTrue(setResponses.contains(response2));
|
|
|
|
|
|
- verify(injector, clusters, cluster, host, stack, metaInfo, service, component, component2, component3,
|
|
|
+ verify(injector, clusters, cluster, host, stack, ambariMetaInfo, service, component, component2, component3,
|
|
|
componentHost1, componentHost2, response1, response2);
|
|
|
}
|
|
|
|
|
@@ -653,9 +810,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
StackId stack = createNiceMock(StackId.class);
|
|
|
- AmbariMetaInfo metaInfo = createNiceMock(AmbariMetaInfo.class);
|
|
|
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
final Host host = createNiceMock(Host.class);
|
|
@@ -706,7 +861,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
put("host1", host);
|
|
|
}}).anyTimes();
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
expect(cluster.getService("service1")).andReturn(service);
|
|
|
expect(service.getServiceComponent("component1")).andReturn(component);
|
|
|
expect(component.getName()).andReturn("component1");
|
|
@@ -717,10 +872,10 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(componentHost1.convertToResponse()).andReturn(response1);
|
|
|
expect(componentHost1.getHostName()).andReturn("host1");
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component2")).andReturn("service2");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component2")).andReturn("service2");
|
|
|
expect(cluster.getService("service2")).andThrow(new ServiceNotFoundException("cluster1", "service2"));
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component3")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component3")).andReturn("service1");
|
|
|
expect(cluster.getService("service1")).andReturn(service);
|
|
|
expect(service.getServiceComponent("component3")).andReturn(component3);
|
|
|
expect(component3.getName()).andReturn("component3");
|
|
@@ -732,17 +887,13 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(componentHost2.getHostName()).andReturn("host1");
|
|
|
|
|
|
// replay mocks
|
|
|
- replay(maintHelper, injector, clusters, cluster, host, stack, metaInfo,
|
|
|
+ replay(maintHelper, injector, clusters, cluster, host, stack, ambariMetaInfo,
|
|
|
service, component, component2, component3, componentHost1,
|
|
|
componentHost2, response1, response2);
|
|
|
|
|
|
//test
|
|
|
AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
- //need to set private field 'ambariMetaInfo' which is injected at runtime
|
|
|
- Class<?> c = controller.getClass();
|
|
|
- Field f = c.getDeclaredField("ambariMetaInfo");
|
|
|
- f.setAccessible(true);
|
|
|
- f.set(controller, metaInfo);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
|
|
|
Set<ServiceComponentHostResponse> setResponses = controller.getHostComponents(setRequests);
|
|
|
|
|
@@ -752,7 +903,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
assertTrue(setResponses.contains(response1));
|
|
|
assertTrue(setResponses.contains(response2));
|
|
|
|
|
|
- verify(injector, clusters, cluster, host, stack, metaInfo, service, component, component2, component3,
|
|
|
+ verify(injector, clusters, cluster, host, stack, ambariMetaInfo, service, component, component2, component3,
|
|
|
componentHost1, componentHost2, response1, response2);
|
|
|
}
|
|
|
|
|
@@ -761,9 +912,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
StackId stack = createNiceMock(StackId.class);
|
|
|
- AmbariMetaInfo metaInfo = createNiceMock(AmbariMetaInfo.class);
|
|
|
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
final Host host = createNiceMock(Host.class);
|
|
@@ -817,7 +966,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(stack.getStackVersion()).andReturn("stackVersion").anyTimes();
|
|
|
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
expect(cluster.getService("service1")).andReturn(service);
|
|
|
expect(service.getServiceComponent("component1")).andReturn(component);
|
|
|
expect(component.getName()).andReturn("component1");
|
|
@@ -828,12 +977,12 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(componentHost1.convertToResponse()).andReturn(response1);
|
|
|
expect(componentHost1.getHostName()).andReturn("host1");
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component2")).andReturn("service2");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component2")).andReturn("service2");
|
|
|
expect(cluster.getService("service2")).andReturn(service2);
|
|
|
expect(service2.getServiceComponent("component2")).
|
|
|
andThrow(new ServiceComponentNotFoundException("cluster1", "service2", "component2"));
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component3")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component3")).andReturn("service1");
|
|
|
expect(cluster.getService("service1")).andReturn(service);
|
|
|
expect(service.getServiceComponent("component3")).andReturn(component3);
|
|
|
expect(component3.getName()).andReturn("component3");
|
|
@@ -845,17 +994,13 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(componentHost2.getHostName()).andReturn("host1");
|
|
|
|
|
|
// replay mocks
|
|
|
- replay(maintHelper, injector, clusters, cluster, host, stack, metaInfo,
|
|
|
+ replay(maintHelper, injector, clusters, cluster, host, stack, ambariMetaInfo,
|
|
|
service, service2, component, component2, component3, componentHost1,
|
|
|
componentHost2, response1, response2);
|
|
|
|
|
|
//test
|
|
|
AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
- //need to set private field 'ambariMetaInfo' which is injected at runtime
|
|
|
- Class<?> c = controller.getClass();
|
|
|
- Field f = c.getDeclaredField("ambariMetaInfo");
|
|
|
- f.setAccessible(true);
|
|
|
- f.set(controller, metaInfo);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
|
|
|
Set<ServiceComponentHostResponse> setResponses = controller.getHostComponents(setRequests);
|
|
|
|
|
@@ -865,7 +1010,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
assertTrue(setResponses.contains(response1));
|
|
|
assertTrue(setResponses.contains(response2));
|
|
|
|
|
|
- verify(injector, clusters, cluster, host, stack, metaInfo, service, service2, component, component2, component3,
|
|
|
+ verify(injector, clusters, cluster, host, stack, ambariMetaInfo, service, service2, component, component2, component3,
|
|
|
componentHost1, componentHost2, response1, response2);
|
|
|
}
|
|
|
|
|
@@ -874,9 +1019,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
StackId stack = createNiceMock(StackId.class);
|
|
|
- AmbariMetaInfo metaInfo = createNiceMock(AmbariMetaInfo.class);
|
|
|
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
final Host host = createNiceMock(Host.class);
|
|
@@ -928,7 +1071,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(stack.getStackName()).andReturn("stackName").anyTimes();
|
|
|
expect(stack.getStackVersion()).andReturn("stackVersion").anyTimes();
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
expect(cluster.getService("service1")).andReturn(service);
|
|
|
expect(service.getServiceComponent("component1")).andReturn(component);
|
|
|
expect(component.getName()).andReturn("component1");
|
|
@@ -938,7 +1081,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
|
|
|
expect(clusters.getClustersForHost("host2")).andThrow(new HostNotFoundException("host2"));
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component3")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component3")).andReturn("service1");
|
|
|
expect(cluster.getService("service1")).andReturn(service);
|
|
|
expect(service.getServiceComponent("component3")).andReturn(component3);
|
|
|
expect(component3.getName()).andReturn("component3");
|
|
@@ -947,17 +1090,13 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(componentHost2.getHostName()).andReturn("host1");
|
|
|
|
|
|
// replay mocks
|
|
|
- replay(maintHelper, injector, clusters, cluster, host, stack, metaInfo,
|
|
|
+ replay(maintHelper, injector, clusters, cluster, host, stack, ambariMetaInfo,
|
|
|
service, service2, component, component2, component3, componentHost1,
|
|
|
componentHost2, response1, response2);
|
|
|
|
|
|
//test
|
|
|
AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
- //need to set private field 'ambariMetaInfo' which is injected at runtime
|
|
|
- Class<?> c = controller.getClass();
|
|
|
- Field f = c.getDeclaredField("ambariMetaInfo");
|
|
|
- f.setAccessible(true);
|
|
|
- f.set(controller, metaInfo);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
|
|
|
Set<ServiceComponentHostResponse> setResponses = controller.getHostComponents(setRequests);
|
|
|
Assert.assertNotNull(setResponses);
|
|
@@ -968,7 +1107,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
assertTrue(setResponses.contains(response1));
|
|
|
assertTrue(setResponses.contains(response2));
|
|
|
|
|
|
- verify(injector, clusters, cluster, host, stack, metaInfo, service, service2, component, component2, component3,
|
|
|
+ verify(injector, clusters, cluster, host, stack, ambariMetaInfo, service, service2, component, component2, component3,
|
|
|
componentHost1, componentHost2, response1, response2);
|
|
|
}
|
|
|
|
|
@@ -977,9 +1116,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
StackId stack = createNiceMock(StackId.class);
|
|
|
- AmbariMetaInfo metaInfo = createNiceMock(AmbariMetaInfo.class);
|
|
|
MaintenanceStateHelper maintHelper = createNiceMock(MaintenanceStateHelper.class);
|
|
|
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
@@ -1011,15 +1148,11 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(clusters.getClustersForHost("host1")).andThrow(new HostNotFoundException("host1"));
|
|
|
|
|
|
// replay mocks
|
|
|
- replay(maintHelper, injector, clusters, cluster, stack, metaInfo);
|
|
|
+ replay(maintHelper, injector, clusters, cluster, stack, ambariMetaInfo);
|
|
|
|
|
|
//test
|
|
|
AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
- //need to set private field 'ambariMetaInfo' which is injected at runtime
|
|
|
- Class<?> c = controller.getClass();
|
|
|
- Field f = c.getDeclaredField("ambariMetaInfo");
|
|
|
- f.setAccessible(true);
|
|
|
- f.set(controller, metaInfo);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
|
|
|
try {
|
|
|
controller.getHostComponents(setRequests);
|
|
@@ -1031,7 +1164,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// assert and verify
|
|
|
assertSame(controller, controllerCapture.getValue());
|
|
|
|
|
|
- verify(injector, clusters, cluster, stack, metaInfo);
|
|
|
+ verify(injector, clusters, cluster, stack, ambariMetaInfo);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -1039,9 +1172,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
StackId stack = createNiceMock(StackId.class);
|
|
|
- AmbariMetaInfo metaInfo = createNiceMock(AmbariMetaInfo.class);
|
|
|
MaintenanceStateHelper maintHelper = createNiceMock(MaintenanceStateHelper.class);
|
|
|
|
|
|
// requests
|
|
@@ -1070,15 +1201,11 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(clusters.getCluster("cluster1")).andThrow(new ClusterNotFoundException("cluster1"));
|
|
|
|
|
|
// replay mocks
|
|
|
- replay(maintHelper, injector, clusters, stack, metaInfo);
|
|
|
+ replay(maintHelper, injector, clusters, stack, ambariMetaInfo);
|
|
|
|
|
|
//test
|
|
|
AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
- //need to set private field 'ambariMetaInfo' which is injected at runtime
|
|
|
- Class<?> c = controller.getClass();
|
|
|
- Field f = c.getDeclaredField("ambariMetaInfo");
|
|
|
- f.setAccessible(true);
|
|
|
- f.set(controller, metaInfo);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
|
|
|
try {
|
|
|
controller.getHostComponents(setRequests);
|
|
@@ -1090,7 +1217,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// assert and verify
|
|
|
assertSame(controller, controllerCapture.getValue());
|
|
|
|
|
|
- verify(injector, clusters,stack, metaInfo);
|
|
|
+ verify(injector, clusters,stack, ambariMetaInfo);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -1098,9 +1225,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
StackId stack = createNiceMock(StackId.class);
|
|
|
- AmbariMetaInfo metaInfo = createStrictMock(AmbariMetaInfo.class);
|
|
|
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
Service service = createNiceMock(Service.class);
|
|
@@ -1143,7 +1268,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
expect(stack.getStackName()).andReturn("stackName");
|
|
|
expect(stack.getStackVersion()).andReturn("stackVersion");
|
|
|
|
|
|
- expect(metaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
+ expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component1")).andReturn("service1");
|
|
|
expect(cluster.getService("service1")).andReturn(service);
|
|
|
expect(service.getServiceComponent("component1")).andReturn(component);
|
|
|
expect(component.getName()).andReturn("component1").anyTimes();
|
|
@@ -1156,15 +1281,11 @@ public class AmbariManagementControllerImplTest {
|
|
|
|
|
|
// replay mocks
|
|
|
replay(maintHelper, injector, clusters, cluster, response1, response2,
|
|
|
- stack, metaInfo, service, component, componentHost1, componentHost2);
|
|
|
+ stack, ambariMetaInfo, service, component, componentHost1, componentHost2);
|
|
|
|
|
|
//test
|
|
|
AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
- //need to set private field 'ambariMetaInfo' which is injected at runtime
|
|
|
- Class<?> c = controller.getClass();
|
|
|
- Field f = c.getDeclaredField("ambariMetaInfo");
|
|
|
- f.setAccessible(true);
|
|
|
- f.set(controller, metaInfo);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
|
|
|
Set<ServiceComponentHostResponse> setResponses = controller.getHostComponents(setRequests);
|
|
|
|
|
@@ -1174,7 +1295,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
assertTrue(setResponses.contains(response1));
|
|
|
assertTrue(setResponses.contains(response2));
|
|
|
|
|
|
- verify(injector, clusters, cluster, response1, response2, stack, metaInfo, service, component, componentHost1, componentHost2);
|
|
|
+ verify(injector, clusters, cluster, response1, response2, stack, ambariMetaInfo, service, component, componentHost1, componentHost2);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -1182,9 +1303,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
// member state mocks
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
StackId stack = createNiceMock(StackId.class);
|
|
|
- AmbariMetaInfo metaInfo = createStrictMock(AmbariMetaInfo.class);
|
|
|
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
Service service1 = createNiceMock(Service.class);
|
|
@@ -1251,16 +1370,12 @@ public class AmbariManagementControllerImplTest {
|
|
|
|
|
|
// replay mocks
|
|
|
replay(maintHelper, injector, clusters, cluster, response1, response2,
|
|
|
- response3, stack, metaInfo, service1, service2, component1, component2,
|
|
|
+ response3, stack, ambariMetaInfo, service1, service2, component1, component2,
|
|
|
componentHost1, componentHost2, componentHost3);
|
|
|
|
|
|
//test
|
|
|
AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
|
|
|
- //need to set private field 'ambariMetaInfo' which is injected at runtime
|
|
|
- Class<?> c = controller.getClass();
|
|
|
- Field f = c.getDeclaredField("ambariMetaInfo");
|
|
|
- f.setAccessible(true);
|
|
|
- f.set(controller, metaInfo);
|
|
|
+ setAmbariMetaInfo(ambariMetaInfo, controller);
|
|
|
|
|
|
Set<ServiceComponentHostResponse> setResponses = controller.getHostComponents(setRequests);
|
|
|
|
|
@@ -1271,7 +1386,7 @@ public class AmbariManagementControllerImplTest {
|
|
|
assertTrue(setResponses.contains(response2));
|
|
|
assertTrue(setResponses.contains(response3));
|
|
|
|
|
|
- verify(injector, clusters, cluster, response1, response2, response3, stack, metaInfo, service1, service2,
|
|
|
+ verify(injector, clusters, cluster, response1, response2, response3, stack, ambariMetaInfo, service1, service2,
|
|
|
component1, component2, componentHost1, componentHost2, componentHost3);
|
|
|
}
|
|
|
|
|
@@ -1280,7 +1395,6 @@ public class AmbariManagementControllerImplTest {
|
|
|
Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
|
|
|
Injector injector = createStrictMock(Injector.class);
|
|
|
MaintenanceStateHelper maintHelper = createNiceMock(MaintenanceStateHelper.class);
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
|
|
|
ServiceInfo serviceInfo = createNiceMock(ServiceInfo.class);
|
|
|
Map<String, String> hostParams = new HashMap<String, String>();
|
|
@@ -1336,7 +1450,6 @@ public class AmbariManagementControllerImplTest {
|
|
|
String SERVER_DB_NAME = "ServerDBName";
|
|
|
|
|
|
ActionManager manager = createNiceMock(ActionManager.class);
|
|
|
- Clusters clusters = createNiceMock(Clusters.class);
|
|
|
StackId stackId = createNiceMock(StackId.class);
|
|
|
Cluster cluster = createNiceMock(Cluster.class);
|
|
|
Injector injector = createNiceMock(Injector.class);
|
|
@@ -1432,6 +1545,14 @@ public class AmbariManagementControllerImplTest {
|
|
|
verify(ldapDataPopulator, clusters, users, ldapBatchDto);
|
|
|
}
|
|
|
|
|
|
+ private void setAmbariMetaInfo(AmbariMetaInfo metaInfo, AmbariManagementController controller) throws NoSuchFieldException, IllegalAccessException {
|
|
|
+ //need to set private field 'ambariMetaInfo' which is injected at runtime
|
|
|
+ Class<?> c = controller.getClass();
|
|
|
+ Field f = c.getDeclaredField("ambariMetaInfo");
|
|
|
+ f.setAccessible(true);
|
|
|
+ f.set(controller, metaInfo);
|
|
|
+ }
|
|
|
+
|
|
|
private class MockModule implements Module {
|
|
|
|
|
|
@Override
|