mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
[DS-3762] Adjust tests to new Builder API
This commit is contained in:
@@ -288,9 +288,6 @@ public class BitstreamContentRestControllerIT extends AbstractControllerIntegrat
|
||||
//An unauthorized request should not log statistics
|
||||
checkNumberOfStatsRecords(bitstream, 0);
|
||||
|
||||
} finally {
|
||||
//** CLEANUP **
|
||||
GroupBuilder.cleaner().delete(internalGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,7 @@ import org.dspace.app.rest.builder.BitstreamBuilder;
|
||||
import org.dspace.app.rest.builder.CollectionBuilder;
|
||||
import org.dspace.app.rest.builder.CommunityBuilder;
|
||||
import org.dspace.app.rest.builder.ItemBuilder;
|
||||
import org.dspace.app.rest.matcher.BitstreamFormatMatcher;
|
||||
import org.dspace.app.rest.matcher.BitstreamMatcher;
|
||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -230,7 +231,7 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(contentType))
|
||||
.andExpect(jsonPath("$._embedded.bitstreams", contains(
|
||||
BitstreamMatcher.matchBitstreamEntry(bitstream.getName(), bitstream.getID())
|
||||
BitstreamMatcher.matchBitstreamEntry(bitstream)
|
||||
)))
|
||||
|
||||
;
|
||||
@@ -342,7 +343,7 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
getClient().perform(get("/api/core/bitstreams/"+bitstream.getID()+"/format"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(contentType))
|
||||
//TODO add matcher on bitstream format
|
||||
.andExpect(jsonPath("$", BitstreamFormatMatcher.matchBitstreamFormatMimeType("text/plain")))
|
||||
;
|
||||
|
||||
|
||||
@@ -351,7 +352,6 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
;
|
||||
|
||||
|
||||
//TODO This test fails in the current code. Authorization error
|
||||
getClient().perform(get("/api/core/bitstreams/"+bitstream.getID()+"/content"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string("ThisIsSomeDummyText"))
|
||||
@@ -359,8 +359,6 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void findOneWrongUUID() throws Exception {
|
||||
|
||||
@@ -377,7 +375,6 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
.build();
|
||||
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
|
||||
|
||||
//TODO This test fails in the current code. Authorization error
|
||||
getClient().perform(get("/api/core/bitstreams/"+ UUID.randomUUID()))
|
||||
.andExpect(status().isNotFound())
|
||||
;
|
||||
|
@@ -190,24 +190,24 @@ public class CommunityRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
|
||||
//** GIVEN **
|
||||
//1. A community-collection structure with one parent community with sub-community and one collection.
|
||||
parentCommunity = new CommunityBuilder().createCommunity(context)
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.withLogo("ThisIsSomeDummyText")
|
||||
.build();
|
||||
|
||||
Community parentCommunity2 = new CommunityBuilder().createCommunity(context)
|
||||
Community parentCommunity2 = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community 2")
|
||||
.withLogo("SomeTest")
|
||||
.build();
|
||||
|
||||
Community child1 = new CommunityBuilder().createSubCommunity(context, parentCommunity)
|
||||
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
|
||||
.withName("Sub Community")
|
||||
.build();
|
||||
|
||||
Community child12 = new CommunityBuilder().createSubCommunity(context, child1)
|
||||
Community child12 = CommunityBuilder.createSubCommunity(context, child1)
|
||||
.withName("Sub Sub Community")
|
||||
.build();
|
||||
Collection col1 = new CollectionBuilder().createCollection(context, child1).withName("Collection 1").build();
|
||||
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
|
||||
|
||||
|
||||
getClient().perform(get("/api/core/communities/search/top"))
|
||||
@@ -239,29 +239,29 @@ public class CommunityRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
|
||||
//** GIVEN **
|
||||
//1. A community-collection structure with one parent community with sub-community and one collection.
|
||||
parentCommunity = new CommunityBuilder().createCommunity(context)
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.withLogo("ThisIsSomeDummyText")
|
||||
.build();
|
||||
|
||||
Community parentCommunity2 = new CommunityBuilder().createCommunity(context)
|
||||
Community parentCommunity2 = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community 2")
|
||||
.withLogo("SomeTest")
|
||||
.build();
|
||||
|
||||
Community child1 = new CommunityBuilder().createSubCommunity(context, parentCommunity)
|
||||
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
|
||||
.withName("Sub Community")
|
||||
.build();
|
||||
|
||||
Community child12 = new CommunityBuilder().createSubCommunity(context, child1)
|
||||
Community child12 = CommunityBuilder.createSubCommunity(context, child1)
|
||||
.withName("Sub Sub Community")
|
||||
.build();
|
||||
|
||||
Community child2 = new CommunityBuilder().createSubCommunity(context, parentCommunity2)
|
||||
Community child2 = CommunityBuilder.createSubCommunity(context, parentCommunity2)
|
||||
.withName("Sub2 Community")
|
||||
.build();
|
||||
|
||||
Collection col1 = new CollectionBuilder().createCollection(context, child1).withName("Collection 1").build();
|
||||
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
|
||||
|
||||
getClient().perform(get("/api/core/communities/search/subCommunities"))
|
||||
.andExpect(status().isOk())
|
||||
|
@@ -35,6 +35,8 @@ import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Abstract builder class that holds references to all available services
|
||||
*
|
||||
* @author Jonas Van Goolen - (jonas@atmire.com)
|
||||
*/
|
||||
public abstract class AbstractBuilder<T, S> {
|
||||
@@ -52,7 +54,6 @@ public abstract class AbstractBuilder<T, S> {
|
||||
static AuthorizeService authorizeService;
|
||||
static ResourcePolicyService resourcePolicyService;
|
||||
static IndexingService indexingService;
|
||||
static BitstreamFormatService bitstreamFormatService;
|
||||
static RegistrationDataService registrationDataService;
|
||||
static VersionHistoryService versionHistoryService;
|
||||
static ClaimedTaskService claimedTaskService;
|
||||
@@ -88,7 +89,6 @@ public abstract class AbstractBuilder<T, S> {
|
||||
authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
resourcePolicyService = AuthorizeServiceFactory.getInstance().getResourcePolicyService();
|
||||
indexingService = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(IndexingService.class.getName(),IndexingService.class);
|
||||
bitstreamFormatService = ContentServiceFactory.getInstance().getBitstreamFormatService();
|
||||
registrationDataService = EPersonServiceFactory.getInstance().getRegistrationDataService();
|
||||
versionHistoryService = VersionServiceFactory.getInstance().getVersionHistoryService();
|
||||
metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService();
|
||||
|
@@ -82,8 +82,4 @@ public class GroupBuilder extends AbstractDSpaceObjectBuilder<Group> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static AbstractBuilder<Group> cleaner() {
|
||||
return new GroupBuilder();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user