TargetClusterResourceProvider extends AbstractDRResourceProvider { @Override public RequestStatus createResources(Request request) throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException { IvoryService service = getService(); Set<Map<String, Object>> propertiesSet = request.getProperties(); for(Map<String, Object> propertyMap : propertiesSet) { service.submitCluster(getCluster((String) propertyMap.get(CLUSTER_NAME_PROPERTY_ID), propertyMap)); } 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);  }
@Test public void testCreateResources() throws Exception { IvoryService service = createMock(IvoryService.class); Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>(); Map<String, Object> properties = new HashMap<String, Object>(); properties.put(TargetClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster1"); properties.put(TargetClusterResourceProvider.CLUSTER_COLO_PROPERTY_ID, "Colo"); properties.put(TargetClusterResourceProvider.CLUSTER_INTERFACES_PROPERTY_ID, Collections.singleton(interfaces)); properties.put(TargetClusterResourceProvider.CLUSTER_LOCATIONS_PROPERTY_ID, Collections.singleton(locations)); properties.put(TargetClusterResourceProvider.CLUSTER_PROPERTIES_PROPERTY_ID, Collections.singletonMap("P1", "V1")); service.submitCluster(TargetClusterResourceProvider.getCluster("Cluster1", properties)); replay(service); propertySet.add(properties); Request request = PropertyHelper.getCreateRequest(propertySet, Collections.<String,String>emptyMap()); TargetClusterResourceProvider provider = new TargetClusterResourceProvider(service, PropertyHelper.getPropertyIds(Resource.Type.DRTargetCluster), PropertyHelper.getKeyPropertyIds(Resource.Type.DRTargetCluster)); provider.createResources(request); verify(service); }