Community extends DSpaceObject implements DSpaceObjectLegacySupport { public List<Community> getSubcommunities() { Community[] output = subCommunities.toArray(new Community[]{}); 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 testGetSubcommunities() throws Exception { new NonStrictExpectations(authorizeService.getClass()) {{ authorizeService.authorizeAction((Context) any, (Community) any, Constants.ADD); result = null; authorizeService.authorizeActionBoolean((Context) any, (Community) any, Constants.ADD); result = true; }}; assertThat("testGetSubcommunities 0",c.getSubcommunities(), notNullValue()); assertTrue("testGetSubcommunities 1", c.getSubcommunities().size() == 0); context.turnOffAuthorisationSystem(); Community community = communityService.create(c, context); communityService.setMetadataSingleValue(context, community, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY, "subcommunity B"); community = communityService.create(c, context); communityService.setMetadataSingleValue(context, community, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY, "subcommunity A"); community = communityService.create(c, context); communityService.setMetadataSingleValue(context, community, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY, "subcommunity C"); context.restoreAuthSystemState(); assertTrue("testGetCollections 2",c.getSubcommunities().get(0).getName().equals("subcommunity A")); assertTrue("testGetCollections 3",c.getSubcommunities().get(1).getName().equals("subcommunity B")); assertTrue("testGetCollections 4",c.getSubcommunities().get(2).getName().equals("subcommunity C")); }
@Test public void testCreateSubcommunityAuth() throws Exception { new NonStrictExpectations(authorizeService.getClass()) {{ authorizeService.authorizeAction((Context) any, (Community) any, Constants.ADD); result = null; authorizeService.authorizeActionBoolean((Context) any, (Community) any, Constants.ADD); result = true; }}; Community result = communityService.createSubcommunity(context, c); assertThat("testCreateSubcommunityAuth 0",c.getSubcommunities(), notNullValue()); assertTrue("testCreateSubcommunityAuth 1", c.getSubcommunities().size() == 1); assertThat("testCreateSubcommunityAuth 2", c.getSubcommunities().get(0), equalTo(result)); }