private void testSuccessDeleteResources(Authentication authentication, State hostComponentState) throws Exception {
    Resource.Type type = Resource.Type.Component;

    AmbariManagementController managementController = createMock(AmbariManagementController.class);
    MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);

    Clusters clusters = createNiceMock(Clusters.class);
    Cluster cluster = createNiceMock(Cluster.class);
    Service service = createNiceMock(Service.class);
    AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
    ServiceComponent serviceComponent = createNiceMock(ServiceComponent.class);
    ServiceComponentHost serviceComponentHost = createNiceMock(ServiceComponentHost.class);
    StackId stackId = createNiceMock(StackId.class);

    Map<String, ServiceComponentHost> serviceComponentHosts = new HashMap<>();
    serviceComponentHosts.put("", serviceComponentHost);

    expect(managementController.getClusters()).andReturn(clusters);
    expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo);

    expect(clusters.getCluster(CLUSTER_NAME)).andReturn(cluster);
    expect(cluster.getService(SERVICE_NAME)).andReturn(service);
    expect(cluster.getClusterId()).andReturn(CLUSTER_ID).anyTimes();

    expect(service.getServiceComponent("Component100")).andReturn(serviceComponent);

    expect(serviceComponent.getDesiredState()).andReturn(State.STARTED);
    expect(serviceComponent.getServiceComponentHosts()).andReturn(serviceComponentHosts).anyTimes();

    expect(serviceComponentHost.getDesiredState()).andReturn(hostComponentState);


    service.deleteServiceComponent(eq("Component100"), anyObject(DeleteHostComponentStatusMetaData.class));
    expectLastCall().once();
    // replay

    replay(managementController, clusters, cluster, service, stackId, ambariMetaInfo,
           serviceComponent, serviceComponentHost, maintenanceStateHelper);

    SecurityContextHolder.getContext().setAuthentication(authentication);

    ResourceProvider provider = getComponentProvider(managementController,
        maintenanceStateHelper);

    AbstractResourceProviderTest.TestObserver observer = new AbstractResourceProviderTest.TestObserver();

    ((ObservableResourceProvider)provider).addObserver(observer);


    Predicate predicate = new PredicateBuilder()
                .property(ComponentResourceProvider.CLUSTER_NAME)
                .equals("Cluster100")
                .and()
                .property(ComponentResourceProvider.SERVICE_NAME)
                .equals("Service100")
                .and()
                .property(ComponentResourceProvider.COMPONENT_NAME)
                .equals("Component100").toPredicate();

    provider.deleteResources(new RequestImpl(null, null, null, null), predicate);

    // verify
    verify(managementController, service);
  }
Tests for the component resource provider.
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java