@Test public void testFindByCollectionMapping() throws Exception { int limit = 5; int offset = 0; context.turnOffAuthorisationSystem(); Collection colToMapTo = this.createCollection(); Item item1 = this.createItem(); Iterator<Item> result = itemService.findByCollectionMapping(context, colToMapTo, limit, offset); assertThat("testFindByCollectionMapping 0", result, notNullValue()); assertFalse("testFindByCollectionMapping 1", result.hasNext()); collectionService.addItem(context, colToMapTo, item1); collectionService.update(context, colToMapTo); context.restoreAuthSystemState(); result = itemService.findByCollectionMapping(context, colToMapTo, limit, offset); assertThat("testFindByCollectionMapping 3", result, notNullValue()); assertTrue("testFindByCollectionMapping 4", result.hasNext()); assertThat("testFindByCollectionMapping 5", result.next(), equalTo(item1)); context.turnOffAuthorisationSystem(); Item item2 = this.createItem(); collectionService.addItem(context, colToMapTo, item2); context.restoreAuthSystemState(); limit = 5; offset = 1; result = itemService.findByCollectionMapping(context, colToMapTo, limit, offset); Item secondItemMapped = result.next(); assertTrue("testFindByCollectionMapping 7", secondItemMapped.equals(item1) || secondItemMapped.equals(item2)); assertFalse("testFindByCollectionMapping 8", result.hasNext()); limit = 1; offset = 0; result = itemService.findByCollectionMapping(context, colToMapTo, limit, offset); Item onlyItemFound = result.next(); assertTrue("testFindByCollectionMapping 9", onlyItemFound .equals(item1) || onlyItemFound .equals(item2)); assertFalse("testFindByCollectionMapping 10", result.hasNext()); limit = 5; offset = 3; result = itemService.findByCollectionMapping(context, colToMapTo, limit, offset); assertFalse("testFindByCollectionMapping 11", result.hasNext()); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj); if (this.getClass() != objClass) { return false; } final Item otherItem = (Item) obj; if (!this.getID().equals(otherItem.getID())) { return false; } return true; }
Item extends DSpaceObject implements DSpaceObjectLegacySupport { @Override public boolean equals(Object obj) { if (obj == null) { return false; } Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj); if (this.getClass() != objClass) { return false; } final Item otherItem = (Item) obj; if (!this.getID().equals(otherItem.getID())) { return false; } return true; } }
Item extends DSpaceObject implements DSpaceObjectLegacySupport { @Override public boolean equals(Object obj) { if (obj == null) { return false; } Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj); if (this.getClass() != objClass) { return false; } final Item otherItem = (Item) obj; if (!this.getID().equals(otherItem.getID())) { return false; } return true; } protected  Item(); }
Item extends DSpaceObject implements DSpaceObjectLegacySupport { @Override public boolean equals(Object obj) { if (obj == null) { return false; } Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj); if (this.getClass() != objClass) { return false; } final Item otherItem = (Item) obj; if (!this.getID().equals(otherItem.getID())) { return false; } return true; } protected  Item(); boolean isArchived(); boolean isWithdrawn(); boolean isDiscoverable(); Date getLastModified(); void setLastModified(Date lastModified); void setArchived(boolean isArchived); void setDiscoverable(boolean discoverable); void setOwningCollection(Collection c); Collection getOwningCollection(); EPerson getSubmitter(); void setSubmitter(EPerson sub); List<Collection> getCollections(); void clearCollections(); Collection getTemplateItemOf(); List<Bundle> getBundles(); List<Bundle> getBundles(String name); @Override boolean equals(Object obj); @Override int hashCode(); @Override int getType(); @Override String getName(); @Override Integer getLegacyId(); ItemService getItemService(); }
Item extends DSpaceObject implements DSpaceObjectLegacySupport { @Override public boolean equals(Object obj) { if (obj == null) { return false; } Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj); if (this.getClass() != objClass) { return false; } final Item otherItem = (Item) obj; if (!this.getID().equals(otherItem.getID())) { return false; } return true; } protected  Item(); boolean isArchived(); boolean isWithdrawn(); boolean isDiscoverable(); Date getLastModified(); void setLastModified(Date lastModified); void setArchived(boolean isArchived); void setDiscoverable(boolean discoverable); void setOwningCollection(Collection c); Collection getOwningCollection(); EPerson getSubmitter(); void setSubmitter(EPerson sub); List<Collection> getCollections(); void clearCollections(); Collection getTemplateItemOf(); List<Bundle> getBundles(); List<Bundle> getBundles(String name); @Override boolean equals(Object obj); @Override int hashCode(); @Override int getType(); @Override String getName(); @Override Integer getLegacyId(); ItemService getItemService(); static final String ANY; }