mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 07:23:08 +00:00
Fixed headers and checkstyle for parentCommunity link functionality
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
package org.dspace.app.rest.repository;
|
package org.dspace.app.rest.repository;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@@ -1,3 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
package org.dspace.app.rest.repository;
|
package org.dspace.app.rest.repository;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@@ -7,16 +7,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest;
|
package org.dspace.app.rest;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.hamcrest.CoreMatchers.not;
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
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;
|
||||||
@@ -62,17 +61,17 @@ public class CommunityCollectionParentIT extends AbstractControllerIntegrationTe
|
|||||||
//** 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.
|
||||||
communityA = CommunityBuilder.createCommunity(context)
|
communityA = CommunityBuilder.createCommunity(context)
|
||||||
.withName("Parent CommunityA")
|
.withName("Parent CommunityA")
|
||||||
.build();
|
.build();
|
||||||
communityB = CommunityBuilder.createCommunity(context)
|
communityB = CommunityBuilder.createCommunity(context)
|
||||||
.withName("Parent CommunityB")
|
.withName("Parent CommunityB")
|
||||||
.build();
|
.build();
|
||||||
communityAA = CommunityBuilder.createSubCommunity(context, communityA)
|
communityAA = CommunityBuilder.createSubCommunity(context, communityA)
|
||||||
.withName("Sub Community")
|
.withName("Sub Community")
|
||||||
.build();
|
.build();
|
||||||
communityAB = CommunityBuilder.createSubCommunity(context, communityA)
|
communityAB = CommunityBuilder.createSubCommunity(context, communityA)
|
||||||
.withName("Sub Community Two")
|
.withName("Sub Community Two")
|
||||||
.build();
|
.build();
|
||||||
col1 = CollectionBuilder.createCollection(context, communityAA).withName("Collection 1").build();
|
col1 = CollectionBuilder.createCollection(context, communityAA).withName("Collection 1").build();
|
||||||
col2 = CollectionBuilder.createCollection(context, communityAA).withName("Collection 2").build();
|
col2 = CollectionBuilder.createCollection(context, communityAA).withName("Collection 2").build();
|
||||||
col3 = CollectionBuilder.createCollection(context, communityAB).withName("Collection 3").build();
|
col3 = CollectionBuilder.createCollection(context, communityAB).withName("Collection 3").build();
|
||||||
@@ -80,25 +79,25 @@ public class CommunityCollectionParentIT extends AbstractControllerIntegrationTe
|
|||||||
|
|
||||||
|
|
||||||
itemX = ItemBuilder.createItem(context, col1)
|
itemX = ItemBuilder.createItem(context, col1)
|
||||||
.withTitle("Public item 1")
|
.withTitle("Public item 1")
|
||||||
.withIssueDate("2017-10-17")
|
.withIssueDate("2017-10-17")
|
||||||
.withAuthor("Smith, Donald").withAuthor("Doe, John")
|
.withAuthor("Smith, Donald").withAuthor("Doe, John")
|
||||||
.withSubject("ExtraEntry")
|
.withSubject("ExtraEntry")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
itemY = ItemBuilder.createItem(context, col1)
|
itemY = ItemBuilder.createItem(context, col1)
|
||||||
.withTitle("Public item 1")
|
.withTitle("Public item 1")
|
||||||
.withIssueDate("2017-10-17")
|
.withIssueDate("2017-10-17")
|
||||||
.withAuthor("Smith, Donald").withAuthor("Doe, John")
|
.withAuthor("Smith, Donald").withAuthor("Doe, John")
|
||||||
.withSubject("ExtraEntry")
|
.withSubject("ExtraEntry")
|
||||||
.build();
|
.build();
|
||||||
collectionService.addItem(context, col2, itemY);
|
collectionService.addItem(context, col2, itemY);
|
||||||
itemZ = ItemBuilder.createItem(context, col2)
|
itemZ = ItemBuilder.createItem(context, col2)
|
||||||
.withTitle("Public item 1")
|
.withTitle("Public item 1")
|
||||||
.withIssueDate("2017-10-17")
|
.withIssueDate("2017-10-17")
|
||||||
.withAuthor("Smith, Donald").withAuthor("Doe, John")
|
.withAuthor("Smith, Donald").withAuthor("Doe, John")
|
||||||
.withSubject("ExtraEntry")
|
.withSubject("ExtraEntry")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
}
|
}
|
||||||
@@ -108,11 +107,12 @@ public class CommunityCollectionParentIT extends AbstractControllerIntegrationTe
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String token = getAuthToken(admin.getEmail(), password);
|
String token = getAuthToken(admin.getEmail(), password);
|
||||||
MvcResult mvcResult = getClient(token).perform(get("/api/core/items/" + itemX.getID() + "/owningCollection")).andReturn();
|
MvcResult mvcResult = getClient(token).perform(get("/api/core/items/" + itemX.getID() + "/owningCollection"))
|
||||||
|
.andReturn();
|
||||||
|
|
||||||
String content = mvcResult.getResponse().getContentAsString();
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
Map<String,Object> map = mapper.readValue(content, Map.class);
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
String collectionUuidString = String.valueOf(map.get("uuid"));
|
String collectionUuidString = String.valueOf(map.get("uuid"));
|
||||||
String collectionName = String.valueOf(map.get("name"));
|
String collectionName = String.valueOf(map.get("name"));
|
||||||
|
|
||||||
mvcResult = getClient(token).perform(get("/api/core/collections/" + col1.getID())).andReturn();
|
mvcResult = getClient(token).perform(get("/api/core/collections/" + col1.getID())).andReturn();
|
||||||
@@ -131,11 +131,12 @@ public class CommunityCollectionParentIT extends AbstractControllerIntegrationTe
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String token = getAuthToken(admin.getEmail(), password);
|
String token = getAuthToken(admin.getEmail(), password);
|
||||||
MvcResult mvcResult = getClient(token).perform(get("/api/core/items/" + itemY.getID() + "/owningCollection")).andReturn();
|
MvcResult mvcResult = getClient(token).perform(get("/api/core/items/" + itemY.getID() + "/owningCollection"))
|
||||||
|
.andReturn();
|
||||||
|
|
||||||
String content = mvcResult.getResponse().getContentAsString();
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
Map<String,Object> map = mapper.readValue(content, Map.class);
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
String collectionUuidString = String.valueOf(map.get("uuid"));
|
String collectionUuidString = String.valueOf(map.get("uuid"));
|
||||||
String collectionName = String.valueOf(map.get("name"));
|
String collectionName = String.valueOf(map.get("name"));
|
||||||
|
|
||||||
mvcResult = getClient(token).perform(get("/api/core/collections/" + col1.getID())).andReturn();
|
mvcResult = getClient(token).perform(get("/api/core/collections/" + col1.getID())).andReturn();
|
||||||
@@ -154,11 +155,12 @@ public class CommunityCollectionParentIT extends AbstractControllerIntegrationTe
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String token = getAuthToken(admin.getEmail(), password);
|
String token = getAuthToken(admin.getEmail(), password);
|
||||||
MvcResult mvcResult = getClient(token).perform(get("/api/core/items/" + itemZ.getID() + "/owningCollection")).andReturn();
|
MvcResult mvcResult = getClient(token).perform(get("/api/core/items/" + itemZ.getID() + "/owningCollection"))
|
||||||
|
.andReturn();
|
||||||
|
|
||||||
String content = mvcResult.getResponse().getContentAsString();
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
Map<String,Object> map = mapper.readValue(content, Map.class);
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
String collectionUuidString = String.valueOf(map.get("uuid"));
|
String collectionUuidString = String.valueOf(map.get("uuid"));
|
||||||
String collectionName = String.valueOf(map.get("name"));
|
String collectionName = String.valueOf(map.get("name"));
|
||||||
|
|
||||||
mvcResult = getClient(token).perform(get("/api/core/collections/" + col2.getID())).andReturn();
|
mvcResult = getClient(token).perform(get("/api/core/collections/" + col2.getID())).andReturn();
|
||||||
@@ -177,11 +179,12 @@ public class CommunityCollectionParentIT extends AbstractControllerIntegrationTe
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String token = getAuthToken(admin.getEmail(), password);
|
String token = getAuthToken(admin.getEmail(), password);
|
||||||
MvcResult mvcResult = getClient(token).perform(get("/api/core/collections/" + col1.getID() + "/parentCommunity")).andReturn();
|
MvcResult mvcResult = getClient(token)
|
||||||
|
.perform(get("/api/core/collections/" + col1.getID() + "/parentCommunity")).andReturn();
|
||||||
|
|
||||||
String content = mvcResult.getResponse().getContentAsString();
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
Map<String,Object> map = mapper.readValue(content, Map.class);
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
String communityUuidString = String.valueOf(map.get("uuid"));
|
String communityUuidString = String.valueOf(map.get("uuid"));
|
||||||
String communityName = String.valueOf(map.get("name"));
|
String communityName = String.valueOf(map.get("name"));
|
||||||
|
|
||||||
mvcResult = getClient(token).perform(get("/api/core/communities/" + communityAA.getID())).andReturn();
|
mvcResult = getClient(token).perform(get("/api/core/communities/" + communityAA.getID())).andReturn();
|
||||||
@@ -201,11 +204,12 @@ public class CommunityCollectionParentIT extends AbstractControllerIntegrationTe
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String token = getAuthToken(admin.getEmail(), password);
|
String token = getAuthToken(admin.getEmail(), password);
|
||||||
MvcResult mvcResult = getClient(token).perform(get("/api/core/collections/" + col2.getID() + "/parentCommunity")).andReturn();
|
MvcResult mvcResult = getClient(token)
|
||||||
|
.perform(get("/api/core/collections/" + col2.getID() + "/parentCommunity")).andReturn();
|
||||||
|
|
||||||
String content = mvcResult.getResponse().getContentAsString();
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
Map<String,Object> map = mapper.readValue(content, Map.class);
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
String communityUuidString = String.valueOf(map.get("uuid"));
|
String communityUuidString = String.valueOf(map.get("uuid"));
|
||||||
String communityName = String.valueOf(map.get("name"));
|
String communityName = String.valueOf(map.get("name"));
|
||||||
|
|
||||||
mvcResult = getClient(token).perform(get("/api/core/communities/" + communityAA.getID())).andReturn();
|
mvcResult = getClient(token).perform(get("/api/core/communities/" + communityAA.getID())).andReturn();
|
||||||
@@ -225,11 +229,12 @@ public class CommunityCollectionParentIT extends AbstractControllerIntegrationTe
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String token = getAuthToken(admin.getEmail(), password);
|
String token = getAuthToken(admin.getEmail(), password);
|
||||||
MvcResult mvcResult = getClient(token).perform(get("/api/core/collections/" + col3.getID() + "/parentCommunity")).andReturn();
|
MvcResult mvcResult = getClient(token)
|
||||||
|
.perform(get("/api/core/collections/" + col3.getID() + "/parentCommunity")).andReturn();
|
||||||
|
|
||||||
String content = mvcResult.getResponse().getContentAsString();
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
Map<String,Object> map = mapper.readValue(content, Map.class);
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
String communityUuidString = String.valueOf(map.get("uuid"));
|
String communityUuidString = String.valueOf(map.get("uuid"));
|
||||||
String communityName = String.valueOf(map.get("name"));
|
String communityName = String.valueOf(map.get("name"));
|
||||||
|
|
||||||
mvcResult = getClient(token).perform(get("/api/core/communities/" + communityAB.getID())).andReturn();
|
mvcResult = getClient(token).perform(get("/api/core/communities/" + communityAB.getID())).andReturn();
|
||||||
@@ -249,11 +254,12 @@ public class CommunityCollectionParentIT extends AbstractControllerIntegrationTe
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String token = getAuthToken(admin.getEmail(), password);
|
String token = getAuthToken(admin.getEmail(), password);
|
||||||
MvcResult mvcResult = getClient(token).perform(get("/api/core/communities/" + communityAA.getID() + "/parentCommunity")).andReturn();
|
MvcResult mvcResult = getClient(token)
|
||||||
|
.perform(get("/api/core/communities/" + communityAA.getID() + "/parentCommunity")).andReturn();
|
||||||
|
|
||||||
String content = mvcResult.getResponse().getContentAsString();
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
Map<String,Object> map = mapper.readValue(content, Map.class);
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
String communityUuidString = String.valueOf(map.get("uuid"));
|
String communityUuidString = String.valueOf(map.get("uuid"));
|
||||||
String communityName = String.valueOf(map.get("name"));
|
String communityName = String.valueOf(map.get("name"));
|
||||||
|
|
||||||
mvcResult = getClient(token).perform(get("/api/core/communities/" + communityA.getID())).andReturn();
|
mvcResult = getClient(token).perform(get("/api/core/communities/" + communityA.getID())).andReturn();
|
||||||
@@ -273,11 +279,12 @@ public class CommunityCollectionParentIT extends AbstractControllerIntegrationTe
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String token = getAuthToken(admin.getEmail(), password);
|
String token = getAuthToken(admin.getEmail(), password);
|
||||||
MvcResult mvcResult = getClient(token).perform(get("/api/core/communities/" + communityAB.getID() + "/parentCommunity")).andReturn();
|
MvcResult mvcResult = getClient(token)
|
||||||
|
.perform(get("/api/core/communities/" + communityAB.getID() + "/parentCommunity")).andReturn();
|
||||||
|
|
||||||
String content = mvcResult.getResponse().getContentAsString();
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
Map<String,Object> map = mapper.readValue(content, Map.class);
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
String communityUuidString = String.valueOf(map.get("uuid"));
|
String communityUuidString = String.valueOf(map.get("uuid"));
|
||||||
String communityName = String.valueOf(map.get("name"));
|
String communityName = String.valueOf(map.get("name"));
|
||||||
|
|
||||||
mvcResult = getClient(token).perform(get("/api/core/communities/" + communityA.getID())).andReturn();
|
mvcResult = getClient(token).perform(get("/api/core/communities/" + communityA.getID())).andReturn();
|
||||||
@@ -296,7 +303,7 @@ public class CommunityCollectionParentIT extends AbstractControllerIntegrationTe
|
|||||||
|
|
||||||
String token = getAuthToken(admin.getEmail(), password);
|
String token = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(token).perform(get("/api/core/communities/" + communityA.getID() + "/parentCommunity"))
|
getClient(token).perform(get("/api/core/communities/" + communityA.getID() + "/parentCommunity"))
|
||||||
.andExpect(status().isNoContent());
|
.andExpect(status().isNoContent());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user