From 72a3dea620639c3ca4b63f6e3fb847d27fc2ef90 Mon Sep 17 00:00:00 2001 From: azizbekxm Date: Tue, 28 Nov 2023 18:11:30 +0500 Subject: [PATCH] [MODORDERS-963] - Fixed ProtectedEntityTestBase --- src/test/java/org/folio/TestUtils.java | 4 ++++ .../impl/protection/ProtectedEntityTestBase.java | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/folio/TestUtils.java b/src/test/java/org/folio/TestUtils.java index 441aa81df..1c5273899 100644 --- a/src/test/java/org/folio/TestUtils.java +++ b/src/test/java/org/folio/TestUtils.java @@ -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) diff --git a/src/test/java/org/folio/rest/impl/protection/ProtectedEntityTestBase.java b/src/test/java/org/folio/rest/impl/protection/ProtectedEntityTestBase.java index 8218ea10e..8ca3b599d 100644 --- a/src/test/java/org/folio/rest/impl/protection/ProtectedEntityTestBase.java +++ b/src/test/java/org/folio/rest/impl/protection/ProtectedEntityTestBase.java @@ -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; @@ -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; @@ -73,9 +76,18 @@ public CompositePoLine preparePoLine(List acqUnitsIds, return poLine; } + public Title prepareTitle(List acqUnitIds) { + Title title = getMinimalContentTitle(); + title.setAcqUnitIds(acqUnitIds); + addMockEntry(TITLES, JsonObject.mapFrom(title)); + return title; + } + public Piece preparePiece(List 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;