@Test public void testDeleteResources() throws Exception { IvoryService service = createMock(IvoryService.class); List<String> targetClusterNames = new LinkedList<String>(); targetClusterNames.add("Cluster1"); Cluster.Interface interface1 = new Cluster.Interface("type", "endpoint", "version"); Cluster.Location location1 = new Cluster.Location("name", "path"); Cluster targetCluster1 = new Cluster("Cluster1", "Colo", Collections.singleton(interface1), Collections.singleton(location1), Collections.singletonMap("P1", "V1")); expect(service.getClusterNames()).andReturn(targetClusterNames); expect(service.getCluster("Cluster1")).andReturn(targetCluster1); service.deleteCluster("Cluster1"); replay(service); TargetClusterResourceProvider provider = new TargetClusterResourceProvider(service, PropertyHelper.getPropertyIds(Resource.Type.DRTargetCluster), PropertyHelper.getKeyPropertyIds(Resource.Type.DRTargetCluster)); Predicate predicate = new PredicateBuilder().property(TargetClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID).equals("Cluster1").toPredicate(); provider.deleteResources(new RequestImpl(null, null, null, null), predicate); verify(service); }
@Override public RequestStatus deleteResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { IvoryService service = getService(); Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate); for (Resource resource : resources) { service.deleteCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID)); } return new RequestStatusImpl(null); }
TargetClusterResourceProvider extends AbstractDRResourceProvider { @Override public RequestStatus deleteResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { IvoryService service = getService(); Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate); for (Resource resource : resources) { service.deleteCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID)); } return new RequestStatusImpl(null); } }
TargetClusterResourceProvider extends AbstractDRResourceProvider { @Override public RequestStatus deleteResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { IvoryService service = getService(); Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate); for (Resource resource : resources) { service.deleteCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID)); } return new RequestStatusImpl(null); } TargetClusterResourceProvider(IvoryService ivoryService,
                                       Set<String> propertyIds,
                                       Map<Resource.Type, String> keyPropertyIds); }
TargetClusterResourceProvider extends AbstractDRResourceProvider { @Override public RequestStatus deleteResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { IvoryService service = getService(); Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate); for (Resource resource : resources) { service.deleteCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID)); } return new RequestStatusImpl(null); } TargetClusterResourceProvider(IvoryService ivoryService,
                                       Set<String> propertyIds,
                                       Map<Resource.Type, String> keyPropertyIds); @Override RequestStatus createResources(Request request); @Override Set<Resource> getResources(Request request, Predicate predicate); @Override RequestStatus updateResources(Request request, Predicate predicate); @Override RequestStatus deleteResources(Request request, Predicate predicate); }
TargetClusterResourceProvider extends AbstractDRResourceProvider { @Override public RequestStatus deleteResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { IvoryService service = getService(); Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate); for (Resource resource : resources) { service.deleteCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID)); } return new RequestStatusImpl(null); } TargetClusterResourceProvider(IvoryService ivoryService,
                                       Set<String> propertyIds,
                                       Map<Resource.Type, String> keyPropertyIds); @Override RequestStatus createResources(Request request); @Override Set<Resource> getResources(Request request, Predicate predicate); @Override RequestStatus updateResources(Request request, Predicate predicate); @Override RequestStatus deleteResources(Request request, Predicate predicate);  }