Skip to content

Commit

Permalink
[MODORDERS-1210] Fix failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Saba-Zedginidze-EPAM committed Nov 27, 2024
1 parent bdb3693 commit 7e5cbd6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public void handle(Message<JsonObject> message) {
var requestContext = new RequestContext(ctx, okapiHeaders);

var poLineId = getPoLineId(messageFromEventBus);
var future = purchaseOrderLineService.getOrderLineById(poLineId, requestContext)
.compose(poLine -> pieceStorageService.getPiecesByLineId(poLineId, requestContext)
.compose(pieces -> updatePoLineAndOrderStatuses(pieces, poLine, requestContext))
var future = pieceStorageService.getPiecesByLineId(poLineId, requestContext)
.compose(pieces -> purchaseOrderLineService.getOrderLineById(poLineId, requestContext)
.compose(poLine -> updatePoLineAndOrderStatuses(pieces, poLine, requestContext))
.onFailure(e -> logger.error("Exception occurred while fetching PoLine by id: '{}'", poLineId, e)))
.onFailure(e -> logger.error("Exception occurred while fetching pieces by PoLine id: '{}'", poLineId, e));

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/folio/orders/events/utils/EventUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

public class EventUtils {

private static final String POL_UPDATE = "poLineIdUpdate";
public static final String POL_UPDATE_FIELD = "poLineIdUpdate";

public static JsonObject createPoLineUpdateEvent(String poLineId) {
return JsonObject.of(POL_UPDATE, poLineId);
return JsonObject.of(POL_UPDATE_FIELD, poLineId);
}

public static String getPoLineId(JsonObject eventPayload) {
return eventPayload.getString(POL_UPDATE);
return eventPayload.getString(POL_UPDATE_FIELD);
}

private EventUtils() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.awaitility.Awaitility.await;
import static org.folio.helper.BaseHelper.EVENT_PAYLOAD;
import static org.folio.orders.events.utils.EventUtils.POL_UPDATE_FIELD;
import static org.folio.rest.impl.EventBusContextConfiguration.eventMessages;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -71,7 +72,7 @@ public static void verifyReceiptStatusUpdateEvent(int msgQty) {
assertThat(message.headers(), not(emptyIterable()));
assertThat(message.body(), notNullValue());
assertThat(message.body()
.getString("poLineIdUpdate"), not(is(emptyOrNullString())));
.getString(POL_UPDATE_FIELD), not(is(emptyOrNullString())));
assertThat(message.body()
.getString(HelperUtils.LANG), not(is(emptyOrNullString())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.folio.TestConfig.isVerticleNotDeployed;
import static org.folio.TestUtils.checkVertxContextCompletion;
import static org.folio.TestUtils.getMockAsJson;
import static org.folio.orders.events.utils.EventUtils.POL_UPDATE_FIELD;
import static org.folio.rest.impl.MockServer.POLINES_COLLECTION;
import static org.folio.rest.impl.MockServer.PO_LINES_MOCK_DATA_PATH;
import static org.folio.rest.impl.MockServer.getPieceSearches;
Expand Down Expand Up @@ -227,7 +228,7 @@ void testPieceReceiptStatusFailureWhenNoMatchingPoLineForPiece(VertxTestContext

private JsonObject createBody(String poLineId) {
JsonObject jsonObj = new JsonObject();
jsonObj.put("poLineIdUpdate", poLineId);
jsonObj.put(POL_UPDATE_FIELD, poLineId);
return jsonObj;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void poLineStatusWhenReceiveLast() {
var receiptStatus = calculatePoLineReceiptStatus(poLineId, fromStorage, update);

// then
assertEquals(CompositePoLine.ReceiptStatus.FULLY_RECEIVED, receiptStatus);
assertEquals(PoLine.ReceiptStatus.FULLY_RECEIVED, receiptStatus);
}

@Test
Expand All @@ -345,7 +345,7 @@ void poLineStatusWhenExpectLast() {
var receiptStatus = calculatePoLineReceiptStatus(poLineId, fromStorage, update);

// then
assertEquals(CompositePoLine.ReceiptStatus.PARTIALLY_RECEIVED, receiptStatus);
assertEquals(PoLine.ReceiptStatus.PARTIALLY_RECEIVED, receiptStatus);
}

@Test
Expand All @@ -359,7 +359,7 @@ void poLineStatusWhenExpectAll() {
var receiptStatus = calculatePoLineReceiptStatus(poLineId, fromStorage, update);

// then
assertEquals(CompositePoLine.ReceiptStatus.AWAITING_RECEIPT, receiptStatus);
assertEquals(PoLine.ReceiptStatus.AWAITING_RECEIPT, receiptStatus);
}

@Test
Expand All @@ -373,7 +373,7 @@ void poLineStatusWhenReceivePart() {
var receiptStatus = calculatePoLineReceiptStatus(poLineId, fromStorage, update);

// then
assertEquals(CompositePoLine.ReceiptStatus.PARTIALLY_RECEIVED, receiptStatus);
assertEquals(PoLine.ReceiptStatus.PARTIALLY_RECEIVED, receiptStatus);
}

private static List<Piece> givenPieces(Piece.ReceivingStatus... statuses) {
Expand Down

0 comments on commit 7e5cbd6

Please sign in to comment.