public static ComponentResourceProvider getComponentProvider(
      AmbariManagementController managementController,
      MaintenanceStateHelper maintenanceStateHelper)
      throws NoSuchFieldException, IllegalAccessException {
    ComponentResourceProvider provider = new ComponentResourceProvider(managementController,
        maintenanceStateHelper);

    Field STOMPComponentsDeleteHandlerField = ComponentResourceProvider.class.getDeclaredField("STOMPComponentsDeleteHandler");
    STOMPComponentsDeleteHandlerField.setAccessible(true);
    STOMPComponentsDeleteHandler STOMPComponentsDeleteHandler = new STOMPComponentsDeleteHandler();
    STOMPComponentsDeleteHandlerField.set(provider, STOMPComponentsDeleteHandler);

    Field topologyHolderProviderField = STOMPComponentsDeleteHandler.class.getDeclaredField("m_topologyHolder");
    topologyHolderProviderField.setAccessible(true);
    Provider<TopologyHolder> m_topologyHolder = createMock(Provider.class);
    topologyHolderProviderField.set(STOMPComponentsDeleteHandler, m_topologyHolder);

    TopologyHolder topologyHolder = createNiceMock(TopologyHolder.class);

    expect(m_topologyHolder.get()).andReturn(topologyHolder).anyTimes();

    Field metadataHolderProviderField = STOMPComponentsDeleteHandler.class.getDeclaredField("metadataHolder");
    metadataHolderProviderField.setAccessible(true);
    Provider<MetadataHolder> m_metadataHolder = createMock(Provider.class);
    metadataHolderProviderField.set(STOMPComponentsDeleteHandler, m_metadataHolder);

    MetadataHolder metadataHolder = createNiceMock(MetadataHolder.class);

    expect(m_metadataHolder.get()).andReturn(metadataHolder).anyTimes();

    replay(m_metadataHolder, metadataHolder, m_topologyHolder, topologyHolder);
    return provider;
  }
Tests for the component resource provider.
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java