@Test public void testUpdateResources() 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 + "/P1", "V1"); List<String> targetClusterNames = new LinkedList<String>(); targetClusterNames.add("Cluster1"); Set<Cluster.Interface> interfaceSet = Collections.singleton(interface1); Set<Cluster.Location> locationSet = Collections.singleton(location1); Cluster targetCluster1 = new Cluster("Cluster1", "Colo", interfaceSet, locationSet, Collections.singletonMap("P1", "V1")); expect(service.getClusterNames()).andReturn(targetClusterNames); expect(service.getCluster("Cluster1")).andReturn(targetCluster1); service.updateCluster(targetCluster1); 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.updateResources(request, null); verify(service); }
@Override public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { IvoryService service = getService(); Iterator<Map<String,Object>> iterator = request.getProperties().iterator(); if (iterator.hasNext()) { Map<String, Object> propertyMap = iterator.next(); Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate); for (Resource resource : resources) { service.updateCluster(getCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID), propertyMap)); } } return new RequestStatusImpl(null); }
TargetClusterResourceProvider extends AbstractDRResourceProvider { @Override public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { IvoryService service = getService(); Iterator<Map<String,Object>> iterator = request.getProperties().iterator(); if (iterator.hasNext()) { Map<String, Object> propertyMap = iterator.next(); Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate); for (Resource resource : resources) { service.updateCluster(getCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID), propertyMap)); } } return new RequestStatusImpl(null); } }
TargetClusterResourceProvider extends AbstractDRResourceProvider { @Override public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { IvoryService service = getService(); Iterator<Map<String,Object>> iterator = request.getProperties().iterator(); if (iterator.hasNext()) { Map<String, Object> propertyMap = iterator.next(); Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate); for (Resource resource : resources) { service.updateCluster(getCluster((String) resource.getPropertyValue(CLUSTER_NAME_PROPERTY_ID), propertyMap)); } } return new RequestStatusImpl(null); } TargetClusterResourceProvider(IvoryService ivoryService,
                                       Set<String> propertyIds,
                                       Map<Resource.Type, String> keyPropertyIds); }
TargetClusterResourceProvider extends AbstractDRResourceProvider { @Override public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { IvoryService service = getService(); Iterator<Map<String,Object>> iterator = request.getProperties().iterator(); if (iterator.hasNext()) { Map<String, Object> propertyMap = iterator.next(); Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate); for (Resource resource : resources) { service.updateCluster(getCluster((String) resource.getPropertyValue(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); }
TargetClusterResourceProvider extends AbstractDRResourceProvider { @Override public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { IvoryService service = getService(); Iterator<Map<String,Object>> iterator = request.getProperties().iterator(); if (iterator.hasNext()) { Map<String, Object> propertyMap = iterator.next(); Set<Resource> resources = getResources(PropertyHelper.getReadRequest(), predicate); for (Resource resource : resources) { service.updateCluster(getCluster((String) resource.getPropertyValue(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);  }