@Test(groups = "fast") public void testPaymentSuccess() throws Exception { setUp(PaymentPluginStatus.PROCESSED); Assert.assertNull(paymentStateContext.getPaymentInfoPlugin()); Assert.assertEquals(paymentOperation.doOperationCallback(), OperationResult.SUCCESS); Assert.assertNotNull(paymentStateContext.getPaymentInfoPlugin()); }
@Test(groups = "fast") public void testPaymentPending() throws Exception { setUp(PaymentPluginStatus.PENDING); Assert.assertNull(paymentStateContext.getPaymentInfoPlugin()); Assert.assertEquals(paymentOperation.doOperationCallback(), OperationResult.PENDING); Assert.assertNotNull(paymentStateContext.getPaymentInfoPlugin()); }
@Test(groups = "fast") public void testPaymentFailure() throws Exception { setUp(PaymentPluginStatus.ERROR); Assert.assertNull(paymentStateContext.getPaymentInfoPlugin()); Assert.assertEquals(paymentOperation.doOperationCallback(), OperationResult.FAILURE); Assert.assertNotNull(paymentStateContext.getPaymentInfoPlugin()); }
private void setUp(final PaymentPluginStatus paymentPluginStatus) throws Exception { final GlobalLocker locker = new MemoryGlobalLocker(); final PluginDispatcher<OperationResult> paymentPluginDispatcher = new PluginDispatcher<OperationResult>(1, Executors.newCachedThreadPool()); paymentStateContext = new PaymentStateContext( true, UUID.randomUUID(), null, null, UUID.randomUUID().toString(), UUID.randomUUID().toString(), TransactionType.CAPTURE, Mockito.mock(Account.class), UUID.randomUUID(), new BigDecimal("192.3920111"), Currency.BRL, false, null, ImmutableList.<PluginProperty>of(), internalCallContext, callContext); final PaymentMethodModelDao paymentMethodModelDao = new PaymentMethodModelDao( paymentStateContext.getPaymentMethodId(), UUID.randomUUID().toString(), clock.getUTCNow(), clock.getUTCNow(), paymentStateContext.getAccount().getId(), MockPaymentProviderPlugin.PLUGIN_NAME, true); final PaymentDao paymentDao = Mockito.mock(PaymentDao.class); Mockito.when( paymentDao.getPaymentMethodIncludedDeleted( paymentStateContext.getPaymentMethodId(), internalCallContext)) .thenReturn(paymentMethodModelDao); final PaymentAutomatonDAOHelper daoHelper = new PaymentAutomatonDAOHelper( paymentStateContext, clock.getUTCNow(), paymentDao, registry, internalCallContext, eventBus, paymentSMHelper); paymentOperation = new PaymentOperationTest( paymentPluginStatus, daoHelper, locker, paymentPluginDispatcher, paymentStateContext); }
@Test(groups = "fast") public void testPluginFailure() throws Exception { setUp(null); Assert.assertNull(paymentStateContext.getPaymentInfoPlugin()); try { paymentOperation.doOperationCallback(); Assert.fail(); } catch (final OperationException e) { Assert.assertEquals(e.getOperationResult(), OperationResult.EXCEPTION); } Assert.assertNull(paymentStateContext.getPaymentInfoPlugin()); }