Community extends DSpaceObject implements DSpaceObjectLegacySupport { @Override public String getName() { String value = getCommunityService().getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY); return value == null ? "" : value; } 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 testCommunityFind() throws Exception { UUID id = c.getID(); Community found = communityService.find(context, id); assertThat("testCommunityFind 0", found, notNullValue()); assertThat("testCommunityFind 1", found.getID(), equalTo(id)); assertThat("testCommunityFind 2", found.getName(), equalTo("")); }
@Test public void testCreateAuth() 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; authorizeService.isAdmin((Context) any); result = false; }}; Community sub = communityService.create(c, context); assertThat("testCreate 2", sub, notNullValue()); assertThat("testCreate 3", sub.getName(), equalTo("")); assertTrue("testCreate 4", communityService.getAllParents(context, sub).size() == 1); assertThat("testCreate 5", communityService.getAllParents(context, sub).get(0), equalTo(c)); }
@Test public void testCreateAuth2() throws Exception { new NonStrictExpectations(authorizeService.getClass()) {{ authorizeService.authorizeActionBoolean((Context) any, (Community) any, Constants.ADD); result = false; authorizeService.isAdmin((Context) any); result = true; }}; Community created = communityService.create(null, context); assertThat("testCreate 0", created, notNullValue()); assertThat("testCreate 1", created.getName(), equalTo("")); Community son = communityService.create(created, context); assertThat("testCreate 2", son, notNullValue()); assertThat("testCreate 3", son.getName(), equalTo("")); assertTrue("testCreate 4", communityService.getAllParents(context, son).size() == 1); assertThat("testCreate 5", communityService.getAllParents(context, son).get(0), equalTo(created)); }
@Test @Override public void testGetName() { assertThat("testGetName 0",c.getName(), equalTo("")); }