use of org.folio.rest.jaxrs.model.Tags in project mod-circulation-storage by folio-org.
the class RequestsApiTest method canCreateARequest.
@Test
@Parameters({ "Title", "Item" })
public void canCreateARequest(String requestLevel) throws InterruptedException, MalformedURLException, TimeoutException, ExecutionException {
UUID id = UUID.randomUUID();
UUID itemId = UUID.randomUUID();
UUID requesterId = UUID.randomUUID();
UUID proxyId = UUID.randomUUID();
UUID holdingsRecordId = UUID.randomUUID();
UUID instanceId = UUID.randomUUID();
UUID pickupServicePointId = UUID.randomUUID();
DateTime requestDate = new DateTime(2017, 7, 22, 10, 22, 54, DateTimeZone.UTC);
DateTime requestExpirationDate = new DateTime(2017, 7, 30, 0, 0, DateTimeZone.UTC);
DateTime holdShelfExpirationDate = new DateTime(2017, 8, 31, 0, 0, DateTimeZone.UTC);
UUID isbnIdentifierId = UUID.randomUUID();
UUID issnIdentifierId = UUID.randomUUID();
final RequestItemSummary nod = new RequestItemSummary("Nod", "565578437802").addIdentifier(isbnIdentifierId, "978-92-8011-566-9").addIdentifier(issnIdentifierId, "2193988");
JsonObject representation = createEntity(new RequestRequestBuilder().recall().toHoldShelf().withId(id).withRequestDate(requestDate).withItemId(itemId).withRequesterId(requesterId).withProxyId(proxyId).withRequestExpirationDate(requestExpirationDate).withHoldShelfExpirationDate(holdShelfExpirationDate).withRequestLevel(requestLevel).withItem(nod).withHoldingsRecordId(holdingsRecordId).withInstanceId(instanceId).withRequester("Jones", "Stuart", "Anthony", "6837502674015").withProxy("Stuart", "Rebecca", "6059539205").withStatus(OPEN_NOT_YET_FILLED).withPosition(1).withPickupServicePointId(pickupServicePointId).withTags(new Tags().withTagList(asList("new", "important"))).create(), requestStorageUrl()).getJson();
assertThat(representation.getString("id"), is(id.toString()));
assertThat(representation.getString("requestType"), is("Recall"));
assertThat(representation.getString("requestDate"), is(equivalentTo(requestDate)));
assertThat(representation.getString("itemId"), is(itemId.toString()));
assertThat(representation.getString("instanceId"), is(instanceId.toString()));
assertThat(representation.getString("holdingsRecordId"), is(holdingsRecordId.toString()));
assertThat(representation.getString("requesterId"), is(requesterId.toString()));
assertThat(representation.getString("proxyUserId"), is(proxyId.toString()));
assertThat(representation.getString("fulfilmentPreference"), is("Hold Shelf"));
assertThat(representation.getString("requestExpirationDate"), is(equivalentTo(requestExpirationDate)));
assertThat(representation.getString("holdShelfExpirationDate"), is(equivalentTo(holdShelfExpirationDate)));
assertThat(representation.getString("status"), is(OPEN_NOT_YET_FILLED));
assertThat(representation.getInteger("position"), is(1));
assertThat(representation.getString("pickupServicePointId"), is(pickupServicePointId.toString()));
assertThat(representation.containsKey("patronComments"), is(false));
assertThat(representation.containsKey("item"), is(true));
JsonObject item = representation.getJsonObject("item");
assertThat(item.getString("barcode"), is("565578437802"));
assertThat(representation.containsKey("instance"), is(true));
JsonObject instance = representation.getJsonObject("instance");
assertThat(instance.getString("title"), is("Nod"));
JsonArray identifiers = instance.getJsonArray("identifiers");
assertThat(identifiers.size(), is(2));
assertThat(identifiers.getJsonObject(0).getString("identifierTypeId"), is(isbnIdentifierId.toString()));
assertThat(identifiers.getJsonObject(0).getString("value"), is("978-92-8011-566-9"));
assertThat(identifiers.getJsonObject(1).getString("identifierTypeId"), is(issnIdentifierId.toString()));
assertThat(identifiers.getJsonObject(1).getString("value"), is("2193988"));
assertThat(representation.containsKey("requester"), is(true));
final JsonObject requesterRepresentation = representation.getJsonObject("requester");
assertThat(requesterRepresentation.getString("lastName"), is("Jones"));
assertThat(requesterRepresentation.getString("firstName"), is("Stuart"));
assertThat(requesterRepresentation.getString("middleName"), is("Anthony"));
assertThat(requesterRepresentation.getString("barcode"), is("6837502674015"));
assertThat("has information taken from proxying user", representation.containsKey("proxy"), is(true));
final JsonObject proxyRepresentation = representation.getJsonObject("proxy");
assertThat("last name is taken from proxying user", proxyRepresentation.getString("lastName"), is("Stuart"));
assertThat("first name is taken from proxying user", proxyRepresentation.getString("firstName"), is("Rebecca"));
assertThat("middle name is not taken from proxying user", proxyRepresentation.containsKey("middleName"), is(false));
assertThat("barcode is taken from proxying user", proxyRepresentation.getString("barcode"), is("6059539205"));
assertThat(representation.containsKey("tags"), is(true));
final JsonObject tagsRepresentation = representation.getJsonObject("tags");
assertThat(tagsRepresentation.containsKey("tagList"), is(true));
assertThat(tagsRepresentation.getJsonArray("tagList"), contains("new", "important"));
assertCreateEventForRequest(representation);
}
use of org.folio.rest.jaxrs.model.Tags in project mod-kb-ebsco-java by folio-org.
the class EholdingsTitlesTest method shouldUpdateOnlyTagsOnPutForNonCustomTitle.
@Test
public void shouldUpdateOnlyTagsOnPutForNonCustomTitle() throws IOException, URISyntaxException {
String resourceResponse = "responses/rmapi/resources/get-managed-resource-updated-response.json";
ObjectMapper mapper = new ObjectMapper();
TitlePutRequest request = mapper.readValue(readFile("requests/kb-ebsco/title/put-title.json"), TitlePutRequest.class);
List<String> newTags = Arrays.asList(STUB_TAG_VALUE, STUB_TAG_VALUE_2);
request.getData().getAttributes().setTags(new Tags().withTagList(newTags));
stubFor(get(new UrlPathPattern(new RegexPattern(CUSTOM_TITLE_ENDPOINT), false)).willReturn(new ResponseDefinitionBuilder().withBody(readFile(resourceResponse))));
putWithOk(EHOLDINGS_TITLES_PATH + "/" + STUB_CUSTOM_TITLE_ID, mapper.writeValueAsString(request), STUB_TOKEN_HEADER);
List<String> tags = TagsTestUtil.getTags(vertx);
assertThat(tags, containsInAnyOrder(newTags.toArray()));
WireMock.verify(0, putRequestedFor(anyUrl()));
}
use of org.folio.rest.jaxrs.model.Tags in project mod-kb-ebsco-java by folio-org.
the class EholdingsTitlesTest method putTitle.
private String putTitle(String updatedResourceResponse, List<String> tags) throws IOException, URISyntaxException {
stubFor(get(new UrlPathPattern(new RegexPattern(CUSTOM_TITLE_ENDPOINT), false)).willReturn(new ResponseDefinitionBuilder().withBody(updatedResourceResponse)));
stubFor(put(new UrlPathPattern(new RegexPattern(CUSTOM_RESOURCE_ENDPOINT), true)).willReturn(new ResponseDefinitionBuilder().withStatus(SC_NO_CONTENT)));
ObjectMapper mapper = new ObjectMapper();
TitlePutRequest titleToBeUpdated = mapper.readValue(readFile("requests/kb-ebsco/title/put-title.json"), TitlePutRequest.class);
if (tags != null) {
titleToBeUpdated.getData().getAttributes().setTags(new Tags().withTagList(tags));
}
return putWithOk(EHOLDINGS_TITLES_PATH + "/" + STUB_CUSTOM_TITLE_ID, mapper.writeValueAsString(titleToBeUpdated), STUB_TOKEN_HEADER).asString();
}
use of org.folio.rest.jaxrs.model.Tags in project mod-kb-ebsco-java by folio-org.
the class EholdingsProvidersImplTest method sendPutTags.
private void sendPutTags(List<String> newTags) throws IOException, URISyntaxException {
ProviderTagsPutRequest tags = readJsonFile(PUT_PROVIDER_TAGS, ProviderTagsPutRequest.class);
if (newTags != null) {
tags.getData().getAttributes().setTags(new Tags().withTagList(newTags));
}
putWithOk(PROVIDER_TAGS_PATH, Json.encode(tags), STUB_TOKEN_HEADER).as(PackageTags.class);
}
use of org.folio.rest.jaxrs.model.Tags in project mod-kb-ebsco-java by folio-org.
the class EholdingsResourcesImplTest method sendPutTags.
private void sendPutTags(List<String> newTags) throws IOException, URISyntaxException {
ObjectMapper mapper = new ObjectMapper();
ResourceTagsPutRequest tags = mapper.readValue(getFile("requests/kb-ebsco/resource/put-resource-tags.json"), ResourceTagsPutRequest.class);
if (newTags != null) {
tags.getData().getAttributes().setTags(new Tags().withTagList(newTags));
}
putWithOk(RESOURCE_TAGS_PATH, mapper.writeValueAsString(tags), STUB_TOKEN_HEADER).as(ResourceTags.class);
}
Aggregations