use of org.folio.rest.acq.model.CompositePurchaseOrder in project mod-gobi by folio-org.
the class GOBIIntegrationServiceResourceImplTest method testPostGobiOrdersContributorNameTypeNotAvailable.
@Test
public final void testPostGobiOrdersContributorNameTypeNotAvailable() throws Exception {
logger.info("Begin: Testing contributor is ignored if contributor name type cannot be resolved");
final String body = getMockData(PO_LISTED_ELECTRONIC_MONOGRAPH_PATH);
GobiResponse order = postOrderSuccess(body, new Header(MOCK_OKAPI_GET_CONTRIBUTOR_NAME_HEADER, MOCK_INSTRUCTION_NOT_EXIST));
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);
assertTrue(compPO.getCompositePoLines().get(0).getContributors().isEmpty());
logger.info("End: Testing contributor is ignored if contributor name type cannot be resolved");
}
use of org.folio.rest.acq.model.CompositePurchaseOrder in project mod-gobi by folio-org.
the class GOBIIntegrationServiceResourceImplTest method testPostGobiOrdersFallBackMaterialTypes.
@Test
public final void testPostGobiOrdersFallBackMaterialTypes(TestContext context) throws Exception {
logger.info("Begin: Testing for falling back to the unspecified material 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(MATERIAL_TYPES, HttpMethod.GET);
// 2 calls must be made to material types end point, once for non existent and other for unspecified
assertEquals(2, configEntries.size());
List<JsonObject> postedOrder = MockServer.serverRqRs.get(PURCHASE_ORDER, HttpMethod.POST);
CompositePurchaseOrder compPO = postedOrder.get(0).mapTo(CompositePurchaseOrder.class);
assertEquals(UNSPECIFIED_MATERIAL_TYPE_ID, compPO.getCompositePoLines().get(0).getEresource().getMaterialType());
verifyRequiredFieldsAreMapped(compPO);
assertNotNull(compPO.getCompositePoLines().get(0).getFundDistribution().get(0).getFundId());
asyncLocal.complete();
logger.info("End: Testing for falling back to the unspecified material 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 testPostGobiOrdersPOListedPrintMonograph.
@Test
public final void testPostGobiOrdersPOListedPrintMonograph(TestContext context) throws Exception {
logger.info("Begin: Testing for 201 - posted order listed print monograph");
final Async asyncLocal = context.async();
final String body = getMockData(PO_LISTED_PRINT_MONOGRAPH_PATH);
final GobiResponse order = postOrderSuccess(body);
context.assertNotNull(order.getPoLineNumber());
Map<String, List<JsonObject>> column = MockServer.serverRqRs.column(HttpMethod.GET);
// Listed Print 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, EXPENSE_CLASS, ACQUISITION_METHOD, MATERIAL_SUPPLIER));
List<JsonObject> postedOrder = MockServer.serverRqRs.get(PURCHASE_ORDER, HttpMethod.POST);
CompositePurchaseOrder compPO = postedOrder.get(0).mapTo(CompositePurchaseOrder.class);
assertThat(compPO.getCompositePoLines().get(0).getCost().getListUnitPriceElectronic(), nullValue());
assertThat(compPO.getCompositePoLines().get(0).getCost().getListUnitPrice(), equalTo(14.95));
assertNotNull(compPO.getCompositePoLines().get(0).getFundDistribution().get(0).getFundId());
assertNotNull(compPO.getCompositePoLines().get(0).getFundDistribution().get(0).getExpenseClassId());
assertNotNull(compPO.getCompositePoLines().get(0).getAcquisitionMethod());
verifyRequiredFieldsAreMapped(compPO);
assertNotNull(compPO.getCompositePoLines().get(0).getFundDistribution().get(0).getFundId());
assertFalse(compPO.getCompositePoLines().get(0).getTags().getTagList().isEmpty());
asyncLocal.complete();
logger.info("End: Testing for 201 - posted order listed print monograph");
}
use of org.folio.rest.acq.model.CompositePurchaseOrder in project mod-gobi by folio-org.
the class GOBIIntegrationServiceResourceImplTest method testPostGobiOrdersNoFundsExist.
@Test
public final void testPostGobiOrdersNoFundsExist() throws Exception {
logger.info("Begin: Testing for checking if FundId is not set if there are no Funds in the environment");
final String body = getMockData(PO_LISTED_ELECTRONIC_MONOGRAPH_PATH);
final GobiResponse order = postOrderSuccess(body, new Header(MOCK_OKAPI_GET_FUND_HEADER, MOCK_INSTRUCTION_NOT_EXIST));
assertNotNull(order.getPoLineNumber());
List<JsonObject> fundsRequests = MockServer.serverRqRs.get(FUNDS, HttpMethod.GET);
// 1 call must be made to Funds endpoint, as there is no default mapping
assertEquals(1, fundsRequests.size());
List<JsonObject> postedOrder = MockServer.serverRqRs.get(PURCHASE_ORDER, HttpMethod.POST);
CompositePurchaseOrder compPO = postedOrder.get(0).mapTo(CompositePurchaseOrder.class);
verifyRequiredFieldsAreMapped(compPO);
// Fund Distribution List must be empty, with no proper FundId
assertEquals(Collections.emptyList(), compPO.getCompositePoLines().get(0).getFundDistribution());
logger.info("End: Testing for checking if FundId is not set if there are no Funds in the environment");
}
use of org.folio.rest.acq.model.CompositePurchaseOrder in project mod-gobi by folio-org.
the class GOBIIntegrationServiceResourceImplTest method testPostGobiOrdersPOUnlistedPrintMonograph.
@Test
public final void testPostGobiOrdersPOUnlistedPrintMonograph(TestContext context) throws Exception {
logger.info("Begin: Testing for 201 - posted order unlisted print monograph");
final Async asyncLocal = context.async();
final String body = getMockData(PO_UNLISTED_PRINT_MONOGRAPHPATH);
final GobiResponse order = postOrderSuccess(body);
context.assertNotNull(order.getPoLineNumber());
Map<String, List<JsonObject>> column = MockServer.serverRqRs.column(HttpMethod.GET);
assertThat(column.keySet(), containsInAnyOrder(CONFIGURATION, CONTRIBUTOR_NAME_TYPES, FUNDS, LOCATION, MATERIAL_TYPES, PURCHASE_ORDER, VENDOR, ACQUISITION_METHOD, MATERIAL_SUPPLIER));
verifyResourceCreateInventoryNotMapped();
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());
assertFalse(compPO.getCompositePoLines().get(0).getTags().getTagList().isEmpty());
asyncLocal.complete();
logger.info("End: Testing for 201 - posted order unlisted print monograph");
}
Aggregations