Search in sources :

Example 11 with Title

use of org.folio.rest.acq.model.Title in project mod-orders by folio-org.

the class PurchaseOrderLinesApiTest method testPutOrderLineByIdPiecesWillNotBeCreated.

@Test
void testPutOrderLineByIdPiecesWillNotBeCreated() {
    logger.info("=== Test PUT Order Line By Id - Pieces will be created ===");
    String lineId = PO_LINE_ID_FOR_SUCCESS_CASE;
    CompositePoLine body = getMockAsJson(COMP_PO_LINES_MOCK_DATA_PATH, lineId).mapTo(CompositePoLine.class);
    body.setCheckinItems(false);
    body.setIsPackage(false);
    body.setReceiptStatus(ReceiptStatus.AWAITING_RECEIPT);
    body.setReportingCodes(new ArrayList<>());
    MockServer.addMockEntry(PO_LINES_STORAGE, body);
    MockServer.addMockEntry(PURCHASE_ORDER_STORAGE, new CompositePurchaseOrder().withId(ID_FOR_PRINT_MONOGRAPH_ORDER).withWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN).withOrderType(CompositePurchaseOrder.OrderType.ONE_TIME));
    String url = String.format(LINE_BY_ID_PATH, lineId);
    addMockEntry(TITLES, new Title().withId(UUID.randomUUID().toString()).withPoLineId(body.getId()).withTitle("Title"));
    verifyPut(url, JsonObject.mapFrom(body), "", 204);
    Map<String, List<JsonObject>> mockServerData = MockServer.serverRqRs.column(HttpMethod.GET);
    assertThat(mockServerData.get(PIECES_STORAGE), nullValue());
    mockServerData = MockServer.serverRqRs.column(HttpMethod.POST);
    assertThat(mockServerData.get(PIECES_STORAGE), nullValue());
}
Also used : CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) Title(org.folio.rest.acq.model.Title) ArrayList(java.util.ArrayList) List(java.util.List) Matchers.containsString(org.hamcrest.Matchers.containsString) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 12 with Title

use of org.folio.rest.acq.model.Title in project mod-orders by folio-org.

the class PurchaseOrderLinesApiTest method testGetPackageOrderLineByIdWithTitle.

@Test
void testGetPackageOrderLineByIdWithTitle() {
    logger.info("=== Test Get Orderline By Id with title ===");
    String instanceId = UUID.randomUUID().toString();
    String polineId = UUID.randomUUID().toString();
    addMockEntry(TITLES, new Title().withId(UUID.randomUUID().toString()).withPoLineId(polineId).withTitle("Title").withInstanceId(instanceId));
    addMockEntry(PO_LINES_STORAGE, getMinimalContentCompositePoLine().withIsPackage(true).withId(polineId));
    final CompositePoLine resp = verifySuccessGet(String.format(LINE_BY_ID_PATH, polineId), CompositePoLine.class);
    logger.info(JsonObject.mapFrom(resp).encodePrettily());
    assertEquals(polineId, resp.getId());
    assertThat(getPoLineSearches(), hasSize(1));
    assertThat(getTitlesSearches(), nullValue());
    assertThat(resp.getInstanceId(), nullValue());
}
Also used : Title(org.folio.rest.acq.model.Title) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) Matchers.containsString(org.hamcrest.Matchers.containsString) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 13 with Title

use of org.folio.rest.acq.model.Title in project mod-orders by folio-org.

the class PurchaseOrderLinesApiTest method testGetOrderLineByIdWithTitle.

@Test
void testGetOrderLineByIdWithTitle() {
    logger.info("=== Test Get Orderline By Id with title ===");
    String instanceId = UUID.randomUUID().toString();
    addMockEntry(TITLES, new Title().withId(UUID.randomUUID().toString()).withPoLineId(ANOTHER_PO_LINE_ID_FOR_SUCCESS_CASE).withTitle("Title").withInstanceId(instanceId));
    final CompositePoLine resp = verifySuccessGet(String.format(LINE_BY_ID_PATH, ANOTHER_PO_LINE_ID_FOR_SUCCESS_CASE), CompositePoLine.class);
    logger.info(JsonObject.mapFrom(resp).encodePrettily());
    assertEquals(ANOTHER_PO_LINE_ID_FOR_SUCCESS_CASE, resp.getId());
    assertThat(getPoLineSearches(), hasSize(1));
    assertThat(getTitlesSearches(), hasSize(1));
    assertThat(instanceId, is(resp.getInstanceId()));
}
Also used : Title(org.folio.rest.acq.model.Title) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) Matchers.containsString(org.hamcrest.Matchers.containsString) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 14 with Title

use of org.folio.rest.acq.model.Title in project mod-orders by folio-org.

the class PurchaseOrderLinesApiTest method testPutOrderLineWithTagInheritance.

@Test
void testPutOrderLineWithTagInheritance() {
    logger.info("=== Test PUT Order Line With Tag Inheritance ===");
    String lineId = "bb66b269-76ed-4616-8da9-730d9b817247";
    CompositePoLine body = getMockAsJson(COMP_PO_LINES_MOCK_DATA_PATH, lineId).mapTo(CompositePoLine.class);
    body.setCheckinItems(false);
    body.setIsPackage(false);
    body.setReceiptStatus(ReceiptStatus.AWAITING_RECEIPT);
    body.setReportingCodes(new ArrayList<>());
    body.setPurchaseOrderId(ID_FOR_PRINT_MONOGRAPH_ORDER);
    MockServer.addMockEntry(PO_LINES_STORAGE, body);
    MockServer.addMockEntry(PURCHASE_ORDER_STORAGE, new CompositePurchaseOrder().withId(ID_FOR_PRINT_MONOGRAPH_ORDER).withWorkflowStatus(CompositePurchaseOrder.WorkflowStatus.OPEN).withOrderType(CompositePurchaseOrder.OrderType.ONE_TIME));
    String url = String.format(LINE_BY_ID_PATH, lineId);
    addMockEntry(TITLES, new Title().withId(UUID.randomUUID().toString()).withPoLineId(body.getId()).withTitle("Title"));
    // edit POLine for new encumbrance
    body.setTags(new Tags().withTagList(Collections.singletonList("created")));
    body.setFundDistribution(Collections.singletonList(new FundDistribution().withCode("EUROHIST").withFundId("e9285a1c-1dfc-4380-868c-e74073003f43").withDistributionType(FundDistribution.DistributionType.PERCENTAGE).withValue(100D)));
    verifyPut(url, JsonObject.mapFrom(body), "", 204);
    Transaction createdEncumbrance = MockServer.getCreatedEncumbrances().get(0);
    assertEquals(Collections.singletonList("created"), createdEncumbrance.getTags().getTagList());
    // edit POLine for encumbrance update
    body.setTags(new Tags().withTagList(Collections.singletonList("updated")));
    body.setCost(new Cost().withCurrency("USD").withListUnitPrice(70.0).withQuantityPhysical(1));
    body.setFundDistribution(Collections.singletonList(new FundDistribution().withCode("EUROHIST").withFundId("a89eccf0-57a6-495e-898d-32b9b2210f2f").withDistributionType(FundDistribution.DistributionType.PERCENTAGE).withValue(100D)));
    verifyPut(url, JsonObject.mapFrom(body), "", 204);
    Transaction updatedEncumbrance = MockServer.getUpdatedTransactions().get(1);
    assertEquals(Collections.singletonList("updated"), updatedEncumbrance.getTags().getTagList());
}
Also used : FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) Transaction(org.folio.rest.acq.model.finance.Transaction) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) TestUtils.getMinimalContentCompositePoLine(org.folio.TestUtils.getMinimalContentCompositePoLine) Title(org.folio.rest.acq.model.Title) Matchers.containsString(org.hamcrest.Matchers.containsString) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) Cost(org.folio.rest.jaxrs.model.Cost) Tags(org.folio.rest.jaxrs.model.Tags) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 15 with Title

use of org.folio.rest.acq.model.Title in project mod-orders by folio-org.

the class TitlesApiTest method testGetTitleById.

@Test
void testGetTitleById() {
    logger.info("=== Test Get Title By Id ===");
    final Title resp = verifySuccessGet(String.format(TITLES_ID_PATH, SAMPLE_TITLE_ID), Title.class);
    logger.info(JsonObject.mapFrom(resp).encodePrettily());
    assertEquals(SAMPLE_TITLE_ID, resp.getId());
}
Also used : Title(org.folio.rest.acq.model.Title) Test(org.junit.jupiter.api.Test)

Aggregations

Title (org.folio.rest.acq.model.Title)15 Test (org.junit.jupiter.api.Test)11 TestUtils.getMinimalContentCompositePoLine (org.folio.TestUtils.getMinimalContentCompositePoLine)9 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 JsonObject (io.vertx.core.json.JsonObject)4 TestUtils.getTitle (org.folio.TestUtils.getTitle)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Transaction (org.folio.rest.acq.model.finance.Transaction)3 Header (io.restassured.http.Header)2 Collections (java.util.Collections)2 Date (java.util.Date)2 CompositePurchaseOrder (org.folio.rest.jaxrs.model.CompositePurchaseOrder)2 HashBasedTable (com.google.common.collect.HashBasedTable)1 Lists (com.google.common.collect.Lists)1 Table (com.google.common.collect.Table)1 Vertx (io.vertx.core.Vertx)1