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);
}
Aggregations