use of org.folio.rest.jaxrs.model.Voucher in project mod-invoice by folio-org.
the class VouchersApiTest method testGetVouchersVoucherById.
@Test
public void testGetVouchersVoucherById() throws IOException {
logger.info("=== Test Get Voucher By Id ===");
JsonObject vouchersList = new JsonObject(getMockData(VOUCHERS_LIST_PATH));
String id = vouchersList.getJsonArray("vouchers").getJsonObject(0).getString(ID);
logger.info(String.format("using mock datafile: %s%s.json", VOUCHERS_LIST_PATH, id));
final Voucher resp = verifySuccessGet(String.format(VOUCHER_ID_PATH, id), Voucher.class);
assertNotNull(resp.getVendorAddress());
assertThat(resp.getVendorAddress()).hasFieldOrPropertyWithValue("addressLine1", "10 Estes Street").hasFieldOrPropertyWithValue("addressLine2", "22").hasFieldOrPropertyWithValue("city", "Ipswich").hasFieldOrPropertyWithValue("stateRegion", "MA").hasFieldOrPropertyWithValue("zipCode", "01938").hasFieldOrPropertyWithValue("country", "USA");
logger.info(JsonObject.mapFrom(resp).encodePrettily());
assertEquals(id, resp.getId());
}
use of org.folio.rest.jaxrs.model.Voucher in project mod-invoice by folio-org.
the class InvoiceLinesRetrieveServiceTest method positiveGetInvoiceMapTest.
@Test
public void positiveGetInvoiceMapTest() throws IOException, ExecutionException, InterruptedException {
RestClient restClient = new RestClient();
InvoiceLinesRetrieveService service = new InvoiceLinesRetrieveService(new InvoiceLineService(restClient));
JsonObject vouchersList = new JsonObject(getMockData(VOUCHERS_LIST_PATH));
List<Voucher> vouchers = vouchersList.getJsonArray("vouchers").stream().map(obj -> ((JsonObject) obj).mapTo(Voucher.class)).collect(toList());
vouchers.remove(1);
VoucherCollection voucherCollection = new VoucherCollection();
voucherCollection.setVouchers(vouchers);
CompletableFuture<Map<String, List<InvoiceLine>>> future = service.getInvoiceLineMap(voucherCollection, new RequestContext(context, okapiHeaders));
Map<String, List<InvoiceLine>> listMap = future.get();
Assertions.assertEquals(1, listMap.values().size());
}
use of org.folio.rest.jaxrs.model.Voucher in project mod-invoice by folio-org.
the class InvoiceRetrieveServiceTest method positiveGetInvoiceMapTest.
@Test
public void positiveGetInvoiceMapTest() throws IOException, ExecutionException, InterruptedException {
InvoiceService invoiceService = new BaseInvoiceService(new RestClient(), invoiceLineService, orderService);
InvoiceRetrieveService service = new InvoiceRetrieveService(invoiceService);
JsonObject vouchersList = new JsonObject(getMockData(VOUCHERS_LIST_PATH));
List<Voucher> vouchers = vouchersList.getJsonArray("vouchers").stream().map(obj -> ((JsonObject) obj).mapTo(Voucher.class)).collect(toList());
vouchers.remove(1);
VoucherCollection voucherCollection = new VoucherCollection();
voucherCollection.setVouchers(vouchers);
CompletableFuture<Map<String, Invoice>> future = service.getInvoiceMap(voucherCollection, new RequestContext(context, okapiHeaders));
Map<String, Invoice> lineMap = future.get();
Assertions.assertEquals(3, lineMap.values().size());
}
use of org.folio.rest.jaxrs.model.Voucher in project mod-invoice by folio-org.
the class VoucherLinesRetrieveServiceTest method positiveGetInvoiceMapTest.
@Test
public void positiveGetInvoiceMapTest() throws IOException, ExecutionException, InterruptedException {
VoucherLinesRetrieveService service = new VoucherLinesRetrieveService(okapiHeaders, context, "en");
JsonObject vouchersList = new JsonObject(getMockData(VOUCHERS_LIST_PATH));
List<Voucher> vouchers = vouchersList.getJsonArray("vouchers").stream().map(obj -> ((JsonObject) obj).mapTo(Voucher.class)).collect(toList());
vouchers.remove(1);
VoucherCollection voucherCollection = new VoucherCollection();
voucherCollection.setVouchers(vouchers);
CompletableFuture<Map<String, List<VoucherLine>>> future = service.getVoucherLinesMap(voucherCollection);
Map<String, List<VoucherLine>> lineMap = future.get();
Assertions.assertEquals(3, lineMap.get("a9b99f8a-7100-47f2-9903-6293d44a9905").size());
}
use of org.folio.rest.jaxrs.model.Voucher in project mod-invoice by folio-org.
the class VoucherCommandService method buildNewVoucher.
/**
* Build new {@link Voucher} based on processed {@link Invoice}
*
* @param invoice invoice {@link Invoice} to be approved
* @return completable future with {@link Voucher}
*/
public CompletableFuture<Voucher> buildNewVoucher(Invoice invoice, RequestContext requestContext) {
Voucher voucher = new Voucher();
voucher.setInvoiceId(invoice.getId());
return getVoucherNumberWithPrefix(requestContext).thenApply(voucher::withVoucherNumber);
}
Aggregations