Skip to content

Commit

Permalink
[MODORDERS-963] - Fixed ProtectedEntityTestBase
Browse files Browse the repository at this point in the history
  • Loading branch information
azizbekxm committed Nov 28, 2023
1 parent b2d458f commit 72a3dea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/test/java/org/folio/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ public static CompositePoLine getMinimalContentCompositePoLine(String orderId) {
.withPurchaseOrderId(orderId);
}

public static Title getMinimalContentTitle() {
return new Title().withTitle("Test title").withId(SAMPLE_TITLE_ID);
}

public static CompositePoLine getMinimalPackageCompositePoLine(String orderId) {
return new CompositePoLine().withSource(CompositePoLine.Source.EDI)
.withId(MIN_PO_LINE_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import static org.folio.TestUtils.getMinimalContentCompositePoLine;
import static org.folio.TestUtils.getMinimalContentCompositePurchaseOrder;
import static org.folio.TestUtils.getMinimalContentPiece;
import static org.folio.TestUtils.getMinimalContentTitle;
import static org.folio.TestUtils.getRandomId;
import static org.folio.orders.utils.ResourcePathResolver.PIECES_STORAGE;
import static org.folio.orders.utils.ResourcePathResolver.PO_LINES_STORAGE;
import static org.folio.orders.utils.ResourcePathResolver.PURCHASE_ORDER_STORAGE;
import static org.folio.orders.utils.ResourcePathResolver.TITLES;
import static org.folio.rest.RestVerticle.OKAPI_USERID_HEADER;
import static org.folio.rest.impl.MockServer.addMockEntry;
import static org.hamcrest.MatcherAssert.assertThat;
Expand All @@ -24,6 +26,7 @@
import org.folio.rest.jaxrs.model.CompositePoLine;
import org.folio.rest.jaxrs.model.CompositePurchaseOrder;
import org.folio.rest.jaxrs.model.Piece;
import org.folio.rest.jaxrs.model.Title;
import org.hamcrest.Matcher;

import io.restassured.http.Header;
Expand Down Expand Up @@ -73,9 +76,18 @@ public CompositePoLine preparePoLine(List<String> acqUnitsIds,
return poLine;
}

public Title prepareTitle(List<String> acqUnitIds) {
Title title = getMinimalContentTitle();
title.setAcqUnitIds(acqUnitIds);
addMockEntry(TITLES, JsonObject.mapFrom(title));
return title;
}

public Piece preparePiece(List<String> acqUnitsIds) {
CompositePoLine poLine = preparePoLine(acqUnitsIds, CompositePurchaseOrder.WorkflowStatus.OPEN);
CompositePoLine poLine = preparePoLine(new ArrayList<>(), CompositePurchaseOrder.WorkflowStatus.OPEN);
Title title = prepareTitle(acqUnitsIds);
Piece piece = getMinimalContentPiece(poLine.getId());
piece.setTitleId(title.getId());
addMockEntry(PIECES_STORAGE, JsonObject.mapFrom(piece));

return piece;
Expand Down

0 comments on commit 72a3dea

Please sign in to comment.