@Test
public void testDeleteRequestSchedule() throws Exception {

  AmbariManagementController managementController = createMock(AmbariManagementController.class);
  Clusters clusters = createNiceMock(Clusters.class);
  Cluster cluster = createNiceMock(Cluster.class);
  RequestExecution requestExecution = createNiceMock(RequestExecution.class);
  ExecutionScheduleManager executionScheduleManager = createNiceMock
    (ExecutionScheduleManager.class);
  Map<Long, RequestExecution> requestExecutionMap = new HashMap<Long,
    RequestExecution>();
  requestExecutionMap.put(1L, requestExecution);
  expect(managementController.getAuthName()).andReturn("admin").anyTimes();
  expect(managementController.getClusters()).andReturn(clusters).anyTimes();
  expect(managementController.getExecutionScheduleManager()).andReturn
    (executionScheduleManager).anyTimes();
  expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
  expect(cluster.getAllRequestExecutions()).andReturn(requestExecutionMap);
  replay(managementController, clusters, cluster, executionScheduleManager,
    requestExecution );
  RequestScheduleResourceProvider resourceProvider = getResourceProvider
    (managementController);
  AbstractResourceProviderTest.TestObserver observer = new AbstractResourceProviderTest.TestObserver();
  ((ObservableResourceProvider) resourceProvider).addObserver(observer);
  Predicate predicate = new PredicateBuilder().property
    (RequestScheduleResourceProvider.REQUEST_SCHEDULE_CLUSTER_NAME_PROPERTY_ID)
    .equals("Cluster100").and().property(RequestScheduleResourceProvider
      .REQUEST_SCHEDULE_ID_PROPERTY_ID).equals(1L).toPredicate();
  resourceProvider.deleteResources(new RequestImpl(null, null, null, null), predicate);
  ResourceProviderEvent lastEvent = observer.getLastEvent();
  Assert.assertNotNull(lastEvent);
  Assert.assertEquals(Resource.Type.RequestSchedule, lastEvent.getResourceType());
  Assert.assertEquals(ResourceProviderEvent.Type.Delete, lastEvent.getType());
  Assert.assertEquals(predicate, lastEvent.getPredicate());
  Assert.assertNull(lastEvent.getRequest());
  verify(managementController, clusters, cluster, executionScheduleManager,
    requestExecution);
}