Search in sources :

Example 1 with TagDefinition

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

Example 2 with TagDefinition

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());
}
Also used : TagDefinition(org.killbill.billing.client.model.TagDefinition) Test(org.testng.annotations.Test)

Example 3 with TagDefinition

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) {
        }
    }
}
Also used : TagDefinition(org.killbill.billing.client.model.TagDefinition) KillBillClientException(org.killbill.billing.client.KillBillClientException) Test(org.testng.annotations.Test)

Example 4 with TagDefinition

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);
}
Also used : TagDefinition(org.killbill.billing.client.model.TagDefinition) Test(org.testng.annotations.Test)

Example 5 with TagDefinition

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);
}
Also used : Account(org.killbill.billing.client.model.Account) TagDefinition(org.killbill.billing.client.model.TagDefinition) Tag(org.killbill.billing.client.model.Tag) UUID(java.util.UUID) SystemTags(org.killbill.billing.util.tag.dao.SystemTags) 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