use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestPaymentMethod method testGePaymentMethodsByKey.
@Test(groups = "slow", description = "Create/retrieve by externalKey")
public void testGePaymentMethodsByKey() throws Exception {
final Account accountJson = createAccountWithDefaultPaymentMethod("foo");
final PaymentMethod paymentMethodJson1 = paymentMethodApi.getPaymentMethodByKey("foo", NULL_PLUGIN_PROPERTIES, requestOptions);
final PaymentMethod paymentMethodJson2 = paymentMethodApi.getPaymentMethod(accountJson.getPaymentMethodId(), NULL_PLUGIN_PROPERTIES, requestOptions);
Assert.assertEquals(paymentMethodJson1, paymentMethodJson2);
final PaymentMethod paymentMethodJson3 = paymentMethodApi.getPaymentMethodByKey("doesnotexist", NULL_PLUGIN_PROPERTIES, requestOptions);
Assert.assertNull(paymentMethodJson3);
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestPerTenantConfig method testFailedPaymentWithPerTenantRetryConfig.
@Test(groups = "slow")
public void testFailedPaymentWithPerTenantRetryConfig() throws Exception {
// Create the tenant
createTenant("tenantSuperTuned", "2367$$ffr79", true);
// Configure our plugin to fail
mockPaymentProviderPlugin.makeAllInvoicesFailWithError(true);
// Upload the config
final ObjectMapper mapper = new ObjectMapper();
final HashMap<String, String> perTenantProperties = new HashMap<String, String>();
perTenantProperties.put("org.killbill.payment.retry.days", "1,1,1");
final String perTenantConfig = mapper.writeValueAsString(perTenantProperties);
callbackServlet.pushExpectedEvent(ExtBusEventType.TENANT_CONFIG_CHANGE);
final TenantKeyValue tenantKey = tenantApi.uploadPerTenantConfiguration(perTenantConfig, requestOptions);
callbackServlet.assertListenerStatus();
final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(false);
final Payments payments = accountApi.getPaymentsForAccount(accountJson.getAccountId(), NULL_PLUGIN_PROPERTIES, requestOptions);
Assert.assertEquals(payments.size(), 1);
Assert.assertEquals(payments.get(0).getTransactions().size(), 1);
//
// Because we have specified a retry interval of one day we should see the new attempt after moving clock 1 day (and not 8 days which is default)
//
//
// Now unregister special per tenant config and when the first retry occurs one day after (and still fails), it now sets a retry date of 8 days
//
callbackServlet.pushExpectedEvents(ExtBusEventType.TENANT_CONFIG_DELETION);
tenantApi.deletePerTenantConfiguration(requestOptions);
callbackServlet.assertListenerStatus();
callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_PAYMENT_FAILED, ExtBusEventType.PAYMENT_FAILED);
clock.addDays(1);
callbackServlet.assertListenerStatus();
final Payments payments2 = accountApi.getPaymentsForAccount(accountJson.getAccountId(), NULL_PLUGIN_PROPERTIES, requestOptions);
Assert.assertEquals(payments2.size(), 1);
Assert.assertEquals(payments2.get(0).getTransactions().size(), 2);
Assert.assertEquals(payments2.get(0).getTransactions().get(0).getStatus(), TransactionStatus.PAYMENT_FAILURE);
Assert.assertEquals(payments2.get(0).getTransactions().get(1).getStatus(), TransactionStatus.PAYMENT_FAILURE);
clock.addDays(1);
callbackServlet.assertListenerStatus();
// No retry with default config
final Payments payments3 = accountApi.getPaymentsForAccount(accountJson.getAccountId(), NULL_PLUGIN_PROPERTIES, requestOptions);
Assert.assertEquals(payments3.size(), 1);
Assert.assertEquals(payments3.get(0).getTransactions().size(), 2);
mockPaymentProviderPlugin.makeAllInvoicesFailWithError(false);
callbackServlet.pushExpectedEvents(ExtBusEventType.INVOICE_PAYMENT_SUCCESS, ExtBusEventType.PAYMENT_SUCCESS);
clock.addDays(7);
callbackServlet.assertListenerStatus();
final Payments payments4 = accountApi.getPaymentsForAccount(accountJson.getAccountId(), NULL_PLUGIN_PROPERTIES, requestOptions);
Assert.assertEquals(payments4.size(), 1);
Assert.assertEquals(payments4.get(0).getTransactions().size(), 3);
Assert.assertEquals(payments4.get(0).getTransactions().get(0).getStatus(), TransactionStatus.PAYMENT_FAILURE);
Assert.assertEquals(payments4.get(0).getTransactions().get(1).getStatus(), TransactionStatus.PAYMENT_FAILURE);
Assert.assertEquals(payments4.get(0).getTransactions().get(2).getStatus(), TransactionStatus.SUCCESS);
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestTag method testGetTagAuditLogsWithHistory.
@Test(groups = "slow", description = "retrieve account logs")
public void testGetTagAuditLogsWithHistory() throws Exception {
final Account accountJson = createAccount();
assertNotNull(accountJson);
final TagDefinition accountTagDefInput = new TagDefinition().setName("tag_name").setDescription("nothing special").setApplicableObjectTypes(ImmutableList.<ObjectType>of(ObjectType.ACCOUNT));
final TagDefinition accountTagDef = tagDefinitionApi.createTagDefinition(accountTagDefInput, requestOptions);
accountApi.createAccountTags(accountJson.getAccountId(), ImmutableList.<UUID>of(accountTagDef.getId()), requestOptions);
// get all audit for the account
final List<AuditLog> auditLogsJson = accountApi.getAccountAuditLogs(accountJson.getAccountId(), requestOptions);
Assert.assertEquals(auditLogsJson.size(), 2);
UUID objectId = null;
for (AuditLog auditLog : auditLogsJson) {
if (auditLog.getObjectType().equals(ObjectType.TAG)) {
objectId = auditLog.getObjectId();
break;
}
}
assertNotNull(objectId);
final List<AuditLog> tagAuditLogWithHistories = tagApi.getTagAuditLogsWithHistory(objectId, requestOptions);
assertEquals(tagAuditLogWithHistories.size(), 1);
assertEquals(tagAuditLogWithHistories.get(0).getChangeType(), ChangeType.INSERT.toString());
assertEquals(tagAuditLogWithHistories.get(0).getObjectType(), ObjectType.TAG);
assertEquals(tagAuditLogWithHistories.get(0).getObjectId(), objectId);
final LinkedHashMap history1 = (LinkedHashMap) tagAuditLogWithHistories.get(0).getHistory();
assertNotNull(history1);
assertEquals(history1.get("tagDefinitionId"), accountTagDef.getId().toString());
assertEquals(history1.get("objectId"), accountJson.getAccountId().toString());
assertEquals(history1.get("objectType"), ObjectType.ACCOUNT.toString());
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestTag method testSystemTagsPagination.
@Test(groups = "slow", description = "Can search system tags")
public void testSystemTagsPagination() throws Exception {
final Account account = createAccount();
int nbAllowedControlTagType = 0;
for (final ControlTagType controlTagType : ControlTagType.values()) {
if (controlTagType.getApplicableObjectTypes().contains(ObjectType.ACCOUNT)) {
accountApi.createAccountTags(account.getAccountId(), ImmutableList.<UUID>of(controlTagType.getId()), requestOptions);
nbAllowedControlTagType++;
}
}
final Tags allTags = accountApi.getAccountTags(account.getAccountId(), requestOptions);
Assert.assertEquals(allTags.size(), nbAllowedControlTagType);
for (final ControlTagType controlTagType : ControlTagType.values()) {
if (controlTagType.getApplicableObjectTypes().contains(ObjectType.ACCOUNT)) {
Assert.assertEquals(tagApi.searchTags(controlTagType.toString(), requestOptions).size(), 1);
// TODO Hack until we fix client api
Assert.assertEquals(tagApi.searchTags(Utf8UrlEncoder.encodePath(controlTagType.getDescription()), requestOptions).size(), 1);
}
}
}
use of org.killbill.billing.client.model.gen.Account in project killbill by killbill.
the class TestTag method testNotApplicableType.
@Test(groups = "slow", description = "Cannot create a control tag against wrong object type")
public void testNotApplicableType() throws Exception {
final Account account = createAccount();
try {
accountApi.createAccountTags(account.getAccountId(), ImmutableList.<UUID>of(ControlTagType.WRITTEN_OFF.getId()), requestOptions);
Assert.fail("Creating a (control) tag against a wrong object type should fail");
} catch (final Exception e) {
Assert.assertTrue(true);
}
}
Aggregations