mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
[DS-3762] added extra clauses for the EPerson matcher
This commit is contained in:

committed by
Tom Desair

parent
70529b154c
commit
f4b6b5d480
@@ -34,7 +34,7 @@ public class EPersonRestRepositoryIT extends AbstractControllerIntegrationTest{
|
|||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(contentType))
|
.andExpect(content().contentType(contentType))
|
||||||
.andExpect(jsonPath("$._embedded.epersons", Matchers.containsInAnyOrder(
|
.andExpect(jsonPath("$._embedded.epersons", Matchers.containsInAnyOrder(
|
||||||
EPersonMatcher.matchEPersonEntry(ePerson.getID(), ePerson.getEmail()),
|
EPersonMatcher.matchEPersonEntry(ePerson),
|
||||||
EPersonMatcher.matchDefaultTestEPerson()
|
EPersonMatcher.matchDefaultTestEPerson()
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,7 @@ public class EPersonRestRepositoryIT extends AbstractControllerIntegrationTest{
|
|||||||
)))
|
)))
|
||||||
.andExpect(jsonPath("$._embedded.epersons", Matchers.not(
|
.andExpect(jsonPath("$._embedded.epersons", Matchers.not(
|
||||||
Matchers.contains(
|
Matchers.contains(
|
||||||
EPersonMatcher.matchEPersonEntry(ePerson.getID(), ePerson.getEmail())
|
EPersonMatcher.matchEPersonEntry(ePerson)
|
||||||
)
|
)
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ public class EPersonRestRepositoryIT extends AbstractControllerIntegrationTest{
|
|||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(contentType))
|
.andExpect(content().contentType(contentType))
|
||||||
.andExpect(jsonPath("$._embedded.epersons", Matchers.contains(
|
.andExpect(jsonPath("$._embedded.epersons", Matchers.contains(
|
||||||
EPersonMatcher.matchEPersonEntry(ePerson.getID(), ePerson.getEmail())
|
EPersonMatcher.matchEPersonEntry(ePerson)
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,11 +90,11 @@ public class EPersonRestRepositoryIT extends AbstractControllerIntegrationTest{
|
|||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(contentType))
|
.andExpect(content().contentType(contentType))
|
||||||
.andExpect(jsonPath("$", Matchers.is(
|
.andExpect(jsonPath("$", Matchers.is(
|
||||||
EPersonMatcher.matchEPersonEntry(ePerson2.getID(), ePerson2.getEmail())
|
EPersonMatcher.matchEPersonEntry(ePerson2)
|
||||||
)))
|
)))
|
||||||
.andExpect(jsonPath("$", Matchers.not(
|
.andExpect(jsonPath("$", Matchers.not(
|
||||||
Matchers.is(
|
Matchers.is(
|
||||||
EPersonMatcher.matchEPersonEntry(ePerson.getID(), ePerson.getEmail())
|
EPersonMatcher.matchEPersonEntry(ePerson)
|
||||||
)
|
)
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@@ -118,11 +118,11 @@ public class EPersonRestRepositoryIT extends AbstractControllerIntegrationTest{
|
|||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(contentType))
|
.andExpect(content().contentType(contentType))
|
||||||
.andExpect(jsonPath("$", Matchers.is(
|
.andExpect(jsonPath("$", Matchers.is(
|
||||||
EPersonMatcher.matchEPersonEntry(ePerson2.getID(), ePerson2.getEmail())
|
EPersonMatcher.matchEPersonEntry(ePerson2)
|
||||||
)))
|
)))
|
||||||
.andExpect(jsonPath("$", Matchers.not(
|
.andExpect(jsonPath("$", Matchers.not(
|
||||||
Matchers.is(
|
Matchers.is(
|
||||||
EPersonMatcher.matchEPersonEntry(ePerson.getID(), ePerson.getEmail())
|
EPersonMatcher.matchEPersonEntry(ePerson)
|
||||||
)
|
)
|
||||||
)))
|
)))
|
||||||
.andExpect(jsonPath("$._links.self.href", Matchers.containsString("/api/eperson/epersons/" + ePerson2.getID())));
|
.andExpect(jsonPath("$._links.self.href", Matchers.containsString("/api/eperson/epersons/" + ePerson2.getID())));
|
||||||
|
@@ -7,23 +7,28 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.matcher;
|
package org.dspace.app.rest.matcher;
|
||||||
|
|
||||||
|
import org.dspace.eperson.EPerson;
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
|
import org.hamcrest.Matchers;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
|
|
||||||
public class EPersonMatcher {
|
public class EPersonMatcher {
|
||||||
|
|
||||||
public static Matcher<? super Object> matchEPersonEntry(UUID uuid, String name) {
|
public static Matcher<? super Object> matchEPersonEntry(EPerson ePerson) {
|
||||||
return allOf(
|
return allOf(
|
||||||
hasJsonPath("$.uuid", is(uuid.toString())),
|
hasJsonPath("$.uuid", is(ePerson.getID().toString())),
|
||||||
hasJsonPath("$.name", is(name)),
|
hasJsonPath("$.name", is(ePerson.getName())),
|
||||||
hasJsonPath("$.type", is("eperson")),
|
hasJsonPath("$.type", is("eperson")),
|
||||||
hasJsonPath("$._links.self.href", containsString("/api/eperson/epersons/" + uuid.toString()))
|
hasJsonPath("$.canLogIn", not(empty())),
|
||||||
|
hasJsonPath("$._links.self.href", containsString("/api/eperson/epersons/" + ePerson.getID().toString())),
|
||||||
|
hasJsonPath("$.metadata", Matchers.containsInAnyOrder(
|
||||||
|
EPersonMetadataMatcher.matchFirstName(ePerson.getFirstName()),
|
||||||
|
EPersonMetadataMatcher.matchLastName(ePerson.getLastName())
|
||||||
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,27 @@
|
|||||||
|
package org.dspace.app.rest.matcher;
|
||||||
|
|
||||||
|
import org.hamcrest.Matcher;
|
||||||
|
import org.hamcrest.Matchers;
|
||||||
|
|
||||||
|
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
||||||
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
import static org.hamcrest.Matchers.empty;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
public class EPersonMetadataMatcher {
|
||||||
|
|
||||||
|
public static Matcher<? super Object> matchFirstName(String firstName){
|
||||||
|
return allOf(
|
||||||
|
hasJsonPath("$.key", is("eperson.firstname")),
|
||||||
|
hasJsonPath("$.value", is(firstName))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Matcher<? super Object> matchLastName(String lastName){
|
||||||
|
return allOf(
|
||||||
|
hasJsonPath("$.key", is("eperson.lastname")),
|
||||||
|
hasJsonPath("$.value", is(lastName))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user