@Test public void testDeleteResources() throws Exception { IvoryService service = createMock(IvoryService.class); Instance instance1 = new Instance("Feed1", "Instance1", "SUBMITTED", "start", "end", "details", "log"); expect(service.getFeedNames()).andReturn(Collections.singletonList("Feed1")); expect(service.getInstances("Feed1")).andReturn(Collections.singletonList(instance1)); service.killInstance("Feed1", "Instance1"); replay(service); InstanceResourceProvider provider = new InstanceResourceProvider(service, PropertyHelper.getPropertyIds(Resource.Type.DRInstance), PropertyHelper.getKeyPropertyIds(Resource.Type.DRInstance)); Predicate predicate = new PredicateBuilder().property(InstanceResourceProvider.INSTANCE_ID_PROPERTY_ID).equals("Instance1").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.killInstance((String) resource.getPropertyValue(INSTANCE_FEED_NAME_PROPERTY_ID), (String) resource.getPropertyValue(INSTANCE_ID_PROPERTY_ID)); } return new RequestStatusImpl(null); }
InstanceResourceProvider 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.killInstance((String) resource.getPropertyValue(INSTANCE_FEED_NAME_PROPERTY_ID), (String) resource.getPropertyValue(INSTANCE_ID_PROPERTY_ID)); } return new RequestStatusImpl(null); } }
InstanceResourceProvider 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.killInstance((String) resource.getPropertyValue(INSTANCE_FEED_NAME_PROPERTY_ID), (String) resource.getPropertyValue(INSTANCE_ID_PROPERTY_ID)); } return new RequestStatusImpl(null); } InstanceResourceProvider(IvoryService ivoryService,
                                  Set<String> propertyIds,
                                  Map<Resource.Type, String> keyPropertyIds); }
InstanceResourceProvider 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.killInstance((String) resource.getPropertyValue(INSTANCE_FEED_NAME_PROPERTY_ID), (String) resource.getPropertyValue(INSTANCE_ID_PROPERTY_ID)); } return new RequestStatusImpl(null); } InstanceResourceProvider(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); }
InstanceResourceProvider 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.killInstance((String) resource.getPropertyValue(INSTANCE_FEED_NAME_PROPERTY_ID), (String) resource.getPropertyValue(INSTANCE_ID_PROPERTY_ID)); } return new RequestStatusImpl(null); } InstanceResourceProvider(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);  }