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);
}
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);
}
Aggregations