Skip to content

Commit

Permalink
[MODORDERS-989] - Increased coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Khamidulla Abdulkhakimov authored and Khamidulla Abdulkhakimov committed Jan 23, 2024
1 parent f2a7f21 commit 89a2d06
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/test/java/org/folio/TestConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ private TestConstants() {}

public static final String ORDERS_RECEIVING_ENDPOINT = "/orders/receive";
public static final String ORDERS_CHECKIN_ENDPOINT = "/orders/check-in";
public static final String ORDERS_EXPECT_ENDPOINT = "/orders/expect";

public static final String PO_LINE_NUMBER_VALUE = "1";

Expand Down
51 changes: 51 additions & 0 deletions src/test/java/org/folio/rest/impl/CheckinReceivingApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.folio.TestConfig.isVerticleNotDeployed;
import static org.folio.TestConstants.EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10;
import static org.folio.TestConstants.ORDERS_CHECKIN_ENDPOINT;
import static org.folio.TestConstants.ORDERS_EXPECT_ENDPOINT;
import static org.folio.TestConstants.ORDERS_RECEIVING_ENDPOINT;
import static org.folio.TestUtils.getInstanceId;
import static org.folio.TestUtils.getMinimalContentCompositePoLine;
Expand Down Expand Up @@ -87,6 +88,8 @@
import org.folio.rest.jaxrs.model.Eresource;
import org.folio.rest.jaxrs.model.Error;
import org.folio.rest.jaxrs.model.Errors;
import org.folio.rest.jaxrs.model.ExpectCollection;
import org.folio.rest.jaxrs.model.ExpectPiece;
import org.folio.rest.jaxrs.model.Physical;
import org.folio.rest.jaxrs.model.Piece;
import org.folio.rest.jaxrs.model.PoLine;
Expand All @@ -98,6 +101,7 @@
import org.folio.rest.jaxrs.model.ReceivingResult;
import org.folio.rest.jaxrs.model.ReceivingResults;
import org.folio.rest.jaxrs.model.ToBeCheckedIn;
import org.folio.rest.jaxrs.model.ToBeExpected;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -836,6 +840,53 @@ void testPostReceivingPhysicalWithErrors() throws IOException {
verifyOrderStatusUpdateEvent(1);
}

@Test
void testMovePieceStatusFromUnreceivableToExpected() {
logger.info("=== Test POST Expect");

CompositePurchaseOrder order = getMinimalContentCompositePurchaseOrder();
CompositePoLine poLine = getMinimalContentCompositePoLine(order.getId());
poLine.setIsPackage(true);
poLine.setOrderFormat(CompositePoLine.OrderFormat.ELECTRONIC_RESOURCE);
poLine.setEresource(new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE_HOLDING_ITEM));

Piece electronicPiece = getMinimalContentPiece(poLine.getId()).withReceivingStatus(Piece.ReceivingStatus.UNRECEIVABLE)
.withFormat(org.folio.rest.jaxrs.model.Piece.Format.ELECTRONIC)
.withId(UUID.randomUUID().toString())
.withTitleId(UUID.randomUUID().toString())
.withItemId(UUID.randomUUID().toString());

addMockEntry(PURCHASE_ORDER_STORAGE, order.withWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN));
addMockEntry(PO_LINES_STORAGE, poLine);
addMockEntry(PIECES_STORAGE, electronicPiece);

List<ToBeExpected> toBeCheckedInList = new ArrayList<>();
toBeCheckedInList.add(new ToBeExpected()
.withExpected(1)
.withPoLineId(poLine.getId())
.withExpectPieces(Collections.singletonList(new ExpectPiece().withId(electronicPiece.getId()).withComment("test"))));

ExpectCollection request = new ExpectCollection()
.withToBeExpected(toBeCheckedInList)
.withTotalRecords(1);

Response response = verifyPostResponse(ORDERS_EXPECT_ENDPOINT, JsonObject.mapFrom(request).encode(),
prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10), APPLICATION_JSON, HttpStatus.HTTP_OK.toInt());
assertThat(response.as(ReceivingResults.class).getReceivingResults().get(0).getProcessedSuccessfully(), is(1));

List<JsonObject> pieceUpdates = getPieceUpdates();

assertThat(pieceUpdates, not(nullValue()));
assertThat(pieceUpdates, hasSize(request.getTotalRecords()));

pieceUpdates.forEach(pol -> {
Piece piece = pol.mapTo(Piece.class);
assertThat(piece.getId(), is(electronicPiece.getId()));
assertThat(piece.getReceivingStatus(), is(Piece.ReceivingStatus.EXPECTED));
assertThat(piece.getComment(), is("test"));
});
}

private void verifyProperQuantityOfHoldingsCreated(ReceivingCollection receivingRq) throws IOException {
Set<String> expectedHoldings = new HashSet<>();

Expand Down

0 comments on commit 89a2d06

Please sign in to comment.