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());
}
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());
}
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()));
}
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());
}
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());
}
Aggregations