### Question:
Community extends DSpaceObject { public Collection[] getCollections() throws SQLException { List<Collection> collections = new ArrayList<Collection>(); TableRowIterator tri = DatabaseManager.queryTable( ourContext,"collection", "SELECT collection.* FROM collection, community2collection WHERE " + "community2collection.collection_id=collection.collection_id " + "AND community2collection.community_id= ? ORDER BY collection.name", getID()); try { while (tri.hasNext()) { TableRow row = tri.next(); Collection fromCache = (Collection) ourContext.fromCache( Collection.class, row.getIntColumn("collection_id")); if (fromCache != null) { collections.add(fromCache); } else { collections.add(new Collection(ourContext, row)); } } } finally { if (tri != null) { tri.close(); } } Collection[] collectionArray = new Collection[collections.size()]; collectionArray = (Collection[]) collections.toArray(collectionArray); return collectionArray; } Community(Context context, TableRow row); static Community find(Context context, int id); static Community create(Community parent, Context context); static Community create(Community parent, Context context, String handle); static Community[] findAll(Context context); static Community[] findAllTop(Context context); int getID(); String getHandle(); String getMetadata(String field); void setMetadata(String field, String value); String getName(); Bitstream getLogo(); Bitstream setLogo(InputStream is); void update(); Group createAdministrators(); void removeAdministrators(); Group getAdministrators(); Collection[] getCollections(); Community[] getSubcommunities(); Community getParentCommunity(); Community[] getAllParents(); Collection createCollection(); Collection createCollection(String handle); void addCollection(Collection c); Community createSubcommunity(); Community createSubcommunity(String handle); void addSubcommunity(Community c); void removeCollection(Collection c); void removeSubcommunity(Community c); void delete(); boolean equals(Object other); int hashCode(); int getType(); boolean canEditBoolean(); void canEdit(); int countItems(); DSpaceObject getAdminObject(int action); DSpaceObject getParentObject();  }### Answer:
@Test public void testGetCollections() throws Exception { new NonStrictExpectations() { AuthorizeManager authManager; { AuthorizeManager.authorizeAction((Context) any, (Community) any, Constants.WRITE); result = null; AuthorizeManager.authorizeAction((Context) any, (Community) any, Constants.ADD); result = null; } }; assertThat("testGetCollections 0",c.getCollections(), notNullValue()); assertTrue("testGetCollections 1", c.getCollections().length == 0); Collection result = c.createCollection(); assertThat("testGetCollections 2",c.getCollections(), notNullValue()); assertTrue("testGetCollections 3", c.getCollections().length == 1); assertThat("testGetCollections 4",c.getCollections()[0], equalTo(result)); }