use of api.support.TlrFeatureStatus in project mod-circulation by folio-org.
the class RequestQueueResourceTest method shouldReorderQueueSuccessfully.
@ParameterizedTest
@CsvSource(value = { "ENABLED, 1, 2, 3, 4", "ENABLED, 1, 2, 4, 3", "ENABLED, 2, 1, 3, 4", "ENABLED, 2, 1, 4, 3", "ENABLED, 4, 3, 2, 1", "ENABLED, 4, 3, 1, 2", "ENABLED, 3, 4, 2, 1", "ENABLED, 3, 4, 1, 2", "DISABLED, 1, 2, 3, 4", "DISABLED, 1, 2, 4, 3", "DISABLED, 2, 1, 3, 4", "DISABLED, 2, 1, 4, 3", "DISABLED, 4, 3, 2, 1", "DISABLED, 4, 3, 1, 2", "DISABLED, 3, 4, 2, 1", "DISABLED, 3, 4, 1, 2", "NOT_CONFIGURED, 1, 2, 3, 4", "NOT_CONFIGURED, 1, 2, 4, 3", "NOT_CONFIGURED, 2, 1, 3, 4", "NOT_CONFIGURED, 2, 1, 4, 3", "NOT_CONFIGURED, 4, 3, 2, 1", "NOT_CONFIGURED, 4, 3, 1, 2", "NOT_CONFIGURED, 3, 4, 2, 1", "NOT_CONFIGURED, 3, 4, 1, 2" })
void shouldReorderQueueSuccessfully(String tlrFeatureStatusString, int firstPosition, int secondPosition, int thirdPosition, int fourthPosition) {
TlrFeatureStatus tlrFeatureStatus = TlrFeatureStatus.valueOf(tlrFeatureStatusString);
reconfigureTlrFeature(tlrFeatureStatus);
checkOutFixture.checkOutByBarcode(item, rebecca);
IndividualResource firstHoldRequest = holdRequestForDefaultItem(steve);
IndividualResource secondHoldRequest = holdRequestForDefaultItem(james);
IndividualResource firstRecallRequest = recallRequestForDefaultItem(charlotte);
IndividualResource secondRecallRequest = recallRequestForDefaultItem(jessica);
JsonObject reorderQueueBody = new ReorderQueueBuilder().addReorderRequest(firstHoldRequest.getId().toString(), firstPosition).addReorderRequest(secondHoldRequest.getId().toString(), secondPosition).addReorderRequest(firstRecallRequest.getId().toString(), thirdPosition).addReorderRequest(secondRecallRequest.getId().toString(), fourthPosition).create();
JsonObject response;
if (tlrFeatureStatus == TlrFeatureStatus.ENABLED) {
response = requestQueueFixture.reorderQueueForInstance(item.getInstanceId().toString(), reorderQueueBody);
} else {
response = requestQueueFixture.reorderQueueForItem(item.getId().toString(), reorderQueueBody);
}
verifyQueueUpdatedForItem(reorderQueueBody, response);
}
use of api.support.TlrFeatureStatus in project mod-circulation by folio-org.
the class RequestQueueResourceTest method logRecordEventIsPublished.
@ParameterizedTest
@EnumSource(TlrFeatureStatus.class)
void logRecordEventIsPublished(TlrFeatureStatus tlrFeatureStatus) {
reconfigureTlrFeature(tlrFeatureStatus);
checkOutFixture.checkOutByBarcode(item, rebecca);
IndividualResource firstHoldRequest = holdRequestForDefaultItem(steve);
IndividualResource secondHoldRequest = holdRequestForDefaultItem(james);
IndividualResource firstRecallRequest = recallRequestForDefaultItem(charlotte);
IndividualResource secondRecallRequest = recallRequestForDefaultItem(jessica);
JsonObject reorderQueue = new ReorderQueueBuilder().addReorderRequest(firstHoldRequest.getId().toString(), 1).addReorderRequest(secondHoldRequest.getId().toString(), 4).addReorderRequest(firstRecallRequest.getId().toString(), 2).addReorderRequest(secondRecallRequest.getId().toString(), 3).create();
JsonObject response;
if (tlrFeatureStatus == TlrFeatureStatus.ENABLED) {
response = requestQueueFixture.reorderQueueForInstance(item.getInstanceId().toString(), reorderQueue);
} else {
response = requestQueueFixture.reorderQueueForItem(item.getId().toString(), reorderQueue);
}
verifyQueueUpdatedForItem(reorderQueue, response);
// TODO: understand why
int numberOfPublishedEvents = 17;
final var publishedEvents = Awaitility.await().atMost(1, TimeUnit.SECONDS).until(FakePubSub::getPublishedEvents, hasSize(numberOfPublishedEvents));
final var reorderedLogEvents = publishedEvents.filterToList(byLogEventType(REQUEST_REORDERED.value()));
assertThat(reorderedLogEvents, hasSize(1));
List<JsonObject> reorderedRequests = new JsonObject(JsonObject.mapFrom(reorderedLogEvents.get(0)).getString("eventPayload")).getJsonObject("payload").getJsonObject("requests").getJsonArray("reordered").stream().map(o -> (JsonObject) o).collect(toList());
assertThat(reorderedRequests, hasSize(3));
reorderedRequests.forEach(r -> {
assertNotNull(r.getInteger("position"));
assertNotNull(r.getInteger("previousPosition"));
assertNotEquals(r.getInteger("position"), r.getInteger("previousPosition"));
});
}
use of api.support.TlrFeatureStatus in project mod-circulation by folio-org.
the class RequestQueueResourceTest method refuseWhenPositionsAreNotSequential.
@ParameterizedTest
@CsvSource(value = { "ENABLED, 1, 2, 5, 4", "ENABLED, 0, 2, 3, 4", "ENABLED, 6, 2, 3, 1", "ENABLED, 70, 0, 10, 2", "ENABLED, 1, 3, 4, 5", "ENABLED, 1, 2, 4, 5", "ENABLED, 1, 2, 3, 5", "DISABLED, 1, 2, 5, 4", "DISABLED, 0, 2, 3, 4", "DISABLED, 6, 2, 3, 1", "DISABLED, 70, 0, 10, 2", "DISABLED, 1, 3, 4, 5", "DISABLED, 1, 2, 4, 5", "DISABLED, 1, 2, 3, 5", "NOT_CONFIGURED, 1, 2, 5, 4", "NOT_CONFIGURED, 0, 2, 3, 4", "NOT_CONFIGURED, 6, 2, 3, 1", "NOT_CONFIGURED, 70, 0, 10, 2", "NOT_CONFIGURED, 1, 3, 4, 5", "NOT_CONFIGURED, 1, 2, 4, 5", "NOT_CONFIGURED, 1, 2, 3, 5" })
void refuseWhenPositionsAreNotSequential(String tlrFeatureStatusString, int firstPosition, int secondPosition, int thirdPosition, int fourthPosition) {
TlrFeatureStatus tlrFeatureStatus = TlrFeatureStatus.valueOf(tlrFeatureStatusString);
reconfigureTlrFeature(tlrFeatureStatus);
checkOutFixture.checkOutByBarcode(item, rebecca);
IndividualResource firstHoldRequest = holdRequestForDefaultItem(steve);
IndividualResource secondHoldRequest = holdRequestForDefaultItem(james);
IndividualResource firstRecallRequest = recallRequestForDefaultItem(charlotte);
IndividualResource secondRecallRequest = recallRequestForDefaultItem(jessica);
JsonObject reorderQueueBody = new ReorderQueueBuilder().addReorderRequest(firstHoldRequest.getId().toString(), firstPosition).addReorderRequest(secondHoldRequest.getId().toString(), secondPosition).addReorderRequest(firstRecallRequest.getId().toString(), thirdPosition).addReorderRequest(secondRecallRequest.getId().toString(), fourthPosition).create();
Response response;
if (tlrFeatureStatus == TlrFeatureStatus.ENABLED) {
response = requestQueueFixture.attemptReorderQueueForInstance(item.getInstanceId().toString(), reorderQueueBody);
} else {
response = requestQueueFixture.attemptReorderQueueForItem(item.getId().toString(), reorderQueueBody);
}
verifyValidationFailure(response, is("Positions must have sequential order."));
}
Aggregations