use of org.killbill.billing.client.model.TagDefinition in project killbill by killbill.
the class TestPayment method testGetTagsForPaymentTransaction.
@Test(groups = "slow")
public void testGetTagsForPaymentTransaction() 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();
killBillClient.createPaymentTransactionTag(paymentTransactionId, createdTagDefinition.getId(), requestOptions);
final Tags paymentTransactionTags = killBillClient.getPaymentTransactionTags(paymentTransactionId, requestOptions);
Assert.assertNotNull(paymentTransactionTags);
Assert.assertEquals(paymentTransactionTags.get(0).getTagDefinitionName(), tagDefinitionName);
}
use of org.killbill.billing.client.model.TagDefinition in project killbill by killbill.
the class TestTag method testTagDefinitionOk.
@Test(groups = "slow", description = "Can create a TagDefinition")
public void testTagDefinitionOk() throws Exception {
final TagDefinition input = new TagDefinition(null, false, "blue", "relaxing color", ImmutableList.<ObjectType>of());
final TagDefinition objFromJson = killBillClient.createTagDefinition(input, requestOptions);
assertNotNull(objFromJson);
assertEquals(objFromJson.getName(), input.getName());
assertEquals(objFromJson.getDescription(), input.getDescription());
}
use of org.killbill.billing.client.model.TagDefinition in project killbill by killbill.
the class TestTag method testTagErrorHandling.
@Test(groups = "slow", description = "Cannot add badly formatted TagDefinition")
public void testTagErrorHandling() throws Exception {
final TagDefinition[] tagDefinitions = { new TagDefinition(null, false, null, null, null), new TagDefinition(null, false, "something", null, null), new TagDefinition(null, false, null, "something", null) };
for (final TagDefinition tagDefinition : tagDefinitions) {
try {
killBillClient.createTagDefinition(tagDefinition, requestOptions);
fail();
} catch (final KillBillClientException e) {
}
}
}
use of org.killbill.billing.client.model.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 = killBillClient.getTagDefinitions(requestOptions);
final int sizeSystemTag = objFromJson.isEmpty() ? 0 : objFromJson.size();
for (final TagDefinition cur : objFromJson) {
Assert.assertFalse(SystemTags.isSystemTag(cur.getId()));
}
final TagDefinition inputBlue = new TagDefinition(null, false, "blue", "relaxing color", ImmutableList.<ObjectType>of());
killBillClient.createTagDefinition(inputBlue, requestOptions);
final TagDefinition inputRed = new TagDefinition(null, false, "red", "hot color", ImmutableList.<ObjectType>of());
killBillClient.createTagDefinition(inputRed, requestOptions);
final TagDefinition inputYellow = new TagDefinition(null, false, "yellow", "vibrant color", ImmutableList.<ObjectType>of());
killBillClient.createTagDefinition(inputYellow, requestOptions);
final TagDefinition inputGreen = new TagDefinition(null, false, "green", "super relaxing color", ImmutableList.<ObjectType>of());
killBillClient.createTagDefinition(inputGreen, requestOptions);
objFromJson = killBillClient.getTagDefinitions(requestOptions);
assertNotNull(objFromJson);
assertEquals(objFromJson.size(), 4 + sizeSystemTag);
killBillClient.deleteTagDefinition(objFromJson.get(0).getId(), requestOptions);
objFromJson = killBillClient.getTagDefinitions(requestOptions);
assertNotNull(objFromJson);
assertEquals(objFromJson.size(), 3 + sizeSystemTag);
}
use of org.killbill.billing.client.model.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, 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);
}
Aggregations