DS-4006: Added explicit check for "groups" link in Group Rest object

This commit is contained in:
Tom Desair
2019-03-05 22:36:13 +01:00
parent aef31c8d37
commit 0961c5040d
2 changed files with 7 additions and 4 deletions

View File

@@ -28,7 +28,6 @@ public class GroupRest extends DSpaceObjectRest {
private boolean permanent;
@JsonIgnore
private List<GroupRest> groups;
@Override
@@ -57,6 +56,7 @@ public class GroupRest extends DSpaceObjectRest {
this.permanent = permanent;
}
@JsonIgnore
@LinkRest(linkClass = GroupRest.class)
public List<GroupRest> getGroups() {
return groups;

View File

@@ -10,6 +10,7 @@ package org.dspace.app.rest.matcher;
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.is;
import java.util.UUID;
@@ -25,16 +26,18 @@ public class GroupMatcher {
hasJsonPath("$.uuid", is(uuid.toString())),
hasJsonPath("$.name", is(name)),
hasJsonPath("$.type", is("group")),
hasJsonPath("$._links.self.href", containsString("/api/eperson/groups/" + uuid.toString()))
hasJsonPath("$._links.self.href", containsString("/api/eperson/groups/" + uuid.toString())),
hasJsonPath("$._links.groups.href", endsWith(uuid.toString() + "/groups"))
);
}
public static Matcher<? super Object> matchGroupWithName(String name) {
return allOf(
hasJsonPath("$.name", is(name)),
hasJsonPath("$.type", is("group"))
hasJsonPath("$.type", is("group")),
hasJsonPath("$._links.self.href", containsString("/api/eperson/groups/")),
hasJsonPath("$._links.groups.href", endsWith("/groups"))
);
}
}