use of org.folio.rest.acq.model.CompositePurchaseOrder in project mod-gobi by folio-org.
the class GOBIIntegrationServiceResourceImplTest method testPostGobiOrdersNoProductIdTypes.
@Test
public final void testPostGobiOrdersNoProductIdTypes() throws Exception {
logger.info("Begin: Testing for checking if productId is set if there are no productIdTypes in the environment");
final String body = getMockData(PO_LISTED_ELECTRONIC_MONOGRAPH_PATH);
final GobiResponse order = postOrderSuccess(body, new Header(MOCK_OKAPI_GET_IDENTIFIER_HEADER, MOCK_INSTRUCTION_NO_PRODUCTYPE));
assertNotNull(order.getPoLineNumber());
List<JsonObject> identifierTypes = MockServer.serverRqRs.get(IDENTIFIER_TYPES, HttpMethod.GET);
// 2 calls must be made to identifiers endpoint
assertEquals(2, identifierTypes.size());
List<JsonObject> postedOrder = MockServer.serverRqRs.get(PURCHASE_ORDER, HttpMethod.POST);
CompositePurchaseOrder compPO = postedOrder.get(0).mapTo(CompositePurchaseOrder.class);
// assert that the productId is mapped, so that if the order is created in Pending state even though
// there is no ProductIdType
assertNull(compPO.getCompositePoLines().get(0).getDetails().getProductIds().get(0).getProductIdType());
assertNotNull(compPO.getCompositePoLines().get(0).getDetails().getProductIds().get(0).getProductId());
verifyRequiredFieldsAreMapped(compPO);
assertNotNull(compPO.getCompositePoLines().get(0).getFundDistribution().get(0).getFundId());
logger.info("End: Testing for checking if productId is set if there are no productIdTypes in the environment");
}
use of org.folio.rest.acq.model.CompositePurchaseOrder in project mod-gobi by folio-org.
the class GOBIIntegrationServiceResourceImplTest method testPostGobiOrdersFallBackContributorTypeName.
@Test
public final void testPostGobiOrdersFallBackContributorTypeName() throws Exception {
logger.info("Begin: Testing for falling back to the first random contributor name type, if a non existent code is sent");
final String body = getMockData(PO_LISTED_ELECTRONIC_MONOGRAPH_PATH);
GobiResponse order = postOrderSuccess(body, new Header(MOCK_OKAPI_GET_CONTRIBUTOR_NAME_HEADER, MOCK_INSTRUCTION_USE_DEFAULT));
assertNotNull(order.getPoLineNumber());
List<JsonObject> types = MockServer.serverRqRs.get(CONTRIBUTOR_NAME_TYPES, HttpMethod.GET);
// 2 calls must be made
assertEquals(2, types.size());
List<JsonObject> postedOrder = MockServer.serverRqRs.get(PURCHASE_ORDER, HttpMethod.POST);
assertEquals(1, postedOrder.size());
CompositePurchaseOrder compPO = postedOrder.get(0).mapTo(CompositePurchaseOrder.class);
verifyRequiredFieldsAreMapped(compPO);
assertNotNull(compPO.getCompositePoLines().get(0).getContributors().get(0).getContributorNameTypeId());
assertNotNull(compPO.getCompositePoLines().get(0).getContributors().get(0).getContributor());
logger.info("End: Testing for falling back to the first random contributor name type, if a non existent code is sent");
}
use of org.folio.rest.acq.model.CompositePurchaseOrder in project mod-gobi by folio-org.
the class GOBIIntegrationServiceResourceImplTest method testPostGobiOrdersPOListedPrintSerial.
@Test
public final void testPostGobiOrdersPOListedPrintSerial(TestContext context) throws Exception {
logger.info("Begin: Testing for 201 - posted order listed print serial");
final Async asyncLocal = context.async();
final String body = getMockData(PO_LISTED_PRINT_SERIAL_PATH);
final GobiResponse order = postOrderSuccess(body);
context.assertNotNull(order.getPoLineNumber());
Map<String, List<JsonObject>> column = MockServer.serverRqRs.column(HttpMethod.GET);
assertThat(column.keySet(), containsInAnyOrder(CONFIGURATION, FUNDS, LOCATION, MATERIAL_TYPES, PURCHASE_ORDER, VENDOR, EXPENSE_CLASS, ACQUISITION_METHOD, MATERIAL_SUPPLIER));
List<JsonObject> postedOrder = MockServer.serverRqRs.get(PURCHASE_ORDER, HttpMethod.POST);
CompositePurchaseOrder compPO = postedOrder.get(0).mapTo(CompositePurchaseOrder.class);
// verify if default currency is used
assertEquals("USD", compPO.getCompositePoLines().get(0).getCost().getCurrency());
verifyRequiredFieldsAreMapped(compPO);
assertNotNull(compPO.getCompositePoLines().get(0).getFundDistribution().get(0).getFundId());
assertTrue(compPO.getCompositePoLines().get(0).getTags().getTagList().isEmpty());
asyncLocal.complete();
logger.info("End: Testing for 201 - posted order listed print serial");
}
use of org.folio.rest.acq.model.CompositePurchaseOrder in project mod-gobi by folio-org.
the class GOBIIntegrationServiceResourceImplTest method testPostGobiOrdersFallBackLocation.
@Test
public final void testPostGobiOrdersFallBackLocation(TestContext context) throws Exception {
logger.info("Begin: Testing for falling back to the first location id, if a non existent code is sent");
final Async asyncLocal = context.async();
final String body = getMockData(PO_LISTED_ELECTRONIC_SERIAL_PATH);
final GobiResponse order = postOrderSuccess(body);
context.assertNotNull(order.getPoLineNumber());
List<JsonObject> configEntries = MockServer.serverRqRs.get(LOCATION, HttpMethod.GET);
// 2 calls must be made to location end point
assertEquals(2, configEntries.size());
List<JsonObject> postedOrder = MockServer.serverRqRs.get(PURCHASE_ORDER, HttpMethod.POST);
CompositePurchaseOrder compPO = postedOrder.get(0).mapTo(CompositePurchaseOrder.class);
verifyRequiredFieldsAreMapped(compPO);
asyncLocal.complete();
logger.info("End: Testing for falling back to tthe first location id, if a non existent code is sent");
}
use of org.folio.rest.acq.model.CompositePurchaseOrder in project mod-gobi by folio-org.
the class GOBIIntegrationServiceResourceImplTest method testPostGobiOrdersPOListedElectronicMonograph.
@Test
public final void testPostGobiOrdersPOListedElectronicMonograph(TestContext context) throws Exception {
logger.info("Begin: Testing for 201 - posted order listed electronic monograph");
final Async asyncLocal = context.async();
final String body = getMockData(PO_LISTED_ELECTRONIC_MONOGRAPH_PATH);
final GobiResponse order = postOrderSuccess(body);
context.assertNotNull(order.getPoLineNumber());
Map<String, List<JsonObject>> column = MockServer.serverRqRs.column(HttpMethod.GET);
// Listed Electronic Monograph has to get the Product type ID so there will be an additional call made
assertThat(column.keySet(), containsInAnyOrder(CONFIGURATION, CONTRIBUTOR_NAME_TYPES, FUNDS, IDENTIFIER_TYPES, LOCATION, MATERIAL_TYPES, PURCHASE_ORDER, VENDOR, ACQUISITION_METHOD, MATERIAL_SUPPLIER));
List<JsonObject> postedOrder = MockServer.serverRqRs.get(PURCHASE_ORDER, HttpMethod.POST);
CompositePurchaseOrder compPO = postedOrder.get(0).mapTo(CompositePurchaseOrder.class);
verifyRequiredFieldsAreMapped(compPO);
assertNotNull(compPO.getCompositePoLines().get(0).getFundDistribution().get(0).getFundId());
// make sure that the qualifier field is empty
assertNull(compPO.getCompositePoLines().get(0).getDetails().getProductIds().get(0).getQualifier());
assertEquals("9781410352224", compPO.getCompositePoLines().get(0).getDetails().getProductIds().get(0).getProductId());
assertFalse(compPO.getCompositePoLines().get(0).getTags().getTagList().isEmpty());
asyncLocal.complete();
logger.info("End: Testing for 201 - posted order listed electronic monograph");
}
Aggregations