/** Tests the PaymentRouterCurrencyTask. */ @Test public void testPaymentRouterCurrencyTask() { // prepare UserWS userUSD = buildUser(PRANCING_PONY_ACCOUNT_TYPE); userUSD.setCurrencyId(CURRENCY_USD); userUSD.setId(api.createUser(userUSD)); UserWS userAUD = buildUser(PRANCING_PONY_ACCOUNT_TYPE); userAUD.setCurrencyId(CURRENCY_AUD); userAUD.setId(api.createUser(userAUD)); ItemTypeWS itemType = buildItemType(); itemType.setId(api.createItemCategory(itemType)); ItemDTOEx item = buildItem(itemType.getId(), api.getCallerCompanyId()); item.setId(api.createItem(item)); // testing OrderWS order = buildOrder(userUSD.getId(), Arrays.asList(item.getId()), new BigDecimal("10")); order.setCurrencyId(userUSD.getCurrencyId()); // create the order and invoice it System.out.println("Creating and invoicing order ..."); Integer invoiceIdUSD = api.createOrderAndInvoice( order, OrderChangeBL.buildFromOrder(order, ORDER_CHANGE_STATUS_APPLY)); Integer orderIdUSD = api.getLastOrders(userUSD.getId(), 1)[0]; // try paying the invoice in USD System.out.println("Making payment in USD..."); PaymentAuthorizationDTOEx authInfo = api.payInvoice(invoiceIdUSD); assertTrue("USD Payment should be successful", authInfo.getResult().booleanValue()); assertEquals( "Should be processed by 'first_fake_processor'", authInfo.getProcessor(), "first_fake_processor"); // create a new order in AUD and invoice it order.setUserId(userAUD.getId()); order.setCurrencyId(userAUD.getCurrencyId()); System.out.println("Creating and invoicing order ..."); Integer invoiceIdAUD = api.createOrderAndInvoice( order, OrderChangeBL.buildFromOrder(order, ORDER_CHANGE_STATUS_APPLY)); Integer orderIdAUD = api.getLastOrders(userAUD.getId(), 1)[0]; // try paying the invoice in AUD System.out.println("Making payment in AUD..."); authInfo = api.payInvoice(invoiceIdAUD); assertTrue("AUD Payment should be successful", authInfo.getResult().booleanValue()); assertEquals( "Should be processed by 'second_fake_processor'", authInfo.getProcessor(), "second_fake_processor"); // remove invoices and orders System.out.println("Deleting invoices and orders."); api.deleteInvoice(invoiceIdUSD); api.deleteInvoice(invoiceIdAUD); api.deleteOrder(orderIdUSD); api.deleteOrder(orderIdAUD); api.deleteUser(userUSD.getId()); api.deleteUser(userAUD.getId()); api.deleteItem(item.getId()); api.deleteItemCategory(itemType.getId()); }