Search in sources :

Example 21 with TitlePostRequest

use of org.folio.rest.jaxrs.model.TitlePostRequest 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);
}
Also used : ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) EqualToJsonPattern(com.github.tomakehurst.wiremock.matching.EqualToJsonPattern) TitlePostRequest(org.folio.rest.jaxrs.model.TitlePostRequest) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) Matchers.containsString(org.hamcrest.Matchers.containsString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Tags(org.folio.rest.jaxrs.model.Tags)

Aggregations

TitlePostRequest (org.folio.rest.jaxrs.model.TitlePostRequest)21 Test (org.junit.Test)18 TitlePostDataAttributes (org.folio.rest.jaxrs.model.TitlePostDataAttributes)14 TitlePostData (org.folio.rest.jaxrs.model.TitlePostData)8 Tags (org.folio.rest.jaxrs.model.Tags)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)1 EqualToJsonPattern (com.github.tomakehurst.wiremock.matching.EqualToJsonPattern)1 EqualToPattern (com.github.tomakehurst.wiremock.matching.EqualToPattern)1 RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)1 UrlPathPattern (com.github.tomakehurst.wiremock.matching.UrlPathPattern)1 AsyncResult (io.vertx.core.AsyncResult)1 Context (io.vertx.core.Context)1 Handler (io.vertx.core.Handler)1 Vertx (io.vertx.core.Vertx)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 UUID (java.util.UUID)1