Community extends DSpaceObject implements DSpaceObjectLegacySupport { public List<Collection> getCollections() { Collection[] output = collections.toArray(new Collection[]{}); Arrays.sort(output, new NameAscendingComparator()); return Arrays.asList(output); } protected  Community(); Bitstream getLogo(); Group getAdministrators(); List<Collection> getCollections(); List<Community> getSubcommunities(); List<Community> getParentCommunities(); void removeParentCommunity(Community parentCommunity); @Override boolean equals(Object other); @Override int hashCode(); @Override int getType(); @Override String getName(); @Override Integer getLegacyId(); static final String COPYRIGHT_TEXT; static final String INTRODUCTORY_TEXT; static final String SHORT_DESCRIPTION; static final String SIDEBAR_TEXT; }
@Test public void testGetCollections() throws Exception { new NonStrictExpectations(authorizeService.getClass()) {{ authorizeService.authorizeAction((Context) any, (Community) any, Constants.ADD); result = null; authorizeService.authorizeAction((Context) any, (Community) any, Constants.WRITE); result = null; }}; assertThat("testGetCollections 0",c.getCollections(), notNullValue()); assertTrue("testGetCollections 1", c.getCollections().size() == 0); context.turnOffAuthorisationSystem(); Collection collection = collectionService.create(context, c); collectionService.setMetadataSingleValue(context, collection, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY, "collection B"); collection = collectionService.create(context, c); collectionService.setMetadataSingleValue(context, collection, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY, "collection C"); collection = collectionService.create(context, c); collectionService.setMetadataSingleValue(context, collection, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY, "collection A"); context.restoreAuthSystemState(); assertTrue("testGetCollections 2",c.getCollections().get(0).getName().equals("collection A")); assertTrue("testGetCollections 3",c.getCollections().get(1).getName().equals("collection B")); assertTrue("testGetCollections 4",c.getCollections().get(2).getName().equals("collection C")); }
@Test public void testCreateCollectionAuth() throws Exception { new NonStrictExpectations(authorizeService.getClass()) {{ authorizeService.authorizeAction((Context) any, (Community) any, Constants.ADD); result = null; }}; Collection result = collectionService.create(context, c); assertThat("testCreateCollectionAuth 0", result, notNullValue()); assertThat("testCreateCollectionAuth 1", c.getCollections(), notNullValue()); assertThat("testCreateCollectionAuth 2", c.getCollections().get(0), equalTo(result)); }