use of org.killbill.billing.client.model.Tags in project killbill by killbill.
the class TestOverdue method testControlTagOverdueConfig.
@Test(groups = "slow", description = "Allow overdue condition by control tag defined in overdue config xml file")
public void testControlTagOverdueConfig() throws Exception {
final String overdueConfigPath = Resources.getResource("overdueWithControlTag.xml").getPath();
killBillClient.uploadXMLOverdueConfig(overdueConfigPath, requestOptions);
// Create an account without a payment method and assign a TEST tag
final Account accountJson = createAccountNoPMBundleAndSubscription();
final Tags accountTag = killBillClient.createAccountTag(accountJson.getAccountId(), ControlTagType.TEST.getId(), requestOptions);
assertEquals(accountTag.get(0).getTagDefinitionId(), ControlTagType.TEST.getId());
// Create an account without a TEST tag
final Account accountJsonNoTag = createAccountNoPMBundleAndSubscription();
// No payment will be triggered as the account doesn't have a payment method
clock.addMonths(1);
crappyWaitForLackOfProperSynchonization();
// Get the invoices
final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoices.size(), 2);
final List<Invoice> invoicesNoTag = killBillClient.getInvoicesForAccount(accountJsonNoTag.getAccountId(), requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoicesNoTag.size(), 2);
// We're still clear - see the configuration
Assert.assertTrue(killBillClient.getOverdueStateForAccount(accountJson.getAccountId(), requestOptions).getIsClearState());
Assert.assertTrue(killBillClient.getOverdueStateForAccount(accountJsonNoTag.getAccountId(), requestOptions).getIsClearState());
clock.addDays(30);
crappyWaitForLackOfProperSynchonization();
// This account is expected to move to OD1 state because it matches with controlTag defined
Assert.assertEquals(killBillClient.getOverdueStateForAccount(accountJson.getAccountId(), requestOptions).getName(), "OD1");
// This account is not expected to move to OD1 state because it does not match with controlTag defined
Assert.assertTrue(killBillClient.getOverdueStateForAccount(accountJsonNoTag.getAccountId(), requestOptions).getIsClearState());
}
use of org.killbill.billing.client.model.Tags in project killbill by killbill.
the class TestTag method testTagsPagination.
@Test(groups = "slow", description = "Can paginate through all tags")
public void testTagsPagination() throws Exception {
final Account account = createAccount();
for (int i = 0; i < 5; i++) {
final TagDefinition tagDefinition = new TagDefinition(null, false, UUID.randomUUID().toString().substring(0, 5), UUID.randomUUID().toString(), ImmutableList.<ObjectType>of(ObjectType.ACCOUNT));
final UUID tagDefinitionId = killBillClient.createTagDefinition(tagDefinition, requestOptions).getId();
killBillClient.createAccountTag(account.getAccountId(), tagDefinitionId, requestOptions);
}
final Tags allTags = killBillClient.getTags(requestOptions);
Assert.assertEquals(allTags.size(), 5);
Tags page = killBillClient.getTags(0L, 1L, requestOptions);
for (int i = 0; i < 5; i++) {
Assert.assertNotNull(page);
Assert.assertEquals(page.size(), 1);
Assert.assertEquals(page.get(0), allTags.get(i));
page = page.getNext();
}
Assert.assertNull(page);
for (final Tag tag : allTags) {
doSearchTag(UUID.randomUUID().toString(), null);
doSearchTag(tag.getTagId().toString(), tag);
doSearchTag(tag.getTagDefinitionName(), tag);
final TagDefinition tagDefinition = killBillClient.getTagDefinition(tag.getTagDefinitionId(), requestOptions);
doSearchTag(tagDefinition.getDescription(), tag);
}
final Tags tags = killBillClient.searchTags(ObjectType.ACCOUNT.toString(), requestOptions);
Assert.assertEquals(tags.size(), 5);
Assert.assertEquals(tags.getPaginationCurrentOffset(), 0);
Assert.assertEquals(tags.getPaginationTotalNbRecords(), 5);
Assert.assertEquals(tags.getPaginationMaxNbRecords(), 5);
}
use of org.killbill.billing.client.model.Tags in project killbill by killbill.
the class TestTag method testGetAllTagsByType.
@Test(groups = "slow", description = "Can search all tags for an account")
public void testGetAllTagsByType() throws Exception {
final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
final Account account = createAccountWithDefaultPaymentMethod();
final Subscription subscriptionJson = createEntitlement(account.getAccountId(), "87544332", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, true);
for (final ControlTagType controlTagType : ControlTagType.values()) {
killBillClient.createAccountTag(account.getAccountId(), controlTagType.getId(), requestOptions);
}
final TagDefinition bundleTagDefInput = new TagDefinition(null, false, "bundletagdef", "nothing special", ImmutableList.<ObjectType>of());
final TagDefinition bundleTagDef = killBillClient.createTagDefinition(bundleTagDefInput, requestOptions);
killBillClient.createBundleTag(subscriptionJson.getBundleId(), bundleTagDef.getId(), requestOptions);
final Tags allBundleTags = killBillClient.getBundleTags(subscriptionJson.getBundleId(), AuditLevel.FULL, requestOptions);
Assert.assertEquals(allBundleTags.size(), 1);
final Tags allAccountTags = killBillClient.getAllAccountTags(account.getAccountId(), null, AuditLevel.FULL, requestOptions);
Assert.assertEquals(allAccountTags.size(), ControlTagType.values().length + 1);
final Tags allBundleTagsForAccount = killBillClient.getAllAccountTags(account.getAccountId(), ObjectType.BUNDLE.name(), AuditLevel.FULL, requestOptions);
Assert.assertEquals(allBundleTagsForAccount.size(), 1);
}
use of org.killbill.billing.client.model.Tags in project killbill by killbill.
the class TestOverdue method testExclusionControlTagOverdueConfig.
@Test(groups = "slow", description = "Allow overdue condition by exclusion control tag defined in overdue config xml file")
public void testExclusionControlTagOverdueConfig() throws Exception {
final String overdueConfigPath = Resources.getResource("overdueWithExclusionControlTag.xml").getPath();
killBillClient.uploadXMLOverdueConfig(overdueConfigPath, requestOptions);
// Create an account without a payment method and assign a TEST tag
final Account accountJson = createAccountNoPMBundleAndSubscription();
final Tags accountTag = killBillClient.createAccountTag(accountJson.getAccountId(), ControlTagType.TEST.getId(), requestOptions);
assertEquals(accountTag.get(0).getTagDefinitionId(), ControlTagType.TEST.getId());
// Create an account without a TEST tag
final Account accountJsonNoTag = createAccountNoPMBundleAndSubscription();
// move a month a wait for invoicing
// No payment will be triggered as the account doesn't have a payment method
clock.addMonths(1);
crappyWaitForLackOfProperSynchonization();
// Get the invoices
final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoices.size(), 2);
final List<Invoice> invoicesNoTag = killBillClient.getInvoicesForAccount(accountJsonNoTag.getAccountId(), requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoicesNoTag.size(), 2);
// We're still clear - see the configuration
Assert.assertTrue(killBillClient.getOverdueStateForAccount(accountJson.getAccountId(), requestOptions).getIsClearState());
Assert.assertTrue(killBillClient.getOverdueStateForAccount(accountJsonNoTag.getAccountId(), requestOptions).getIsClearState());
clock.addDays(30);
crappyWaitForLackOfProperSynchonization();
// This account is not expected to move to OD1 state because it does not match with exclusion controlTag defined
Assert.assertTrue(killBillClient.getOverdueStateForAccount(accountJson.getAccountId(), requestOptions).getIsClearState());
// This account is expected to move to OD1 state because it matches with exclusion controlTag defined
Assert.assertEquals(killBillClient.getOverdueStateForAccount(accountJsonNoTag.getAccountId(), requestOptions).getName(), "OD1");
}
use of org.killbill.billing.client.model.Tags in project killbill by killbill.
the class TestPayment method testCreateTagForPaymentTransaction.
@Test(groups = "slow")
public void testCreateTagForPaymentTransaction() throws Exception {
UUID tagDefinitionId = UUID.randomUUID();
String tagDefinitionName = "payment-transaction";
TagDefinition tagDefinition = new TagDefinition(tagDefinitionId, false, tagDefinitionName, "description", null);
final TagDefinition createdTagDefinition = killBillClient.createTagDefinition(tagDefinition, requestOptions);
final Account account = createAccountWithDefaultPaymentMethod();
final String externalPaymentKey = UUID.randomUUID().toString();
final UUID paymentId = testCreateRetrievePayment(account, null, externalPaymentKey, 1);
final Payment payment = killBillClient.getPaymentByExternalKey(externalPaymentKey, requestOptions);
assertEquals(payment.getPaymentId(), paymentId);
UUID paymentTransactionId = payment.getTransactions().get(0).getTransactionId();
final Tags paymentTransactionTag = killBillClient.createPaymentTransactionTag(paymentTransactionId, createdTagDefinition.getId(), requestOptions);
Assert.assertNotNull(paymentTransactionTag);
Assert.assertEquals(paymentTransactionTag.get(0).getTagDefinitionName(), tagDefinitionName);
}
Aggregations