use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldDeletePackageTagsOnDelete.
@Test
public void shouldDeletePackageTagsOnDelete() throws IOException, URISyntaxException {
saveTag(vertx, FULL_PACKAGE_ID, PACKAGE, "test one");
mockGet(new EqualToPattern(PACKAGE_BY_ID_URL), CUSTOM_PACKAGE_STUB_FILE);
EqualToJsonPattern putBodyPattern = new EqualToJsonPattern("{\"isSelected\":false}", true, true);
mockPut(new EqualToPattern(PACKAGE_BY_ID_URL), putBodyPattern, SC_NO_CONTENT);
deleteWithNoContent(PACKAGES_PATH, STUB_TOKEN_HEADER);
List<String> tagsAfterRequest = TagsTestUtil.getTagsForRecordType(vertx, PACKAGE);
assertThat(tagsAfterRequest, empty());
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldSendDeleteRequestForPackage.
@Test
public void shouldSendDeleteRequestForPackage() throws IOException, URISyntaxException {
EqualToJsonPattern putBodyPattern = new EqualToJsonPattern("{\"isSelected\":false}", true, true);
mockGet(new EqualToPattern(PACKAGE_BY_ID_URL), CUSTOM_PACKAGE_STUB_FILE);
mockPut(new EqualToPattern(PACKAGE_BY_ID_URL), putBodyPattern, SC_NO_CONTENT);
deleteWithNoContent(PACKAGES_PATH, STUB_TOKEN_HEADER);
verify(1, putRequestedFor(PACKAGE_URL_PATTERN).withRequestBody(putBodyPattern));
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsTitlesTest method postTitle.
private ExtractableResponse<Response> postTitle(List<String> tags) throws IOException, URISyntaxException {
String titleCreatedIdStubResponseFile = "responses/rmapi/titles/post-title-response.json";
String titlePostStubRequestFile = "requests/kb-ebsco/title/post-title-request.json";
String getTitleByTitleIdStubFile = "responses/rmapi/titles/get-title-by-id-for-post-request.json";
EqualToJsonPattern postBodyPattern = new EqualToJsonPattern("{\n \"titleName\" : \"Test Title\",\n \"edition\" : \"Test edition\",\n \"publisherName\" : \"Test publisher\",\n \"pubType\" : \"thesisdissertation\",\n \"description\" : \"Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\",\n \"isPeerReviewed\" : true,\n \"identifiersList\" : [ {\n \"id\" : \"1111-2222-3333\",\n \"subtype\" : 2,\n \"type\" : 0\n } ],\n \"contributorsList\" : [ {\n \"type\" : \"author\",\n \"contributor\" : \"smith, john\"\n }, {\n \"type\" : \"illustrator\",\n \"contributor\" : \"smith, ralph\"\n } ],\n \"peerReviewed\" : true\n} \"userDefinedField2\": \"test 2\",\n\"userDefinedField3\": \"\",\n\"userDefinedField4\" : null,\n\"userDefinedField5\": \"test 5\"", true, true);
stubFor(post(new UrlPathPattern(new EqualToPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/vendors/" + STUB_VENDOR_ID + "/packages/" + STUB_PACKAGE_ID + "/titles"), false)).withRequestBody(postBodyPattern).willReturn(new ResponseDefinitionBuilder().withBody(readFile(titleCreatedIdStubResponseFile)).withStatus(SC_OK)));
stubFor(get(new UrlPathPattern(new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/titles/" + STUB_TITLE_ID), true)).willReturn(new ResponseDefinitionBuilder().withBody(readFile(getTitleByTitleIdStubFile)).withStatus(SC_OK)));
ObjectMapper mapper = new ObjectMapper();
TitlePostRequest request = mapper.readValue(readFile(titlePostStubRequestFile), TitlePostRequest.class);
request.getData().getAttributes().setTags(new Tags().withTagList(tags));
return postWithOk(EHOLDINGS_TITLES_PATH, mapper.writeValueAsString(request), STUB_TOKEN_HEADER);
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldPostResourceToRMAPI.
@Test
public void shouldPostResourceToRMAPI() throws IOException, URISyntaxException, JSONException {
String stubTitleResponseFile = "responses/rmapi/resources/get-resource-by-id-success-response.json";
String stubPackageResponseFile = "responses/rmapi/packages/get-custom-package-by-id-response.json";
String stubPackageResourcesFile = "responses/rmapi/resources/get-resources-by-package-id-response.json";
String postStubRequest = "requests/kb-ebsco/resource/post-resources-request.json";
String expectedResourceFile = "responses/kb-ebsco/resources/expected-resource-after-post.json";
EqualToJsonPattern putRequestBodyPattern = new EqualToJsonPattern(readFile("requests/rmapi/resources/select-resource-request.json"), true, true);
mockPackageResources(stubPackageResourcesFile);
mockPackage(stubPackageResponseFile);
mockTitle(stubTitleResponseFile);
mockResource(stubTitleResponseFile);
mockPut(new RegexPattern(MANAGED_RESOURCE_ENDPOINT), putRequestBodyPattern, SC_NO_CONTENT);
String actualResponse = postWithOk("eholdings/resources", readFile(postStubRequest), STUB_TOKEN_HEADER).asString();
JSONAssert.assertEquals(readFile(expectedResourceFile), actualResponse, true);
verify(1, putRequestedFor(new UrlPathPattern(new EqualToPattern(MANAGED_RESOURCE_ENDPOINT), false)).withRequestBody(putRequestBodyPattern));
}
use of com.github.tomakehurst.wiremock.matching.EqualToJsonPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method shouldDeleteAccessTypeOnDeleteRequest.
@Test
public void shouldDeleteAccessTypeOnDeleteRequest() throws IOException, URISyntaxException {
String accessTypeId = insertAccessTypes(testData(configuration.getId()), vertx).get(0).getId();
insertAccessTypeMapping(STUB_CUSTOM_RESOURCE_ID, RecordType.RESOURCE, accessTypeId, vertx);
EqualToJsonPattern putBodyPattern = new EqualToJsonPattern("{\"isSelected\":false}", true, true);
deleteResource(putBodyPattern);
List<AccessTypeMapping> actualMappings = getAccessTypeMappings(vertx);
assertThat(actualMappings, empty());
}
Aggregations