Applied feedback

This commit is contained in:
Raf Ponsaerts
2019-02-20 11:28:34 +01:00
parent 53580fa228
commit 7f194dfa95
6 changed files with 250 additions and 97 deletions

View File

@@ -249,7 +249,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
} }
} }
MetadataValue metadataValue = metadataValueService.create(context, dso, metadataField); MetadataValue metadataValue = metadataValueService.create(context, dso, metadataField);
// TODO Set place to list length //Set place to list length
metadataValue.setPlace(this.getMetadata(dso, Item.ANY, Item.ANY, Item.ANY, Item.ANY).size()); metadataValue.setPlace(this.getMetadata(dso, Item.ANY, Item.ANY, Item.ANY, Item.ANY).size());
metadataValue.setLanguage(lang == null ? null : lang.trim()); metadataValue.setLanguage(lang == null ? null : lang.trim());
@@ -560,6 +560,10 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
} else { } else {
metadataValues = dso.getMetadata(); metadataValues = dso.getMetadata();
} }
//This inline sort function will sort the MetadataValues based on their place in ascending order
//If two places are the same then the MetadataValue instance will be placed before the
//RelationshipMetadataValue instance.
//This is done to ensure that the order is correct.
metadataValues.sort(new Comparator<MetadataValue>() { metadataValues.sort(new Comparator<MetadataValue>() {
public int compare(MetadataValue o1, MetadataValue o2) { public int compare(MetadataValue o1, MetadataValue o2) {
int compare = o1.getPlace() - o2.getPlace(); int compare = o1.getPlace() - o2.getPlace();

View File

@@ -1314,7 +1314,7 @@ prevent the generation of resource policy entry values with null dspace_object a
} }
} catch (SQLException e) { } catch (SQLException e) {
log.error(e, e); log.error("Lookup for Relationships for item with uuid: " + item.getID() + " caused DSpace to crash", e);
} }
return fullMetadataValueList; return fullMetadataValueList;
} }
@@ -1357,6 +1357,12 @@ prevent the generation of resource policy entry values with null dspace_object a
} }
/**
* This method will sort the List of MetadataValue objects based on the MetadataSchema, MetadataField Element,
* MetadataField Qualifier and MetadataField Place in that order.
* @param listToReturn The list to be sorted
* @return The list sorted on those criteria
*/
private List<MetadataValue> sortMetadataValueList(List<MetadataValue> listToReturn) { private List<MetadataValue> sortMetadataValueList(List<MetadataValue> listToReturn) {
Comparator<MetadataValue> comparator = Comparator.comparing( Comparator<MetadataValue> comparator = Comparator.comparing(
metadataValue -> metadataValue.getMetadataField().getMetadataSchema().getName(), metadataValue -> metadataValue.getMetadataField().getMetadataSchema().getName(),
@@ -1373,6 +1379,8 @@ prevent the generation of resource policy entry values with null dspace_object a
return listToReturn; return listToReturn;
} }
//This method processes the Relationship of an Item and will return a list of RelationshipMetadataValue objects
//that are generated for this specfic relationship for the item through the config in VirtualMetadataPopulator
private List<RelationshipMetadataValue> handleItemRelationship(Context context, Item item, String entityType, private List<RelationshipMetadataValue> handleItemRelationship(Context context, Item item, String entityType,
Relationship relationship, Relationship relationship,
boolean enableVirtualMetadata) boolean enableVirtualMetadata)
@@ -1399,23 +1407,26 @@ prevent the generation of resource policy entry values with null dspace_object a
} }
if (hashMaps != null && enableVirtualMetadata) { if (hashMaps != null && enableVirtualMetadata) {
resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMappping(context, item, hashMaps, resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMapping(context, item, hashMaps,
otherItem, relationName, otherItem, relationName,
relationship.getID(), place)); relationship.getID(), place));
} }
RelationshipMetadataValue relationMetadataFromOtherItem = RelationshipMetadataValue relationMetadataFromOtherItem =
getRelationMetadataFromOtherItem(context, otherItem, relationName, relationship.getID()); getRelationMetadataFromOtherItem(context, otherItem, relationName, relationship.getID());
if (relationMetadataFromOtherItem != null) { if (relationMetadataFromOtherItem != null) {
resultingMetadataValueList.add(relationMetadataFromOtherItem); resultingMetadataValueList.add(relationMetadataFromOtherItem);
} }
return resultingMetadataValueList; return resultingMetadataValueList;
} }
private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMappping(Context context, Item item, //This method will retrieve a list of RelationshipMetadataValue objects based on the config passed along in the
HashMap<String, VirtualBean> //hashmaps parameter. The beans will be used to retrieve the values for the RelationshipMetadataValue objects
hashMaps, //and the keys of the hashmap will be used to construct the RelationshipMetadataValue object.
Item otherItem, String relationName, private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMapping(Context context, Item item,
Integer relationshipId, int place) HashMap<String, VirtualBean>
hashMaps,
Item otherItem, String relationName,
Integer relationshipId, int place)
throws SQLException { throws SQLException {
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>(); List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
for (Map.Entry<String, VirtualBean> entry : hashMaps.entrySet()) { for (Map.Entry<String, VirtualBean> entry : hashMaps.entrySet()) {
@@ -1475,6 +1486,8 @@ prevent the generation of resource policy entry values with null dspace_object a
return metadataValue; return metadataValue;
} }
//This method will construct a RelationshipMetadataValue object with proper schema, element and qualifier based
//on the key String parameter passed along to it
private RelationshipMetadataValue constructMetadataValue(Context context, String key) { private RelationshipMetadataValue constructMetadataValue(Context context, String key) {
String[] splittedKey = key.split("\\."); String[] splittedKey = key.split("\\.");
RelationshipMetadataValue metadataValue = new RelationshipMetadataValue(); RelationshipMetadataValue metadataValue = new RelationshipMetadataValue();

View File

@@ -86,6 +86,8 @@ public class RelationshipServiceImpl implements RelationshipService {
false); false);
context.turnOffAuthorisationSystem(); context.turnOffAuthorisationSystem();
//If useForPlace for the leftlabel is false for the relationshipType,
// we need to sort the relationships here based on leftplace.
if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), true)) { if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), true)) {
if (!leftRelationships.isEmpty()) { if (!leftRelationships.isEmpty()) {
leftRelationships.sort(Comparator.comparingInt(Relationship::getLeftPlace)); leftRelationships.sort(Comparator.comparingInt(Relationship::getLeftPlace));
@@ -101,6 +103,8 @@ public class RelationshipServiceImpl implements RelationshipService {
} }
//If useForPlace for the rightLabel is false for the relationshipType,
// we need to sort the relationships here based on the rightplace.
if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), false)) { if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), false)) {
if (!rightRelationships.isEmpty()) { if (!rightRelationships.isEmpty()) {
rightRelationships.sort(Comparator.comparingInt(Relationship::getRightPlace)); rightRelationships.sort(Comparator.comparingInt(Relationship::getRightPlace));
@@ -132,6 +136,8 @@ public class RelationshipServiceImpl implements RelationshipService {
} }
//Sets the places for the Relationship properly if the updatePlaceInRelationship was called for a new creation
//of this Relationship
private void handleCreationPlaces(Context context, Relationship relationship) throws SQLException { private void handleCreationPlaces(Context context, Relationship relationship) throws SQLException {
List<Relationship> leftRelationships; List<Relationship> leftRelationships;
List<Relationship> rightRelationships; List<Relationship> rightRelationships;

View File

@@ -40,6 +40,13 @@ public class VirtualMetadataPopulator {
return map; return map;
} }
/**
* This method will return a boolean indicating whether the useForPlace is true or false for the given
* RelationshipType for the left or right label as indicated by the second parameter.
* @param relationshipType The relationshipType for which this should be checked
* @param isLeft The boolean indicating whether to check the left or the right label
* @return A boolean indicating whether the useForPlace is true or not for the given parameters
*/
public boolean isUseForPlaceTrueForRelationshipType(RelationshipType relationshipType, boolean isLeft) { public boolean isUseForPlaceTrueForRelationshipType(RelationshipType relationshipType, boolean isLeft) {
HashMap<String, VirtualBean> hashMaps; HashMap<String, VirtualBean> hashMaps;
if (isLeft) { if (isLeft) {

View File

@@ -30,6 +30,7 @@ import org.dspace.content.service.RelationshipService;
import org.dspace.content.service.RelationshipTypeService; import org.dspace.content.service.RelationshipTypeService;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.eperson.EPerson;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@@ -104,15 +105,21 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
RelationshipType relationshipType = relationshipTypeService RelationshipType relationshipType = relationshipTypeService
.find(context, Integer.parseInt(req.getParameter("relationshipType"))); .find(context, Integer.parseInt(req.getParameter("relationshipType")));
relationship.setLeftItem(leftItem); EPerson ePerson = context.getCurrentUser();
relationship.setRightItem(rightItem); if (authorizeService.authorizeActionBoolean(context, leftItem, Constants.WRITE) ||
relationship.setRelationshipType(relationshipType); authorizeService.authorizeActionBoolean(context, rightItem, Constants.WRITE)) {
try { relationship.setLeftItem(leftItem);
relationship.setRightItem(rightItem);
relationship.setRelationshipType(relationshipType);
relationship = relationshipService.create(context, relationship); relationship = relationshipService.create(context, relationship);
} catch (AuthorizeException e) { context.turnOffAuthorisationSystem();
relationshipService.updateItem(context, relationship.getLeftItem());
relationshipService.updateItem(context, relationship.getRightItem());
context.restoreAuthSystemState();
return relationshipConverter.fromModel(relationship);
} else {
throw new AccessDeniedException("You do not have write rights on this relationship's items"); throw new AccessDeniedException("You do not have write rights on this relationship's items");
} }
return relationshipConverter.fromModel(relationship);
} else { } else {
throw new UnprocessableEntityException("The given items in the request were not valid items"); throw new UnprocessableEntityException("The given items in the request were not valid items");
} }

View File

@@ -204,6 +204,8 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
Relationship relationship3 = RelationshipBuilder Relationship relationship3 = RelationshipBuilder
.createRelationshipBuilder(context, publication, auhor1, isAuthorOfPublicationRelationshipType).build(); .createRelationshipBuilder(context, publication, auhor1, isAuthorOfPublicationRelationshipType).build();
context.restoreAuthSystemState();
getClient().perform(get("/api/core/relationships")) getClient().perform(get("/api/core/relationships"))
.andExpect(status().isOk()) .andExpect(status().isOk())
@@ -233,11 +235,11 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
Collection col3 = CollectionBuilder.createCollection(context, child1).withName("OrgUnits").build(); Collection col3 = CollectionBuilder.createCollection(context, child1).withName("OrgUnits").build();
Item author1 = ItemBuilder.createItem(context, col1) Item author1 = ItemBuilder.createItem(context, col1)
.withTitle("Author1") .withTitle("Author1")
.withIssueDate("2017-10-17") .withIssueDate("2017-10-17")
.withAuthor("Smith, Donald") .withAuthor("Smith, Donald")
.withRelationshipType("Person") .withRelationshipType("Person")
.build(); .build();
Item publication = ItemBuilder.createItem(context, col3) Item publication = ItemBuilder.createItem(context, col3)
.withTitle("Publication1") .withTitle("Publication1")
@@ -266,16 +268,20 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
authorizeService.addPolicy(context, publication, Constants.WRITE, user); authorizeService.addPolicy(context, publication, Constants.WRITE, user);
context.restoreAuthSystemState();
String token = getAuthToken(user.getEmail(), password); String token = getAuthToken(user.getEmail(), password);
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships") MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author1.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
@@ -329,6 +335,7 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
context.setCurrentUser(user); context.setCurrentUser(user);
authorizeService.addPolicy(context, author1, Constants.WRITE, user); authorizeService.addPolicy(context, author1, Constants.WRITE, user);
context.restoreAuthSystemState();
String token = getAuthToken(user.getEmail(), password); String token = getAuthToken(user.getEmail(), password);
@@ -336,10 +343,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author1.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
@@ -392,6 +401,7 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
// actually save the eperson to unit testing DB // actually save the eperson to unit testing DB
ePersonService.update(context, user); ePersonService.update(context, user);
context.setCurrentUser(user); context.setCurrentUser(user);
context.restoreAuthSystemState();
String token = getAuthToken(user.getEmail(), password); String token = getAuthToken(user.getEmail(), password);
@@ -399,15 +409,22 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author1.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author1.getID()))
.andExpect(status().isForbidden()) .andExpect(status().isForbidden())
.andReturn(); .andReturn();
} }
/**
* This method will test the addition of a mixture of plain-text metadatavalues and relationships to then
* verify that the place property is still being handled correctly.
* @throws Exception
*/
@Test @Test
public void addRelationshipsAndMetadataToValidatePlaceTest() throws Exception { public void addRelationshipsAndMetadataToValidatePlaceTest() throws Exception {
@@ -459,14 +476,18 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
String adminToken = getAuthToken(admin.getEmail(), password); String adminToken = getAuthToken(admin.getEmail(), password);
// Here we create our first Relationship to the Publication to give it a dc.contributor.author virtual
// metadata field.
MvcResult mvcResult = getClient(adminToken).perform(post("/api/core/relationships") MvcResult mvcResult = getClient(adminToken).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author1.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@@ -475,50 +496,67 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
Map<String, Object> map = mapper.readValue(content, Map.class); Map<String, Object> map = mapper.readValue(content, Map.class);
String firstRelationshipIdString = String.valueOf(map.get("id")); String firstRelationshipIdString = String.valueOf(map.get("id"));
// Here we call the relationship and verify that the relationship's leftplace is 0
getClient(adminToken).perform(get("/api/core/relationships/" + firstRelationshipIdString)) getClient(adminToken).perform(get("/api/core/relationships/" + firstRelationshipIdString))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("leftPlace", is(0))); .andExpect(jsonPath("leftPlace", is(0)));
// Make sure we grab the latest instance of the Item from the database
publication = itemService.find(context, publication.getID()); publication = itemService.find(context, publication.getID());
// Add a plain text dc.contributor.author value
itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text"); itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text");
itemService.update(context, publication); itemService.update(context, publication);
List<MetadataValue> list = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY); List<MetadataValue> list = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY);
// Ensure that the list of dc.contributor.author values now holds two values ("Smith, Donald" and "plain text")
assertEquals(2, list.size()); assertEquals(2, list.size());
for (MetadataValue mdv : list) { for (MetadataValue mdv : list) {
// Here we want to ensure that the "plain text" metadatavalue has place 1 because it was added later than
// the Relationship, so the "Smith, Donald" should have place 0 and "plain text" should have place 1
if (StringUtils.equals(mdv.getValue(), "plain text")) { if (StringUtils.equals(mdv.getValue(), "plain text")) {
assertEquals(1, mdv.getPlace()); assertEquals(1, mdv.getPlace());
} }
} }
// Testing what was describe above
MetadataValue author0MD = list.get(0); MetadataValue author0MD = list.get(0);
assertEquals("Smith, Donald", author0MD.getValue()); assertEquals("Smith, Donald", author0MD.getValue());
MetadataValue author1MD = list.get(1); MetadataValue author1MD = list.get(1);
assertEquals("plain text", author1MD.getValue()); assertEquals("plain text", author1MD.getValue());
// Verfiy the leftPlace of our relationship is still 0.
getClient(adminToken).perform(get("/api/core/relationships/" + firstRelationshipIdString)) getClient(adminToken).perform(get("/api/core/relationships/" + firstRelationshipIdString))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("leftPlace", is(0))); .andExpect(jsonPath("leftPlace", is(0)));
// Create another Relationship for the Publication, thus creating a third dc.contributor.author mdv
mvcResult = getClient(adminToken).perform(post("/api/core/relationships") mvcResult = getClient(adminToken).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
.content( (org.springframework.data.rest.webmvc.RestMediaTypes
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + .TEXT_URI_LIST_VALUE))
"https://localhost:8080/spring-rest/api/core/items/" + author2.getID())) .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author2.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
content = mvcResult.getResponse().getContentAsString(); content = mvcResult.getResponse().getContentAsString();
map = mapper.readValue(content, Map.class); map = mapper.readValue(content, Map.class);
// Grab the ID for the second relationship for future calling in the rest
String secondRelationshipIdString = String.valueOf(map.get("id")); String secondRelationshipIdString = String.valueOf(map.get("id"));
list = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY); list = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY);
// Ensure that we now have three dc.contributor.author mdv ("Smith, Donald", "plain text", "Smith, Maria"
// In that order which will be checked below the rest call
assertEquals(3, list.size()); assertEquals(3, list.size());
// Perform the REST call to the relationship to ensure its leftPlace is 2 even though it's only the second
// Relationship. Note that leftPlace 1 was skipped due to the dc.contributor.author plain text value and
// This is expected behaviour and should be tested
getClient(adminToken).perform(get("/api/core/relationships/" + secondRelationshipIdString)) getClient(adminToken).perform(get("/api/core/relationships/" + secondRelationshipIdString))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("leftPlace", is(2))); .andExpect(jsonPath("leftPlace", is(2)));
@@ -530,15 +568,16 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
MetadataValue author2MD = list.get(2); MetadataValue author2MD = list.get(2);
assertEquals("Smith, Maria", author2MD.getValue()); assertEquals("Smith, Maria", author2MD.getValue());
// Ensure we have the latest instance of the Item from the database
publication = itemService.find(context, publication.getID()); publication = itemService.find(context, publication.getID());
// Add a fourth dc.contributor.author mdv
itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text two"); itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text two");
// itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text three");
itemService.update(context, publication); itemService.update(context, publication);
// itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text four");
// itemService.update(context, publication);
list = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY); list = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY);
// Assert that the list of dc.contributor.author mdv is now of size 4 in the following order:
// "Smith, Donald", "plain text", "Smith, Maria", "plain text two"
assertEquals(4, list.size()); assertEquals(4, list.size());
for (MetadataValue mdv : list) { for (MetadataValue mdv : list) {
if (StringUtils.equals(mdv.getValue(), "plain text two")) { if (StringUtils.equals(mdv.getValue(), "plain text two")) {
@@ -556,27 +595,37 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
assertEquals("plain text two", author3MD.getValue()); assertEquals("plain text two", author3MD.getValue());
// Create the third Relationship thus adding a fifth dc.contributor.author mdv
mvcResult = getClient(adminToken).perform(post("/api/core/relationships") mvcResult = getClient(adminToken).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author3.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author3.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
content = mvcResult.getResponse().getContentAsString(); content = mvcResult.getResponse().getContentAsString();
map = mapper.readValue(content, Map.class); map = mapper.readValue(content, Map.class);
// Save the third Relationship's ID for future calling
String thirdRelationshipIdString = String.valueOf(map.get("id")); String thirdRelationshipIdString = String.valueOf(map.get("id"));
list = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY); list = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY);
// Assert that our dc.contributor.author mdv list is now of size 5
assertEquals(5, list.size()); assertEquals(5, list.size());
// Assert that the third Relationship has leftPlace 4, even though 3 relationships were created.
// This is because the plain text values 'occupy' place 1 and 3.
getClient(adminToken).perform(get("/api/core/relationships/" + thirdRelationshipIdString)) getClient(adminToken).perform(get("/api/core/relationships/" + thirdRelationshipIdString))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("leftPlace", is(4))); .andExpect(jsonPath("leftPlace", is(4)));
// Assert that the list is of size 5 and in the following order:
// "Smith, Donald", "plain text", "Smith, Maria", "plain text two", "Maybe, Maybe"
// Thus the order they were added in
author0MD = list.get(0); author0MD = list.get(0);
assertEquals("Smith, Donald", author0MD.getValue()); assertEquals("Smith, Donald", author0MD.getValue());
author1MD = list.get(1); author1MD = list.get(1);
@@ -588,6 +637,7 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
MetadataValue author4MD = list.get(4); MetadataValue author4MD = list.get(4);
assertEquals("Maybe, Maybe", author4MD.getValue()); assertEquals("Maybe, Maybe", author4MD.getValue());
// The following additions of Metadata will perform the same sequence of logic and tests as described above
publication = itemService.find(context, publication.getID()); publication = itemService.find(context, publication.getID());
itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text three"); itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text three");
itemService.update(context, publication); itemService.update(context, publication);
@@ -669,6 +719,11 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
assertEquals(20, list.size()); //also includes type and 3 relation.isAuthorOfPublication values assertEquals(20, list.size()); //also includes type and 3 relation.isAuthorOfPublication values
} }
/**
* This method will test the deletion of a plain-text metadatavalue to then
* verify that the place property is still being handled correctly.
* @throws Exception
*/
@Test @Test
public void deleteMetadataValueAndValidatePlace() throws Exception { public void deleteMetadataValueAndValidatePlace() throws Exception {
@@ -720,15 +775,18 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
String adminToken = getAuthToken(admin.getEmail(), password); String adminToken = getAuthToken(admin.getEmail(), password);
// First create the structure of 5 metadatavalues just like the additions test.
MvcResult mvcResult = getClient(adminToken).perform(post("/api/core/relationships") MvcResult mvcResult = getClient(adminToken).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author1.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@@ -762,10 +820,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author2.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author2.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
@@ -779,11 +839,8 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
publication = itemService.find(context, publication.getID()); publication = itemService.find(context, publication.getID());
itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text two"); itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text two");
// itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text three");
itemService.update(context, publication); itemService.update(context, publication);
// itemService.addMetadata(context, publication, "dc", "contributor", "author", Item.ANY, "plain text four");
// itemService.update(context, publication);
list = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY); list = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY);
for (MetadataValue mdv : list) { for (MetadataValue mdv : list) {
@@ -797,10 +854,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author3.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author3.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
@@ -824,6 +883,8 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
} }
} }
// Now we will have a dc.contributor.author metadatavalue list of size 5 in the following order:
// "Smith, Donald", "plain text", "Smith, Maria", "plain text two", "Maybe, Maybe"
List<MetadataValue> authors = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY); List<MetadataValue> authors = itemService.getMetadata(publication, "dc", "contributor", "author", Item.ANY);
List<MetadataValue> listToRemove = new LinkedList<>(); List<MetadataValue> listToRemove = new LinkedList<>();
for (MetadataValue metadataValue : authors) { for (MetadataValue metadataValue : authors) {
@@ -831,6 +892,9 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
listToRemove.add(metadataValue); listToRemove.add(metadataValue);
} }
} }
// Remove the "plain text two" metadatavalue. Ensure that all mdvs prior to that in the list are unchanged
// And ensure that the ones coming after this mdv have its place lowered by one.
itemService.removeMetadataValues(context, publication, listToRemove); itemService.removeMetadataValues(context, publication, listToRemove);
itemService.update(context, publication); itemService.update(context, publication);
@@ -861,6 +925,11 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
} }
/**
* This method will test the deletion of a Relationship to then
* verify that the place property is still being handled correctly.
* @throws Exception
*/
@Test @Test
public void deleteRelationshipsAndValidatePlace() throws Exception { public void deleteRelationshipsAndValidatePlace() throws Exception {
@@ -912,15 +981,18 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
String adminToken = getAuthToken(admin.getEmail(), password); String adminToken = getAuthToken(admin.getEmail(), password);
// First create the structure of 5 metadatavalues just like the additions test.
MvcResult mvcResult = getClient(adminToken).perform(post("/api/core/relationships") MvcResult mvcResult = getClient(adminToken).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author1.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@@ -954,10 +1026,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author2.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author2.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
@@ -986,10 +1060,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author3.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author3.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
@@ -1014,6 +1090,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
} }
// Now we will have a dc.contributor.author metadatavalue list of size 5 in the following order:
// "Smith, Donald", "plain text", "Smith, Maria", "plain text two", "Maybe, Maybe"
// Now we delete the second relationship, the one that made "Smith, Maria" metadatavalue
// Ensure that all metadatavalues before this one in the list still hold the same place
// Ensure that all the metadatavalues after this one have their place lowered by one
getClient(adminToken).perform(delete("/api/core/relationships/" + secondRelationshipIdString)); getClient(adminToken).perform(delete("/api/core/relationships/" + secondRelationshipIdString));
getClient(adminToken).perform(get("/api/core/relationships/" + firstRelationshipIdString)) getClient(adminToken).perform(get("/api/core/relationships/" + firstRelationshipIdString))
@@ -1052,6 +1134,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
} }
/**
* This test will simply add Relationships between Items with a useForPlace attribute set to false for the
* RelationshipType. We want to test that the Relationships that are created will still have their place
* attributes handled in a correct way
* @throws Exception
*/
@Test @Test
public void addRelationshipsNotUseForPlace() throws Exception { public void addRelationshipsNotUseForPlace() throws Exception {
@@ -1101,14 +1189,18 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
String adminToken = getAuthToken(admin.getEmail(), password); String adminToken = getAuthToken(admin.getEmail(), password);
// This is essentially a sequence of adding Relationships by POST and then checking with GET to see
// if the place is being set properly.
MvcResult mvcResult = getClient(adminToken).perform(post("/api/core/relationships") MvcResult mvcResult = getClient(adminToken).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isOrgUnitOfPersonRelationshipType.getID() isOrgUnitOfPersonRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + author1.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + author1.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID())) "https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@@ -1124,10 +1216,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
mvcResult = getClient(adminToken).perform(post("/api/core/relationships") mvcResult = getClient(adminToken).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isOrgUnitOfPersonRelationshipType.getID().toString()) isOrgUnitOfPersonRelationshipType.getID().toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
.content( (org.springframework.data.rest.webmvc.RestMediaTypes
"https://localhost:8080/spring-rest/api/core/items/" + author2.getID() + "\n" + .TEXT_URI_LIST_VALUE))
"https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID())) .content(
"https://localhost:8080/spring-rest/api/core/items/" + author2.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
mapper = new ObjectMapper(); mapper = new ObjectMapper();
@@ -1143,10 +1237,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
mvcResult = getClient(adminToken).perform(post("/api/core/relationships") mvcResult = getClient(adminToken).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isOrgUnitOfPersonRelationshipType.getID().toString()) isOrgUnitOfPersonRelationshipType.getID().toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
.content( (org.springframework.data.rest.webmvc.RestMediaTypes
"https://localhost:8080/spring-rest/api/core/items/" + author3.getID() + "\n" + .TEXT_URI_LIST_VALUE))
"https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID())) .content(
"https://localhost:8080/spring-rest/api/core/items/" + author3.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
mapper = new ObjectMapper(); mapper = new ObjectMapper();
@@ -1160,6 +1256,13 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
.andExpect(jsonPath("rightPlace", is(2))); .andExpect(jsonPath("rightPlace", is(2)));
} }
/**
* This test will simply add Relationships between Items with a useForPlace attribute set to false for the
* RelationshipType. We want to test that the Relationships that are created will still have their place
* attributes handled in a correct way. It will then delete a Relationship and once again ensure that the place
* attributes are being handled correctly.
* @throws Exception
*/
@Test @Test
public void addAndDeleteRelationshipsNotUseForPlace() throws Exception { public void addAndDeleteRelationshipsNotUseForPlace() throws Exception {
@@ -1209,14 +1312,18 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
String adminToken = getAuthToken(admin.getEmail(), password); String adminToken = getAuthToken(admin.getEmail(), password);
// This is essentially a sequence of adding Relationships by POST and then checking with GET to see
// if the place is being set properly.
MvcResult mvcResult = getClient(adminToken).perform(post("/api/core/relationships") MvcResult mvcResult = getClient(adminToken).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isOrgUnitOfPersonRelationshipType.getID() isOrgUnitOfPersonRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
.content( (org.springframework.data.rest.webmvc.RestMediaTypes
"https://localhost:8080/spring-rest/api/core/items/" + author1.getID() + "\n" + .TEXT_URI_LIST_VALUE))
"https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID())) .content(
"https://localhost:8080/spring-rest/api/core/items/" + author1.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@@ -1232,10 +1339,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
mvcResult = getClient(adminToken).perform(post("/api/core/relationships") mvcResult = getClient(adminToken).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isOrgUnitOfPersonRelationshipType.getID().toString()) isOrgUnitOfPersonRelationshipType.getID().toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
.content( (org.springframework.data.rest.webmvc.RestMediaTypes
"https://localhost:8080/spring-rest/api/core/items/" + author2.getID() + "\n" + .TEXT_URI_LIST_VALUE))
"https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID())) .content(
"https://localhost:8080/spring-rest/api/core/items/" + author2.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
mapper = new ObjectMapper(); mapper = new ObjectMapper();
@@ -1251,10 +1360,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
mvcResult = getClient(adminToken).perform(post("/api/core/relationships") mvcResult = getClient(adminToken).perform(post("/api/core/relationships")
.param("relationshipType", .param("relationshipType",
isOrgUnitOfPersonRelationshipType.getID().toString()) isOrgUnitOfPersonRelationshipType.getID().toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
.content( (org.springframework.data.rest.webmvc.RestMediaTypes
"https://localhost:8080/spring-rest/api/core/items/" + author3.getID() + "\n" + .TEXT_URI_LIST_VALUE))
"https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID())) .content(
"https://localhost:8080/spring-rest/api/core/items/" + author3.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + orgUnit1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
mapper = new ObjectMapper(); mapper = new ObjectMapper();
@@ -1267,6 +1378,7 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("rightPlace", is(2))); .andExpect(jsonPath("rightPlace", is(2)));
// Here we will delete the secondRelationship and then verify that the others have their place handled properly
getClient(adminToken).perform(delete("/api/core/relationships/" + secondRelationshipIdString)); getClient(adminToken).perform(delete("/api/core/relationships/" + secondRelationshipIdString));
getClient(adminToken).perform(get("/api/core/relationships/" + firstRelationshipIdString)) getClient(adminToken).perform(get("/api/core/relationships/" + firstRelationshipIdString))
@@ -1328,10 +1440,12 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
.param("relationshipType", .param("relationshipType",
isAuthorOfPublicationRelationshipType.getID() isAuthorOfPublicationRelationshipType.getID()
.toString()) .toString())
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
(org.springframework.data.rest.webmvc.RestMediaTypes
.TEXT_URI_LIST_VALUE))
.content( .content(
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
"https://localhost:8080/spring-rest/api/core/items/" + author1.getID())) "https://localhost:8080/spring-rest/api/core/items/" + author1.getID()))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andReturn(); .andReturn();
@@ -1341,12 +1455,14 @@ public class RelationshipRestRepositoryIT extends AbstractControllerIntegrationT
String id = String.valueOf(map.get("id")); String id = String.valueOf(map.get("id"));
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id) MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id)
.contentType(MediaType.parseMediaType("text/uri-list")) .contentType(MediaType.parseMediaType
.content( (org.springframework.data.rest.webmvc.RestMediaTypes
"https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" + .TEXT_URI_LIST_VALUE))
"https://localhost:8080/spring-rest/api/core/items/" + author2.getID())) .content(
.andExpect(status().isOk()) "https://localhost:8080/spring-rest/api/core/items/" + publication.getID() + "\n" +
.andReturn(); "https://localhost:8080/spring-rest/api/core/items/" + author2.getID()))
.andExpect(status().isOk())
.andReturn();
getClient(token).perform(get("/api/core/relationships/" + id)) getClient(token).perform(get("/api/core/relationships/" + id))
.andExpect(status().isOk()) .andExpect(status().isOk())