Search in sources :

Example 6 with TagDefinition

use of org.killbill.billing.client.model.TagDefinition 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);
}
Also used : Account(org.killbill.billing.client.model.Account) ControlTagType(org.killbill.billing.util.tag.ControlTagType) TagDefinition(org.killbill.billing.client.model.TagDefinition) Subscription(org.killbill.billing.client.model.Subscription) DateTime(org.joda.time.DateTime) SystemTags(org.killbill.billing.util.tag.dao.SystemTags) Tags(org.killbill.billing.client.model.Tags) Test(org.testng.annotations.Test)

Example 7 with TagDefinition

use of org.killbill.billing.client.model.TagDefinition 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);
}
Also used : TagDefinition(org.killbill.billing.client.model.TagDefinition) Account(org.killbill.billing.client.model.Account) Payment(org.killbill.billing.client.model.Payment) UUID(java.util.UUID) Tags(org.killbill.billing.client.model.Tags) Test(org.testng.annotations.Test)

Aggregations

TagDefinition (org.killbill.billing.client.model.TagDefinition)7 Test (org.testng.annotations.Test)7 Account (org.killbill.billing.client.model.Account)4 Tags (org.killbill.billing.client.model.Tags)4 UUID (java.util.UUID)3 Payment (org.killbill.billing.client.model.Payment)2 SystemTags (org.killbill.billing.util.tag.dao.SystemTags)2 DateTime (org.joda.time.DateTime)1 KillBillClientException (org.killbill.billing.client.KillBillClientException)1 Subscription (org.killbill.billing.client.model.Subscription)1 Tag (org.killbill.billing.client.model.Tag)1 ControlTagType (org.killbill.billing.util.tag.ControlTagType)1