use of org.killbill.billing.client.model.gen.TagDefinition 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, "td-" + i, UUID.randomUUID().toString(), ImmutableList.<ObjectType>of(ObjectType.ACCOUNT), null);
final UUID tagDefinitionId = tagDefinitionApi.createTagDefinition(tagDefinition, requestOptions).getId();
accountApi.createAccountTags(account.getAccountId(), ImmutableList.<UUID>of(tagDefinitionId), requestOptions);
}
final Tags allTags = accountApi.getAccountTags(account.getAccountId(), requestOptions);
Assert.assertEquals(allTags.size(), 5);
Tags page = tagApi.getTags(0L, 1L, AuditLevel.NONE, requestOptions);
for (int i = 0; i < 5; i++) {
Assert.assertNotNull(page);
Assert.assertEquals(page.size(), 1);
final Tag targetTag = page.get(0);
Assert.assertTrue(Iterables.any(allTags, new Predicate<Tag>() {
@Override
public boolean apply(@Nullable final Tag input) {
return input.equals(targetTag);
}
}));
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 = tagDefinitionApi.getTagDefinition(tag.getTagDefinitionId(), requestOptions);
doSearchTag(tagDefinition.getDescription(), tag);
}
final Tags tags = tagApi.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.gen.TagDefinition in project killbill by killbill.
the class TestTag method testMultipleTagDefinitionOk.
@Test(groups = "slow", description = "Can create and delete TagDefinitions")
public void testMultipleTagDefinitionOk() throws Exception {
List<TagDefinition> objFromJson = tagDefinitionApi.getTagDefinitions(requestOptions);
final int sizeSystemTag = objFromJson.isEmpty() ? 0 : objFromJson.size();
final TagDefinition inputBlue = new TagDefinition(null, false, "blue", "relaxing color", ImmutableList.<ObjectType>of(ObjectType.TRANSACTION), null);
tagDefinitionApi.createTagDefinition(inputBlue, requestOptions);
final TagDefinition inputRed = new TagDefinition(null, false, "red", "hot color", ImmutableList.<ObjectType>of(ObjectType.TRANSACTION), null);
tagDefinitionApi.createTagDefinition(inputRed, requestOptions);
final TagDefinition inputYellow = new TagDefinition(null, false, "yellow", "vibrant color", ImmutableList.<ObjectType>of(ObjectType.TRANSACTION), null);
tagDefinitionApi.createTagDefinition(inputYellow, requestOptions);
final TagDefinition inputGreen = new TagDefinition(null, false, "green", "super relaxing color", ImmutableList.<ObjectType>of(ObjectType.TRANSACTION), null);
tagDefinitionApi.createTagDefinition(inputGreen, requestOptions);
objFromJson = tagDefinitionApi.getTagDefinitions(requestOptions);
assertNotNull(objFromJson);
assertEquals(objFromJson.size(), 4 + sizeSystemTag);
tagDefinitionApi.deleteTagDefinition(objFromJson.get(0).getId(), requestOptions);
objFromJson = tagDefinitionApi.getTagDefinitions(requestOptions);
assertNotNull(objFromJson);
assertEquals(objFromJson.size(), 3 + sizeSystemTag);
}
use of org.killbill.billing.client.model.gen.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 = createSubscription(account.getAccountId(), "87544332", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY);
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 TagDefinition bundleTagDefInput = new TagDefinition(null, false, "bundletagdef", "nothing special", ImmutableList.<ObjectType>of(ObjectType.TRANSACTION), null);
final TagDefinition bundleTagDef = tagDefinitionApi.createTagDefinition(bundleTagDefInput, requestOptions);
bundleApi.createBundleTags(subscriptionJson.getBundleId(), ImmutableList.<UUID>of(bundleTagDef.getId()), requestOptions);
final Tags allBundleTags = bundleApi.getBundleTags(subscriptionJson.getBundleId(), requestOptions);
Assert.assertEquals(allBundleTags.size(), 1);
final Tags allAccountTags = accountApi.getAllTags(account.getAccountId(), null, requestOptions);
Assert.assertEquals(allAccountTags.size(), nbAllowedControlTagType + 1);
final Tags allBundleTagsForAccount = accountApi.getAllTags(account.getAccountId(), ObjectType.BUNDLE, requestOptions);
Assert.assertEquals(allBundleTagsForAccount.size(), 1);
}
use of org.killbill.billing.client.model.gen.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", ImmutableList.<ObjectType>of(ObjectType.TRANSACTION), null);
final TagDefinition createdTagDefinition = tagDefinitionApi.createTagDefinition(tagDefinition, requestOptions);
final Account account = createAccountWithDefaultPaymentMethod();
final String externalPaymentKey = UUID.randomUUID().toString();
final UUID paymentId = testCreateRetrievePayment(account, null, externalPaymentKey, 1);
final Payment payment = paymentApi.getPaymentByExternalKey(externalPaymentKey, NULL_PLUGIN_PROPERTIES, requestOptions);
assertEquals(payment.getPaymentId(), paymentId);
UUID paymentTransactionId = payment.getTransactions().get(0).getTransactionId();
final Tags paymentTransactionTag = paymentTransactionApi.createTransactionTags(paymentTransactionId, ImmutableList.<UUID>of(createdTagDefinition.getId()), requestOptions);
Assert.assertNotNull(paymentTransactionTag);
Assert.assertEquals(paymentTransactionTag.get(0).getTagDefinitionName(), tagDefinitionName);
}
Aggregations