@Test(groups = "slow")
  public void testGetPaymentInfo() throws Exception {
    final PaymentPluginApi api =
        getTestApi(paymentPluginApiOSGIServiceRegistration, BUNDLE_TEST_RESOURCE_PREFIX);

    final DateTime beforeCall = new DateTime().toDateTime(DateTimeZone.UTC).minusSeconds(1);
    final PaymentTransactionInfoPlugin res =
        api.getPaymentInfo(
                UUID.randomUUID(),
                UUID.randomUUID(),
                ImmutableList.<PluginProperty>of(),
                callContext)
            .get(0);
    final DateTime afterCall = new DateTime().toDateTime(DateTimeZone.UTC).plusSeconds(1);

    Assert.assertTrue(res.getAmount().compareTo(BigDecimal.ZERO) == 0);
    Assert.assertTrue(res.getCreatedDate().compareTo(beforeCall) >= 0);
    Assert.assertTrue(res.getCreatedDate().compareTo(afterCall) <= 0);

    Assert.assertTrue(res.getEffectiveDate().compareTo(beforeCall) >= 0);
    Assert.assertTrue(res.getEffectiveDate().compareTo(afterCall) <= 0);

    assertEquals(res.getGatewayError(), "gateway_error");
    assertEquals(res.getGatewayErrorCode(), "gateway_error_code");

    assertEquals(res.getStatus(), PaymentPluginStatus.PROCESSED);
  }
 @Test(groups = "slow")
 public void testSetDefaultPaymentMethod() throws Exception {
   final PaymentPluginApi api =
       getTestApi(paymentPluginApiOSGIServiceRegistration, BUNDLE_TEST_RESOURCE_PREFIX);
   api.setDefaultPaymentMethod(
       UUID.randomUUID(), UUID.randomUUID(), ImmutableList.<PluginProperty>of(), callContext);
 }
  @Test(groups = "slow")
  public void testGetPaymentMethods() throws Exception {
    final PaymentPluginApi api =
        getTestApi(paymentPluginApiOSGIServiceRegistration, BUNDLE_TEST_RESOURCE_PREFIX);
    final UUID kbAccountId = UUID.randomUUID();
    final List<PaymentMethodInfoPlugin> res =
        api.getPaymentMethods(kbAccountId, true, ImmutableList.<PluginProperty>of(), callContext);

    assertEquals(res.size(), 1);

    final PaymentMethodInfoPlugin res0 = res.get(0);
    Assert.assertTrue(res0.isDefault());
    assertEquals(res0.getExternalPaymentMethodId(), "external_payment_method_id");
    assertEquals(res0.getAccountId(), kbAccountId);
    assertEquals(res0.getPaymentMethodId(), kbAccountId);
  }
  @Test(groups = "slow")
  public void testGetPaymentMethodDetail() throws Exception {
    final PaymentPluginApi api =
        getTestApi(paymentPluginApiOSGIServiceRegistration, BUNDLE_TEST_RESOURCE_PREFIX);
    final PaymentMethodPlugin res =
        api.getPaymentMethodDetail(
            UUID.randomUUID(), UUID.randomUUID(), ImmutableList.<PluginProperty>of(), callContext);

    assertEquals(res.getExternalPaymentMethodId(), "external_payment_method_id");
    Assert.assertTrue(res.isDefaultPaymentMethod());
    assertEquals(res.getProperties().size(), 2);
    assertEquals(res.getProperties().get(0).getKey(), "key1");
    assertEquals(res.getProperties().get(0).getValue(), "value1");
    assertEquals(res.getProperties().get(1).getKey(), "key2");
    assertEquals(res.getProperties().get(1).getValue(), "value2");
  }
  @Test(groups = "slow")
  public void testAddPaymentMethod() throws Exception {
    final PaymentPluginApi api =
        getTestApi(paymentPluginApiOSGIServiceRegistration, BUNDLE_TEST_RESOURCE_PREFIX);

    final PaymentMethodPlugin paymentMethodPlugin = Mockito.mock(PaymentMethodPlugin.class);
    Mockito.when(paymentMethodPlugin.getExternalPaymentMethodId())
        .thenReturn(UUID.randomUUID().toString());

    api.addPaymentMethod(
        UUID.randomUUID(),
        UUID.randomUUID(),
        paymentMethodPlugin,
        true,
        ImmutableList.<PluginProperty>of(),
        callContext);
  }
 private List<PaymentTransactionInfoPlugin> getPaymentTransactionInfoPlugins(
     final PaymentPluginApi plugin,
     final PaymentModelDao paymentModelDao,
     final Iterable<PluginProperty> properties,
     final TenantContext context)
     throws PaymentApiException {
   try {
     return plugin.getPaymentInfo(
         paymentModelDao.getAccountId(), paymentModelDao.getId(), properties, context);
   } catch (final PaymentPluginApiException e) {
     throw new PaymentApiException(
         ErrorCode.PAYMENT_PLUGIN_GET_PAYMENT_INFO, paymentModelDao.getId(), e.toString());
   }
 }