Export all collections of a community recursively

This commit is contained in:
Keiji Suzuki
2013-07-07 11:07:42 +09:00
parent 28502b115c
commit 2b4633a87c
4 changed files with 124 additions and 17 deletions

View File

@@ -766,6 +766,37 @@ public class CommunityTest extends AbstractDSpaceObjectTest
assertThat("testGetAllParents 4", son.getAllParents()[0], equalTo(c));
}
/**
* Test of getAllCollections method, of class Community.
*/
@Test
public void testGetAllCollections() throws Exception
{
new NonStrictExpectations()
{
AuthorizeManager authManager;
{
AuthorizeManager.authorizeAction((Context) any, (Community) any,
Constants.ADD); result = null;
AuthorizeManager.authorizeActionBoolean((Context) any, (Community) any,
Constants.ADD); result = true;
}
};
//empty by default
assertThat("testGetAllCollections 0",c.getAllCollections(), notNullValue());
assertTrue("testGetAllCollections 1", c.getAllCollections().length == 0);
//community has a collection and a subcommunity, subcommunity has a collection
Collection collOfC = c.createCollection();
Community sub = Community.create(c, context);
Collection collOfSub = sub.createCollection();
assertThat("testGetAllCollections 2",c.getAllCollections(), notNullValue());
assertTrue("testGetAllCollections 3", c.getAllCollections().length == 2);
assertThat("testGetAllCollections 4", c.getAllCollections()[0], equalTo(collOfSub));
assertThat("testGetAllCollections 5", c.getAllCollections()[1], equalTo(collOfC));
}
/**
* Test of createCollection method, of class Community.
*/