[DS-3762] Adjust tests to new Builder API

This commit is contained in:
Tom Desair
2017-12-05 15:10:57 +01:00
parent e070c2bd79
commit a478867804
5 changed files with 16 additions and 26 deletions

View File

@@ -288,9 +288,6 @@ public class BitstreamContentRestControllerIT extends AbstractControllerIntegrat
//An unauthorized request should not log statistics //An unauthorized request should not log statistics
checkNumberOfStatsRecords(bitstream, 0); checkNumberOfStatsRecords(bitstream, 0);
} finally {
//** CLEANUP **
GroupBuilder.cleaner().delete(internalGroup);
} }
} }

View File

@@ -13,6 +13,7 @@ import org.dspace.app.rest.builder.BitstreamBuilder;
import org.dspace.app.rest.builder.CollectionBuilder; import org.dspace.app.rest.builder.CollectionBuilder;
import org.dspace.app.rest.builder.CommunityBuilder; import org.dspace.app.rest.builder.CommunityBuilder;
import org.dspace.app.rest.builder.ItemBuilder; 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.matcher.BitstreamMatcher;
import org.dspace.app.rest.test.AbstractControllerIntegrationTest; import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
import org.dspace.content.Bitstream; import org.dspace.content.Bitstream;
@@ -230,7 +231,7 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(contentType)) .andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.bitstreams", contains( .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")) getClient().perform(get("/api/core/bitstreams/"+bitstream.getID()+"/format"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(contentType)) .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")) getClient().perform(get("/api/core/bitstreams/"+bitstream.getID()+"/content"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().string("ThisIsSomeDummyText")) .andExpect(content().string("ThisIsSomeDummyText"))
@@ -359,8 +359,6 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
} }
@Test @Test
public void findOneWrongUUID() throws Exception { public void findOneWrongUUID() throws Exception {
@@ -377,7 +375,6 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
.build(); .build();
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").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())) getClient().perform(get("/api/core/bitstreams/"+ UUID.randomUUID()))
.andExpect(status().isNotFound()) .andExpect(status().isNotFound())
; ;

View File

@@ -190,24 +190,24 @@ public class CommunityRestRepositoryIT extends AbstractControllerIntegrationTest
//** GIVEN ** //** GIVEN **
//1. A community-collection structure with one parent community with sub-community and one collection. //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") .withName("Parent Community")
.withLogo("ThisIsSomeDummyText") .withLogo("ThisIsSomeDummyText")
.build(); .build();
Community parentCommunity2 = new CommunityBuilder().createCommunity(context) Community parentCommunity2 = CommunityBuilder.createCommunity(context)
.withName("Parent Community 2") .withName("Parent Community 2")
.withLogo("SomeTest") .withLogo("SomeTest")
.build(); .build();
Community child1 = new CommunityBuilder().createSubCommunity(context, parentCommunity) Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
.withName("Sub Community") .withName("Sub Community")
.build(); .build();
Community child12 = new CommunityBuilder().createSubCommunity(context, child1) Community child12 = CommunityBuilder.createSubCommunity(context, child1)
.withName("Sub Sub Community") .withName("Sub Sub Community")
.build(); .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")) getClient().perform(get("/api/core/communities/search/top"))
@@ -239,29 +239,29 @@ public class CommunityRestRepositoryIT extends AbstractControllerIntegrationTest
//** GIVEN ** //** GIVEN **
//1. A community-collection structure with one parent community with sub-community and one collection. //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") .withName("Parent Community")
.withLogo("ThisIsSomeDummyText") .withLogo("ThisIsSomeDummyText")
.build(); .build();
Community parentCommunity2 = new CommunityBuilder().createCommunity(context) Community parentCommunity2 = CommunityBuilder.createCommunity(context)
.withName("Parent Community 2") .withName("Parent Community 2")
.withLogo("SomeTest") .withLogo("SomeTest")
.build(); .build();
Community child1 = new CommunityBuilder().createSubCommunity(context, parentCommunity) Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
.withName("Sub Community") .withName("Sub Community")
.build(); .build();
Community child12 = new CommunityBuilder().createSubCommunity(context, child1) Community child12 = CommunityBuilder.createSubCommunity(context, child1)
.withName("Sub Sub Community") .withName("Sub Sub Community")
.build(); .build();
Community child2 = new CommunityBuilder().createSubCommunity(context, parentCommunity2) Community child2 = CommunityBuilder.createSubCommunity(context, parentCommunity2)
.withName("Sub2 Community") .withName("Sub2 Community")
.build(); .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")) getClient().perform(get("/api/core/communities/search/subCommunities"))
.andExpect(status().isOk()) .andExpect(status().isOk())

View File

@@ -35,6 +35,8 @@ import java.sql.SQLException;
import java.util.Date; import java.util.Date;
/** /**
* Abstract builder class that holds references to all available services
*
* @author Jonas Van Goolen - (jonas@atmire.com) * @author Jonas Van Goolen - (jonas@atmire.com)
*/ */
public abstract class AbstractBuilder<T, S> { public abstract class AbstractBuilder<T, S> {
@@ -52,7 +54,6 @@ public abstract class AbstractBuilder<T, S> {
static AuthorizeService authorizeService; static AuthorizeService authorizeService;
static ResourcePolicyService resourcePolicyService; static ResourcePolicyService resourcePolicyService;
static IndexingService indexingService; static IndexingService indexingService;
static BitstreamFormatService bitstreamFormatService;
static RegistrationDataService registrationDataService; static RegistrationDataService registrationDataService;
static VersionHistoryService versionHistoryService; static VersionHistoryService versionHistoryService;
static ClaimedTaskService claimedTaskService; static ClaimedTaskService claimedTaskService;
@@ -88,7 +89,6 @@ public abstract class AbstractBuilder<T, S> {
authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService(); authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
resourcePolicyService = AuthorizeServiceFactory.getInstance().getResourcePolicyService(); resourcePolicyService = AuthorizeServiceFactory.getInstance().getResourcePolicyService();
indexingService = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(IndexingService.class.getName(),IndexingService.class); indexingService = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(IndexingService.class.getName(),IndexingService.class);
bitstreamFormatService = ContentServiceFactory.getInstance().getBitstreamFormatService();
registrationDataService = EPersonServiceFactory.getInstance().getRegistrationDataService(); registrationDataService = EPersonServiceFactory.getInstance().getRegistrationDataService();
versionHistoryService = VersionServiceFactory.getInstance().getVersionHistoryService(); versionHistoryService = VersionServiceFactory.getInstance().getVersionHistoryService();
metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService(); metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService();

View File

@@ -82,8 +82,4 @@ public class GroupBuilder extends AbstractDSpaceObjectBuilder<Group> {
return this; return this;
} }
public static AbstractBuilder<Group> cleaner() {
return new GroupBuilder();
}
} }