@Test public void testDeleteResources() throws Exception { IvoryService service = createMock(IvoryService.class); List<String> feedNames = new LinkedList<String>(); feedNames.add("Feed1"); Map<String,String> props = new HashMap<String, String>(); Feed feed1 = new Feed("Feed1", "d", "s", "sch", "source", "st", "end", "l", "a", "target", "st", "end", "l", "a", props); expect(service.getFeedNames()).andReturn(feedNames); expect(service.getFeed("Feed1")).andReturn(feed1); service.deleteFeed("Feed1"); replay(service); FeedResourceProvider provider = new FeedResourceProvider(service, PropertyHelper.getPropertyIds(Resource.Type.DRFeed), PropertyHelper.getKeyPropertyIds(Resource.Type.DRFeed)); Predicate predicate = new PredicateBuilder().property(FeedResourceProvider.FEED_NAME_PROPERTY_ID).equals("Feed1").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.deleteFeed((String) resource.getPropertyValue(FEED_NAME_PROPERTY_ID)); } return new RequestStatusImpl(null); }
FeedResourceProvider 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.deleteFeed((String) resource.getPropertyValue(FEED_NAME_PROPERTY_ID)); } return new RequestStatusImpl(null); } }
FeedResourceProvider 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.deleteFeed((String) resource.getPropertyValue(FEED_NAME_PROPERTY_ID)); } return new RequestStatusImpl(null); } FeedResourceProvider(IvoryService ivoryService,
                              Set<String> propertyIds,
                              Map<Resource.Type, String> keyPropertyIds); }
FeedResourceProvider 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.deleteFeed((String) resource.getPropertyValue(FEED_NAME_PROPERTY_ID)); } return new RequestStatusImpl(null); } FeedResourceProvider(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); }
FeedResourceProvider 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.deleteFeed((String) resource.getPropertyValue(FEED_NAME_PROPERTY_ID)); } return new RequestStatusImpl(null); } FeedResourceProvider(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);  }