@Test
public void testGetResources() throws Exception {
Resource.Type type = Resource.Type.HostComponent;
AmbariManagementController managementController = createMock(AmbariManagementController.class);
Set<ServiceComponentHostResponse> allResponse = new HashSet<ServiceComponentHostResponse>();
StackId stackId = new StackId("HDP-0.1");
StackId stackId2 = new StackId("HDP-0.2");
allResponse.add(new ServiceComponentHostResponse(
"Cluster100", "Service100", "Component100", "Host100", null, null, State.INSTALLED.toString(),
stackId.getStackId(), State.STARTED.toString(),
stackId2.getStackId()));
allResponse.add(new ServiceComponentHostResponse(
"Cluster100", "Service100", "Component101", "Host100", null, null, State.INSTALLED.toString(),
stackId.getStackId(), State.STARTED.toString(),
stackId2.getStackId()));
allResponse.add(new ServiceComponentHostResponse(
"Cluster100", "Service100", "Component102", "Host100", null, null, State.INSTALLED.toString(),
stackId.getStackId(), State.STARTED.toString(),
stackId2.getStackId()));
Map<String, String> expectedNameValues = new HashMap<String, String>();
expectedNameValues.put(
HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
expectedNameValues.put(
HostComponentResourceProvider.HOST_COMPONENT_STATE_PROPERTY_ID, State.INSTALLED.toString());
expectedNameValues.put(
HostComponentResourceProvider.HOST_COMPONENT_STACK_ID_PROPERTY_ID, stackId.getStackId());
expectedNameValues.put(
HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID, State.STARTED.toString());
expectedNameValues.put(
HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STACK_ID_PROPERTY_ID, stackId2.getStackId());
// set expectations
expect(managementController.getHostComponents(
AbstractResourceProviderTest.Matcher.getHostComponentRequestSet(
"Cluster100", null, null, null, null, null))).andReturn(allResponse).once();
// replay
replay(managementController);