Collection extends DSpaceObject implements DSpaceObjectLegacySupport { @Override public boolean equals(Object other) { if (other == null) { return false; } Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other); if (this.getClass() != objClass) { return false; } final Collection otherCollection = (Collection) other; if (!this.getID().equals(otherCollection.getID() )) { return false; } return true; } protected  Collection(); @Override String getName(); Bitstream getLogo(); Group getSubmitters(); Group getAdministrators(); Group getWorkflowStep1(); Group getWorkflowStep2(); Group getWorkflowStep3(); String getLicenseCollection(); void setLicense(Context context, String license); Item getTemplateItem(); List<Community> getCommunities(); @Override boolean equals(Object other); @Override int hashCode(); @Override int getType(); void setWorkflowGroup(Context context, int step, Group g); @Override Integer getLegacyId(); @Transient
    static final String COPYRIGHT_TEXT; @Transient
    static final String INTRODUCTORY_TEXT; @Transient
    static final String SHORT_DESCRIPTION; @Transient
    static final String SIDEBAR_TEXT; @Transient
    static final String PROVENANCE_TEXT; }
@Test public void testFindAll() throws Exception { List<Collection> all = collectionService.findAll(context); assertThat("testFindAll 0", all, notNullValue()); assertTrue("testFindAll 1", all.size() >= 1); boolean added = false; for(Collection cl: all) { if(cl.equals(collection)) { added = true; } } assertTrue("testFindAll 2",added); }
@Test public void testAddItemAuth() throws Exception { new NonStrictExpectations(authorizeService.getClass()) {{ authorizeService.authorizeAction((Context) any, (Collection) any, Constants.ADD); result = null; authorizeService.authorizeAction((Context) any, (Item) any, Constants.WRITE); result = null; }}; WorkspaceItem workspaceItem = workspaceItemService.create(context, collection, false); Item item = installItemService.installItem(context, workspaceItem); collectionService.addItem(context, collection, item); boolean added = false; Iterator<Item> ii = itemService.findByCollection(context, collection); while(ii.hasNext()) { if(ii.next().equals(item)) { added = true; } } assertTrue("testAddItemAuth 0",added); }
@Test public void testRemoveItemAuth() throws Exception { new NonStrictExpectations(authorizeService.getClass()) {{ authorizeService.authorizeAction((Context) any, (Collection) any, Constants.ADD); result = null; authorizeService.authorizeAction((Context) any, (Collection) any, Constants.REMOVE); result = null; authorizeService.authorizeAction((Context) any, (Item) any, Constants.WRITE); result = null; authorizeService.authorizeAction((Context) any, (Item) any, Constants.DELETE); result = null; }}; WorkspaceItem workspaceItem = workspaceItemService.create(context, collection, false); Item item = installItemService.installItem(context, workspaceItem); collectionService.addItem(context, collection, item); collectionService.removeItem(context, collection, item); boolean isthere = false; Iterator<Item> ii = itemService.findByCollection(context, collection); while(ii.hasNext()) { if(ii.next().equals(item)) { isthere = true; } } assertFalse("testRemoveItemAuth 0",isthere); }
@Test @SuppressWarnings("ObjectEqualsNull") public void testEquals() throws SQLException, AuthorizeException { new NonStrictExpectations(authorizeService.getClass()) {{ authorizeService.authorizeAction((Context) any, (Community) any, Constants.ADD); result = null; }}; assertFalse("testEquals 0",collection.equals(null)); assertFalse("testEquals 1",collection.equals(collectionService.create(context, owningCommunity))); assertTrue("testEquals 2", collection.equals(collection)); }