use of org.folio.rest.jaxrs.model.PoLineCollection in project mod-orders by folio-org.
the class PurchaseOrderLineServiceTest method successRetrievePurchaseOrderLinesByQuery.
@Test
void successRetrievePurchaseOrderLinesByQuery() {
String orderLineId = UUID.randomUUID().toString();
List<PoLine> purchaseOrderLines = Collections.singletonList(new PoLine().withId(orderLineId));
PoLineCollection expLines = new PoLineCollection().withPoLines(purchaseOrderLines).withTotalRecords(1);
when(restClientMock.get(any(), any(), any())).thenReturn(CompletableFuture.completedFuture(expLines));
String expectedQuery = String.format("id==%s", orderLineId);
List<PoLine> actLines = purchaseOrderLineService.getOrderLines(expectedQuery, 0, Integer.MAX_VALUE, requestContext).join();
verify(restClientMock).get(any(), eq(requestContext), eq(PoLineCollection.class));
assertEquals(purchaseOrderLines, actLines);
}
use of org.folio.rest.jaxrs.model.PoLineCollection in project mod-orders by folio-org.
the class PurchaseOrderLineService method getOrderLinesChunk.
private CompletableFuture<List<PoLine>> getOrderLinesChunk(List<String> orderLineIds, RequestContext requestContext) {
String query = convertIdsToCqlQuery(orderLineIds);
RequestEntry requestEntry = new RequestEntry(ENDPOINT).withQuery(query).withOffset(0).withLimit(MAX_IDS_FOR_GET_RQ);
return restClient.get(requestEntry, requestContext, PoLineCollection.class).thenApply(PoLineCollection::getPoLines);
}
use of org.folio.rest.jaxrs.model.PoLineCollection in project mod-orders by folio-org.
the class CheckinReceivingApiTest method verifyProperQuantityOfHoldingsCreated.
private void verifyProperQuantityOfHoldingsCreated(ReceivingCollection receivingRq) throws IOException {
Set<String> expectedHoldings = new HashSet<>();
// get processed poline
PoLineCollection poLineCollection = new JsonObject(getMockData(POLINES_COLLECTION)).mapTo(PoLineCollection.class);
PoLine poline = poLineCollection.getPoLines().stream().filter(poLine -> poLine.getId().equals(receivingRq.getToBeReceived().get(0).getPoLineId())).findFirst().get();
CompositePoLine compPOL = PoLineCommonUtil.convertToCompositePoLine(poline);
// get processed pieces for receiving
PieceCollection pieces = new JsonObject(getMockData(PIECE_RECORDS_MOCK_DATA_PATH + "pieceRecordsCollection.json")).mapTo(PieceCollection.class);
List<String> pieceIds = new ArrayList<>();
receivingRq.getToBeReceived().get(0).getReceivedItems().forEach(recItem -> pieceIds.add(recItem.getPieceId()));
// get processed pieces from mock collection
pieces.getPieces().removeIf(piece -> !pieceIds.contains(piece.getId()));
for (org.folio.rest.acq.model.Piece piece : pieces.getPieces()) {
for (ReceivedItem receivedItem : receivingRq.getToBeReceived().get(0).getReceivedItems()) {
if (receivedItem.getPieceId().equals(piece.getId()) && !receivedItem.getLocationId().equals(piece.getLocationId()) && isHoldingsUpdateRequired(piece, compPOL)) {
expectedHoldings.add(getInstanceId(poline) + receivedItem.getLocationId());
}
}
}
assertEquals(expectedHoldings.size(), getCreatedHoldings().size());
}
use of org.folio.rest.jaxrs.model.PoLineCollection in project mod-orders by folio-org.
the class PurchaseOrderLinesApiTest method testGetOrderPOLinesByPoId.
@Test
void testGetOrderPOLinesByPoId() {
logger.info("=== Test Get Orders lines - by PO id ===");
String sortBy = " sortBy poNumber";
String cql = String.format("%s==%s", PURCHASE_ORDER_ID, ORDER_ID_WITH_PO_LINES);
String endpointQuery = String.format("%s?query=%s%s", LINES_PATH, cql, sortBy);
final PoLineCollection poLineCollection = verifySuccessGet(endpointQuery, PoLineCollection.class, PROTECTED_READ_ONLY_TENANT);
assertThat(poLineCollection.getTotalRecords(), is(2));
assertThat(getPoLineSearches(), hasSize(1));
assertThat(MockServer.serverRqRs.get(ACQUISITIONS_UNITS, HttpMethod.GET), hasSize(1));
assertThat(MockServer.serverRqRs.get(ACQUISITIONS_MEMBERSHIPS, HttpMethod.GET), hasSize(1));
List<String> queryParams = getQueryParams(PO_LINES_STORAGE);
assertThat(queryParams, hasSize(1));
String queryToStorage = queryParams.get(0);
assertThat(queryToStorage, containsString("(" + cql + ")"));
assertThat(queryToStorage, containsString(ORDER_ID_WITH_PO_LINES));
assertThat(queryToStorage, not(containsString(ACQUISITIONS_UNIT_IDS + "=")));
assertThat(queryToStorage, containsString(NO_ACQ_UNIT_ASSIGNED_CQL));
assertThat(queryToStorage, endsWith(sortBy));
}
Aggregations