mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 23:43:06 +00:00
Merge branch 'feature-name-variants' of https://github.com/atmire/DSpace into feature-name-variants
# Conflicts: # dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java # dspace-api/src/main/java/org/dspace/content/RelationshipMetadataServiceImpl.java
This commit is contained in:
@@ -1341,8 +1341,8 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
//except for relation.type which is the type of item in the model
|
//except for relation.type which is the type of item in the model
|
||||||
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName()) && !StringUtils.equals(element, "type")) {
|
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName()) && !StringUtils.equals(element, "type")) {
|
||||||
|
|
||||||
List<RelationshipMetadataValue> relationMetadata =
|
List<RelationshipMetadataValue> relationMetadata = relationshipMetadataService
|
||||||
relationshipMetadataService.getRelationshipMetadata(item, false);
|
.getRelationshipMetadata(item, false);
|
||||||
List<MetadataValue> listToReturn = new LinkedList<>();
|
List<MetadataValue> listToReturn = new LinkedList<>();
|
||||||
for (MetadataValue metadataValue : relationMetadata) {
|
for (MetadataValue metadataValue : relationMetadata) {
|
||||||
if (StringUtils.equals(metadataValue.getMetadataField().getElement(), element)) {
|
if (StringUtils.equals(metadataValue.getMetadataField().getElement(), element)) {
|
||||||
@@ -1398,6 +1398,4 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -85,19 +85,21 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
String relationName;
|
String relationName;
|
||||||
Item otherItem;
|
Item otherItem;
|
||||||
int place = 0;
|
int place = 0;
|
||||||
boolean isLeft;
|
boolean isLeftwards;
|
||||||
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) {
|
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) {
|
||||||
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getLeftwardLabel());
|
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getLeftwardLabel());
|
||||||
otherItem = relationship.getRightItem();
|
otherItem = relationship.getRightItem();
|
||||||
relationName = relationship.getRelationshipType().getLeftwardLabel();
|
relationName = relationship.getRelationshipType().getLeftwardLabel();
|
||||||
place = relationship.getLeftPlace();
|
place = relationship.getLeftPlace();
|
||||||
isLeft = true;
|
isLeftwards = false; //if the current item is stored on the left,
|
||||||
|
// the name variant is retrieved from the rightwards label
|
||||||
} else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType)) {
|
} else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType)) {
|
||||||
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getRightwardLabel());
|
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getRightwardLabel());
|
||||||
otherItem = relationship.getLeftItem();
|
otherItem = relationship.getLeftItem();
|
||||||
relationName = relationship.getRelationshipType().getRightwardLabel();
|
relationName = relationship.getRelationshipType().getRightwardLabel();
|
||||||
place = relationship.getRightPlace();
|
place = relationship.getRightPlace();
|
||||||
isLeft = false;
|
isLeftwards = true; //if the current item is stored on the right,
|
||||||
|
// the name variant is retrieved from the leftwards label
|
||||||
} else {
|
} else {
|
||||||
//No virtual metadata can be created
|
//No virtual metadata can be created
|
||||||
return resultingMetadataValueList;
|
return resultingMetadataValueList;
|
||||||
@@ -106,7 +108,7 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
if (hashMaps != null && enableVirtualMetadata) {
|
if (hashMaps != null && enableVirtualMetadata) {
|
||||||
resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMapping(context, item, hashMaps,
|
resultingMetadataValueList.addAll(handleRelationshipTypeMetadataMapping(context, item, hashMaps,
|
||||||
otherItem, relationName,
|
otherItem, relationName,
|
||||||
relationship, place, isLeft));
|
relationship, place, isLeftwards));
|
||||||
}
|
}
|
||||||
RelationshipMetadataValue relationMetadataFromOtherItem =
|
RelationshipMetadataValue relationMetadataFromOtherItem =
|
||||||
getRelationMetadataFromOtherItem(context, otherItem, relationName, relationship.getID(), place);
|
getRelationMetadataFromOtherItem(context, otherItem, relationName, relationship.getID(), place);
|
||||||
@@ -120,10 +122,8 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
//hashmaps parameter. The beans will be used to retrieve the values for the RelationshipMetadataValue objects
|
//hashmaps parameter. The beans will be used to retrieve the values for the RelationshipMetadataValue objects
|
||||||
//and the keys of the hashmap will be used to construct the RelationshipMetadataValue object.
|
//and the keys of the hashmap will be used to construct the RelationshipMetadataValue object.
|
||||||
private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMapping(Context context, Item item,
|
private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMapping(Context context, Item item,
|
||||||
HashMap<String, VirtualMetadataConfiguration> hashMaps,
|
HashMap<String, VirtualMetadataConfiguration> hashMaps, Item otherItem, String relationName,
|
||||||
Item otherItem, String relationName,
|
Relationship relationship, int place, boolean isLeftwards) throws SQLException {
|
||||||
Relationship relationship, int place,
|
|
||||||
boolean isLeft) throws SQLException {
|
|
||||||
|
|
||||||
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
|
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
|
||||||
for (Map.Entry<String, VirtualMetadataConfiguration> entry : hashMaps.entrySet()) {
|
for (Map.Entry<String, VirtualMetadataConfiguration> entry : hashMaps.entrySet()) {
|
||||||
@@ -131,20 +131,18 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
VirtualMetadataConfiguration virtualBean = entry.getValue();
|
VirtualMetadataConfiguration virtualBean = entry.getValue();
|
||||||
|
|
||||||
if (virtualBean.getPopulateWithNameVariant()) {
|
if (virtualBean.getPopulateWithNameVariant()) {
|
||||||
String wardLabel = isLeft ? relationship.getLeftwardLabel() : relationship.getRightwardLabel();
|
String wardLabel = isLeftwards ? relationship.getLeftwardLabel() : relationship.getRightwardLabel();
|
||||||
if (wardLabel != null) {
|
if (wardLabel != null) {
|
||||||
resultingMetadataValueList.add(
|
resultingMetadataValueList.add(
|
||||||
constructRelationshipMetadataValue(
|
constructRelationshipMetadataValue(context, item, relationship.getID(), place, key, virtualBean,
|
||||||
context, item, relationship.getID(), place, key, virtualBean, wardLabel
|
wardLabel));
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
handleVirtualBeanValues(
|
handleVirtualBeanValues(context, item, otherItem, relationship, place, resultingMetadataValueList,
|
||||||
context, item, otherItem, relationship, place, resultingMetadataValueList, key, virtualBean);
|
key, virtualBean);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
handleVirtualBeanValues(
|
handleVirtualBeanValues(context, item, otherItem, relationship, place, resultingMetadataValueList, key,
|
||||||
context, item, otherItem, relationship, place, resultingMetadataValueList, key, virtualBean
|
virtualBean);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resultingMetadataValueList;
|
return resultingMetadataValueList;
|
||||||
@@ -154,15 +152,20 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
int place, List<RelationshipMetadataValue> resultingMetadataValueList,
|
int place, List<RelationshipMetadataValue> resultingMetadataValueList,
|
||||||
String key, VirtualMetadataConfiguration virtualBean) throws SQLException {
|
String key, VirtualMetadataConfiguration virtualBean) throws SQLException {
|
||||||
for (String value : virtualBean.getValues(context, otherItem)) {
|
for (String value : virtualBean.getValues(context, otherItem)) {
|
||||||
resultingMetadataValueList.add(
|
RelationshipMetadataValue relationshipMetadataValue = constructRelationshipMetadataValue(context, item,
|
||||||
constructRelationshipMetadataValue(context, item, relationship.getID(), place, key, virtualBean, value)
|
relationship
|
||||||
);
|
.getID(),
|
||||||
|
place,
|
||||||
|
key, virtualBean,
|
||||||
|
value);
|
||||||
|
if (relationshipMetadataValue != null) {
|
||||||
|
resultingMetadataValueList.add(relationshipMetadataValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RelationshipMetadataValue constructRelationshipMetadataValue(Context context, Item item,
|
private RelationshipMetadataValue constructRelationshipMetadataValue(Context context, Item item,
|
||||||
Integer relationshipId,
|
Integer relationshipId, int place,
|
||||||
int place,
|
|
||||||
String key,
|
String key,
|
||||||
VirtualMetadataConfiguration virtualBean,
|
VirtualMetadataConfiguration virtualBean,
|
||||||
String value) {
|
String value) {
|
||||||
|
@@ -7,11 +7,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest;
|
package org.dspace.app.rest;
|
||||||
|
|
||||||
|
import static org.dspace.app.rest.matcher.MetadataMatcher.matchMetadata;
|
||||||
|
import static org.hamcrest.Matchers.allOf;
|
||||||
import static org.hamcrest.Matchers.contains;
|
import static org.hamcrest.Matchers.contains;
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.hasItem;
|
import static org.hamcrest.Matchers.hasItem;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
|
||||||
@@ -264,8 +267,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -304,8 +309,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -340,15 +347,17 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isForbidden())
|
.andExpect(status().isForbidden())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createRelationShipWithLeftwardLabel() throws Exception {
|
public void createRelationshipWithLeftwardLabel() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
||||||
@@ -362,14 +371,17 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
|
|
||||||
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
||||||
.param("relationshipType",
|
.param("relationshipType",
|
||||||
isAuthorOfPublicationRelationshipType.getID().toString())
|
isAuthorOfPublicationRelationshipType.getID()
|
||||||
|
.toString())
|
||||||
.param("leftwardLabel", leftwardLabel)
|
.param("leftwardLabel", leftwardLabel)
|
||||||
.contentType(MediaType.parseMediaType
|
.contentType(MediaType.parseMediaType
|
||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -387,7 +399,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createRelationShipWithRightWardLabel() throws Exception {
|
public void createRelationshipWithRightwardLabel() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
||||||
@@ -401,14 +413,17 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
|
|
||||||
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
||||||
.param("relationshipType",
|
.param("relationshipType",
|
||||||
isAuthorOfPublicationRelationshipType.getID().toString())
|
isAuthorOfPublicationRelationshipType.getID()
|
||||||
|
.toString())
|
||||||
.param("rightwardLabel", rightwardLabel)
|
.param("rightwardLabel", rightwardLabel)
|
||||||
.contentType(MediaType.parseMediaType
|
.contentType(MediaType.parseMediaType
|
||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -426,7 +441,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createRelationShipWithRightWardlabelAndLeftWardLabel() throws Exception {
|
public void createRelationshipWithRightwardLabelAndLeftwardLabel() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
||||||
@@ -441,15 +456,18 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
|
|
||||||
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
||||||
.param("relationshipType",
|
.param("relationshipType",
|
||||||
isAuthorOfPublicationRelationshipType.getID().toString())
|
isAuthorOfPublicationRelationshipType.getID()
|
||||||
|
.toString())
|
||||||
.param("leftwardLabel", leftwardLabel)
|
.param("leftwardLabel", leftwardLabel)
|
||||||
.param("rightwardLabel", rightwardLabel)
|
.param("rightwardLabel", rightwardLabel)
|
||||||
.contentType(MediaType.parseMediaType
|
.contentType(MediaType.parseMediaType
|
||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -467,7 +485,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createRelationShipAndAddLeftWardLabelAfterwards() throws Exception {
|
public void createRelationshipAndAddLeftwardLabelAfterwards() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
||||||
@@ -481,13 +499,16 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
|
|
||||||
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
||||||
.param("relationshipType",
|
.param("relationshipType",
|
||||||
isAuthorOfPublicationRelationshipType.getID().toString())
|
isAuthorOfPublicationRelationshipType.getID()
|
||||||
|
.toString())
|
||||||
.contentType(MediaType.parseMediaType
|
.contentType(MediaType.parseMediaType
|
||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -522,7 +543,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createRelationShipThenAddLabelsAndRemoveThem() throws Exception {
|
public void createRelationshipThenAddLabelsAndRemoveThem() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
||||||
@@ -537,13 +558,16 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
|
|
||||||
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
||||||
.param("relationshipType",
|
.param("relationshipType",
|
||||||
isAuthorOfPublicationRelationshipType.getID().toString())
|
isAuthorOfPublicationRelationshipType.getID()
|
||||||
|
.toString())
|
||||||
.contentType(MediaType.parseMediaType
|
.contentType(MediaType.parseMediaType
|
||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -650,8 +674,11 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items" +
|
||||||
|
"/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
@@ -706,8 +733,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author2.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -772,8 +801,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author3.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author3
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -933,8 +964,11 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items" +
|
||||||
|
"/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
@@ -981,8 +1015,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author2.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -1022,8 +1058,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author3.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author3
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -1136,8 +1174,11 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items" +
|
||||||
|
"/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
@@ -1184,8 +1225,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author2.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -1225,8 +1268,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author3.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author3
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -1330,8 +1375,12 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/spring-rest/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/spring-rest/api/core" +
|
||||||
"https://localhost:8080/spring-rest/api/core/items/" + author1.getID()))
|
"/items/" + publication1
|
||||||
|
.getID() + "\n" +
|
||||||
|
"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();
|
||||||
@@ -1368,8 +1417,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/spring-rest/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/spring-rest/api/core/items/" + publication1
|
||||||
"https://localhost:8080/spring-rest/api/core/items/" + author2.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/spring-rest/api/core/items/" + author2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -1466,8 +1517,11 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
"https://localhost:8080/server/api/core/items/" + orgUnit1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items" +
|
||||||
|
"/" + orgUnit1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
@@ -1487,8 +1541,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + author2.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + author2
|
||||||
"https://localhost:8080/server/api/core/items/" + orgUnit1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + orgUnit1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
@@ -1508,8 +1564,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + author3.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + author3
|
||||||
"https://localhost:8080/server/api/core/items/" + orgUnit1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + orgUnit1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
@@ -1545,8 +1603,11 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
"https://localhost:8080/server/api/core/items/" + orgUnit1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items" +
|
||||||
|
"/" + orgUnit1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
@@ -1566,8 +1627,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + author2.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + author2
|
||||||
"https://localhost:8080/server/api/core/items/" + orgUnit1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + orgUnit1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
@@ -1587,8 +1650,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + author3.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + author3
|
||||||
"https://localhost:8080/server/api/core/items/" + orgUnit1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + orgUnit1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
@@ -1635,14 +1700,16 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
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 id = String.valueOf(map.get("id"));
|
String id = String.valueOf(map.get("id"));
|
||||||
|
|
||||||
//Modify the left item in the relationship publication > publication 2
|
//Modify the left item in the relationship publication > publication 2
|
||||||
@@ -1651,7 +1718,8 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication2.getID()))
|
"https://localhost:8080/server/api/core/items/" + publication2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -1669,7 +1737,8 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + author2.getID()))
|
"https://localhost:8080/server/api/core/items/" + author2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -1708,20 +1777,24 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
.toString())
|
.toString())
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
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 id = String.valueOf(map.get("id"));
|
String id = String.valueOf(map.get("id"));
|
||||||
|
|
||||||
//change right item from author 1 > author 2
|
//change right item from author 1 > author 2
|
||||||
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/rightItem")
|
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/rightItem")
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content("https://localhost:8080/server/api/core/items/" + author2.getID()))
|
.content(
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
//verify change and other not changed
|
//verify change and other not changed
|
||||||
@@ -1758,19 +1831,23 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
.toString())
|
.toString())
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
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 id = String.valueOf(map.get("id"));
|
String id = String.valueOf(map.get("id"));
|
||||||
//change rightItem from author1 > author2
|
//change rightItem from author1 > author2
|
||||||
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/rightItem")
|
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/rightItem")
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content("https://localhost:8080/server/api/core/items/" + author2.getID()))
|
.content(
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
//verify right item change and other not changed
|
//verify right item change and other not changed
|
||||||
@@ -1809,19 +1886,23 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
.toString())
|
.toString())
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
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 id = String.valueOf(map.get("id"));
|
String id = String.valueOf(map.get("id"));
|
||||||
//change leftItem
|
//change leftItem
|
||||||
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/leftItem")
|
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/leftItem")
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content("https://localhost:8080/server/api/core/items/" + publication2.getID()))
|
.content(
|
||||||
|
"https://localhost:8080/server/api/core/items/" + publication2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
//verify change and other not changed
|
//verify change and other not changed
|
||||||
@@ -1866,12 +1947,14 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
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 id = String.valueOf(map.get("id"));
|
String id = String.valueOf(map.get("id"));
|
||||||
//change left item
|
//change left item
|
||||||
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/leftItem")
|
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/leftItem")
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content("https://localhost:8080/server/api/core/items/" + publication2.getID()))
|
.content(
|
||||||
|
"https://localhost:8080/server/api/core/items/" + publication2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
//verify change and other not changed
|
//verify change and other not changed
|
||||||
@@ -1906,20 +1989,24 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
.toString())
|
.toString())
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
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 id = String.valueOf(map.get("id"));
|
String id = String.valueOf(map.get("id"));
|
||||||
token = getAuthToken(user1.getEmail(), password);
|
token = getAuthToken(user1.getEmail(), password);
|
||||||
//attempt change, expect not allowed
|
//attempt change, expect not allowed
|
||||||
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/rightItem")
|
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/rightItem")
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content("https://localhost:8080/server/api/core/items/" + author2.getID()))
|
.content(
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isForbidden())
|
.andExpect(status().isForbidden())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
//verify nothing changed
|
//verify nothing changed
|
||||||
@@ -1955,20 +2042,24 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
.toString())
|
.toString())
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
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 id = String.valueOf(map.get("id"));
|
String id = String.valueOf(map.get("id"));
|
||||||
token = getAuthToken(user1.getEmail(), password);
|
token = getAuthToken(user1.getEmail(), password);
|
||||||
//attempt right item change, expect not allowed
|
//attempt right item change, expect not allowed
|
||||||
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/rightItem")
|
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/rightItem")
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content("https://localhost:8080/server/api/core/items/" + author2.getID()))
|
.content(
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isForbidden())
|
.andExpect(status().isForbidden())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
//verify not changed
|
//verify not changed
|
||||||
@@ -2004,19 +2095,23 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
.toString())
|
.toString())
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
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 id = String.valueOf(map.get("id"));
|
String id = String.valueOf(map.get("id"));
|
||||||
//attempt left item change, expect not allowed
|
//attempt left item change, expect not allowed
|
||||||
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/leftItem")
|
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/leftItem")
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content("https://localhost:8080/server/api/core/items/" + publication2.getID()))
|
.content(
|
||||||
|
"https://localhost:8080/server/api/core/items/" + publication2
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isForbidden())
|
.andExpect(status().isForbidden())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
//verify not changed
|
//verify not changed
|
||||||
@@ -2131,8 +2226,10 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
.toString())
|
.toString())
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content(
|
.content(
|
||||||
"https://localhost:8080/server/api/core/items/" + publication1.getID() + "\n" +
|
"https://localhost:8080/server/api/core/items/" + publication1
|
||||||
"https://localhost:8080/server/api/core/items/" + author1.getID()))
|
.getID() + "\n" +
|
||||||
|
"https://localhost:8080/server/api/core/items/" + author1
|
||||||
|
.getID()))
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
@@ -2145,9 +2242,163 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
//attempt left item change on non-existent relationship
|
//attempt left item change on non-existent relationship
|
||||||
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/leftItem")
|
MvcResult mvcResult2 = getClient(token).perform(put("/api/core/relationships/" + id + "/leftItem")
|
||||||
.contentType(MediaType.parseMediaType("text/uri-list"))
|
.contentType(MediaType.parseMediaType("text/uri-list"))
|
||||||
.content("https://localhost:8080/server/api/core/items/" + nonexistentItemID))
|
.content(
|
||||||
|
"https://localhost:8080/server/api/core/items/" + nonexistentItemID))
|
||||||
.andExpect(status().isUnprocessableEntity())
|
.andExpect(status().isUnprocessableEntity())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void leftWardLabelRelationshipTest() throws Exception {
|
||||||
|
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
|
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
|
Relationship relationship3 = RelationshipBuilder
|
||||||
|
.createRelationshipBuilder(context, publication1, author1, isAuthorOfPublicationRelationshipType)
|
||||||
|
.withLeftWardLabel("LeftWardLabelTest").build();
|
||||||
|
|
||||||
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
|
getClient().perform(get("/api/core/relationships"))
|
||||||
|
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.page",
|
||||||
|
is(PageMatcher.pageEntryWithTotalPagesAndElements(0, 20, 1, 1))))
|
||||||
|
.andExpect(jsonPath("$._embedded.relationships", containsInAnyOrder(
|
||||||
|
RelationshipMatcher.matchRelationship(relationship3)
|
||||||
|
)))
|
||||||
|
;
|
||||||
|
|
||||||
|
getClient().perform(get("/api/core/items/" + publication1.getID()))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.metadata", allOf(
|
||||||
|
matchMetadata("dc.contributor.author", "LeftWardLabelTest"),
|
||||||
|
matchMetadata("dc.title", "Publication1"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nonLeftWardLabelRelationshipTest() throws Exception {
|
||||||
|
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
|
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
|
Relationship relationship3 = RelationshipBuilder
|
||||||
|
.createRelationshipBuilder(context, publication1, author3, isAuthorOfPublicationRelationshipType)
|
||||||
|
.withLeftPlace(1).build();
|
||||||
|
|
||||||
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
|
getClient().perform(get("/api/core/relationships"))
|
||||||
|
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.page",
|
||||||
|
is(PageMatcher.pageEntryWithTotalPagesAndElements(0, 20, 1, 1))))
|
||||||
|
.andExpect(jsonPath("$._embedded.relationships", containsInAnyOrder(
|
||||||
|
RelationshipMatcher.matchRelationship(relationship3)
|
||||||
|
)))
|
||||||
|
;
|
||||||
|
|
||||||
|
getClient().perform(get("/api/core/items/" + publication1.getID()))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.metadata", allOf(
|
||||||
|
matchMetadata("dc.contributor.author", "Maybe, Maybe"),
|
||||||
|
matchMetadata("dc.contributor.author", "Testy, TEst"),
|
||||||
|
matchMetadata("dc.title", "Publication1"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void mixedLeftWardLabelAndRegularRelationshipTest() throws Exception {
|
||||||
|
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
|
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
|
Item author1 = ItemBuilder.createItem(context, col1)
|
||||||
|
.withTitle("Author1")
|
||||||
|
.withIssueDate("2017-10-17")
|
||||||
|
.withAuthor("Smith, Donald")
|
||||||
|
.withPersonIdentifierFirstName("testingFirstName")
|
||||||
|
.withPersonIdentifierLastName("testingLastName")
|
||||||
|
.withRelationshipType("Person")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Relationship relationship3 = RelationshipBuilder
|
||||||
|
.createRelationshipBuilder(context, publication1, author3, isAuthorOfPublicationRelationshipType)
|
||||||
|
.withLeftPlace(1).build();
|
||||||
|
|
||||||
|
Relationship relationship2 = RelationshipBuilder
|
||||||
|
.createRelationshipBuilder(context, publication1, author1, isAuthorOfPublicationRelationshipType)
|
||||||
|
.withLeftWardLabel("TestingLeftWardLabel").build();
|
||||||
|
|
||||||
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
|
getClient().perform(get("/api/core/relationships"))
|
||||||
|
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.page",
|
||||||
|
is(PageMatcher.pageEntryWithTotalPagesAndElements(0, 20, 1, 2))))
|
||||||
|
.andExpect(jsonPath("$._embedded.relationships", containsInAnyOrder(
|
||||||
|
RelationshipMatcher.matchRelationship(relationship3),
|
||||||
|
RelationshipMatcher.matchRelationship(relationship2)
|
||||||
|
)))
|
||||||
|
;
|
||||||
|
|
||||||
|
getClient().perform(get("/api/core/items/" + publication1.getID()))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.metadata", allOf(
|
||||||
|
matchMetadata("dc.contributor.author", "Maybe, Maybe"),
|
||||||
|
matchMetadata("dc.contributor.author", "Testy, TEst"),
|
||||||
|
matchMetadata("dc.contributor.author", "TestingLeftWardLabel"),
|
||||||
|
not(matchMetadata("dc.contributor.author", "testingLastName, testingFirstName")),
|
||||||
|
matchMetadata("dc.title", "Publication1"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void rightWardLabelRelationshipTest() throws Exception {
|
||||||
|
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
|
RelationshipType isAuthorOfPublicationRelationshipType = relationshipTypeService
|
||||||
|
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, "Publication"),
|
||||||
|
entityTypeService.findByEntityType(context, "Person"),
|
||||||
|
"isAuthorOfPublication", "isPublicationOfAuthor");
|
||||||
|
|
||||||
|
Relationship relationship3 = RelationshipBuilder
|
||||||
|
.createRelationshipBuilder(context, publication1, author3, isAuthorOfPublicationRelationshipType)
|
||||||
|
.withRightWardLabel("rightWardLabelTest").withLeftPlace(1).build();
|
||||||
|
|
||||||
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
|
getClient().perform(get("/api/core/relationships"))
|
||||||
|
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.page",
|
||||||
|
is(PageMatcher.pageEntryWithTotalPagesAndElements(0, 20, 1, 1))))
|
||||||
|
.andExpect(jsonPath("$._embedded.relationships", containsInAnyOrder(
|
||||||
|
RelationshipMatcher.matchRelationship(relationship3)
|
||||||
|
)))
|
||||||
|
;
|
||||||
|
|
||||||
|
getClient().perform(get("/api/core/items/" + publication1.getID()))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.metadata", allOf(
|
||||||
|
matchMetadata("dc.contributor.author", "Maybe, Maybe"),
|
||||||
|
matchMetadata("dc.contributor.author", "Testy, TEst"),
|
||||||
|
matchMetadata("dc.title", "Publication1"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -84,4 +84,19 @@ public class RelationshipBuilder extends AbstractBuilder<Relationship, Relations
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RelationshipBuilder withLeftWardLabel(String leftWardLabel) throws SQLException {
|
||||||
|
relationship.setLeftwardLabel(leftWardLabel);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RelationshipBuilder withRightWardLabel(String rightWardLabel) throws SQLException {
|
||||||
|
relationship.setRightwardLabel(rightWardLabel);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RelationshipBuilder withLeftPlace(int leftPlace) {
|
||||||
|
relationship.setLeftPlace(leftPlace);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.app.rest.matcher;
|
package org.dspace.app.rest.matcher;
|
||||||
|
|
||||||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
||||||
import static org.hamcrest.Matchers.contains;
|
import static org.hamcrest.Matchers.hasItem;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
@@ -18,7 +18,8 @@ import org.hamcrest.Matcher;
|
|||||||
*/
|
*/
|
||||||
public class MetadataMatcher {
|
public class MetadataMatcher {
|
||||||
|
|
||||||
private MetadataMatcher() { }
|
private MetadataMatcher() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a matcher to ensure a given value is present among all values for a given metadata key.
|
* Gets a matcher to ensure a given value is present among all values for a given metadata key.
|
||||||
@@ -28,7 +29,7 @@ public class MetadataMatcher {
|
|||||||
* @return the matcher.
|
* @return the matcher.
|
||||||
*/
|
*/
|
||||||
public static Matcher<? super Object> matchMetadata(String key, String value) {
|
public static Matcher<? super Object> matchMetadata(String key, String value) {
|
||||||
return hasJsonPath("$.['" + key + "'][*].value", contains(value));
|
return hasJsonPath("$.['" + key + "'][*].value", hasItem(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user