mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
[DS-3762] added more clauses to the metadatafield tests
This commit is contained in:

committed by
Tom Desair

parent
f4b6b5d480
commit
00d3e095fb
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.app.rest;
|
||||
|
||||
import org.dspace.app.rest.matcher.MetadataFieldMatcher;
|
||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
@@ -24,10 +25,13 @@ public class MetadatafieldRestRepositoryIT extends AbstractControllerIntegration
|
||||
getClient().perform(get("/api/core/metadatafields"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(contentType))
|
||||
.andExpect(jsonPath("$._embedded.metadatafields[0].type", Matchers.is("metadatafield")))
|
||||
.andExpect(jsonPath("$._embedded.metadatafields", Matchers.hasItem(
|
||||
MetadataFieldMatcher.matchMetadataField()
|
||||
)))
|
||||
.andExpect(jsonPath("$._links.first.href", Matchers.containsString("/api/core/metadatafields")))
|
||||
.andExpect(jsonPath("$._links.self.href", Matchers.containsString("/api/core/metadatafields")))
|
||||
.andExpect(jsonPath("$._links.next.href", Matchers.containsString("/api/core/metadatafields")))
|
||||
.andExpect(jsonPath("$._links.last.href", Matchers.containsString("/api/core/metadatafields")));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,22 @@
|
||||
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.is;
|
||||
|
||||
public class MetadataFieldMatcher {
|
||||
|
||||
public static Matcher<? super Object> matchMetadataField(){
|
||||
return allOf(
|
||||
hasJsonPath("$.element", Matchers.not(Matchers.empty())),
|
||||
hasJsonPath("$.qualifier", Matchers.not(Matchers.empty())),
|
||||
hasJsonPath("$.type", is("metadatafield")),
|
||||
hasJsonPath("$._embedded.schema", Matchers.not(Matchers.empty())),
|
||||
hasJsonPath("$._links.schema.href", Matchers.containsString("/api/core/metadatafields")),
|
||||
hasJsonPath("$._links.self.href", Matchers.containsString("/api/core/metadatafields"))
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user