Search in sources :

Example 1 with Tags

use of org.killbill.billing.client.model.Tags in project killbill by killbill.

the class KillbillClient method createAccountWithExternalPMBundleAndSubscriptionAndManualPayTagAndWaitForFirstInvoice.

protected Account createAccountWithExternalPMBundleAndSubscriptionAndManualPayTagAndWaitForFirstInvoice() throws Exception {
    final Account accountJson = createAccountWithExternalPaymentMethod();
    assertNotNull(accountJson);
    callbackServlet.pushExpectedEvent(ExtBusEventType.TAG_CREATION);
    final Tags accountTag = accountApi.createAccountTags(accountJson.getAccountId(), ImmutableList.<UUID>of(ControlTagType.MANUAL_PAY.getId()), requestOptions);
    callbackServlet.assertListenerStatus();
    assertNotNull(accountTag);
    assertEquals(accountTag.get(0).getTagDefinitionId(), ControlTagType.MANUAL_PAY.getId());
    // Add a bundle, subscription and move the clock to get the first invoice
    final Subscription subscriptionJson = createSubscription(accountJson.getAccountId(), UUID.randomUUID().toString(), "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY);
    assertNotNull(subscriptionJson);
    callbackServlet.pushExpectedEvents(ExtBusEventType.SUBSCRIPTION_PHASE, ExtBusEventType.INVOICE_CREATION);
    clock.addDays(32);
    callbackServlet.assertListenerStatus();
    return accountJson;
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Subscription(org.killbill.billing.client.model.gen.Subscription) Tags(org.killbill.billing.client.model.Tags)

Example 2 with Tags

use of org.killbill.billing.client.model.Tags in project killbill by killbill.

the class TestPayment method testDeletePaymentMethodWithAutoPayOff.

@Test(groups = "slow")
public void testDeletePaymentMethodWithAutoPayOff() throws Exception {
    final Account account = createAccountWithDefaultPaymentMethod();
    final UUID paymentMethodId = account.getPaymentMethodId();
    RequestOptions inputOptions = RequestOptions.builder().withCreatedBy(createdBy).withReason(reason).withComment(comment).build();
    paymentMethodApi.deletePaymentMethod(paymentMethodId, true, false, NULL_PLUGIN_PROPERTIES, inputOptions);
    Tags accountTags = accountApi.getAccountTags(account.getAccountId(), inputOptions);
    Assert.assertNotNull(accountTags);
    Assert.assertEquals(accountTags.get(0).getTagDefinitionName(), "AUTO_PAY_OFF");
}
Also used : Account(org.killbill.billing.client.model.gen.Account) RequestOptions(org.killbill.billing.client.RequestOptions) UUID(java.util.UUID) Tags(org.killbill.billing.client.model.Tags) Test(org.testng.annotations.Test)

Example 3 with Tags

use of org.killbill.billing.client.model.Tags 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", 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();
    paymentTransactionApi.createTransactionTags(paymentTransactionId, ImmutableList.<UUID>of(createdTagDefinition.getId()), requestOptions);
    final Tags paymentTransactionTags = paymentTransactionApi.getTransactionTags(paymentTransactionId, requestOptions);
    Assert.assertNotNull(paymentTransactionTags);
    Assert.assertEquals(paymentTransactionTags.get(0).getTagDefinitionName(), tagDefinitionName);
}
Also used : TagDefinition(org.killbill.billing.client.model.gen.TagDefinition) Account(org.killbill.billing.client.model.gen.Account) InvoicePayment(org.killbill.billing.client.model.gen.InvoicePayment) Payment(org.killbill.billing.client.model.gen.Payment) UUID(java.util.UUID) Tags(org.killbill.billing.client.model.Tags) Test(org.testng.annotations.Test)

Example 4 with Tags

use of org.killbill.billing.client.model.Tags in project killbill by killbill.

the class TestTag method doSearchTag.

private void doSearchTag(final String searchKey, @Nullable final Tag expectedTag) throws KillBillClientException {
    final Tags tags = tagApi.searchTags(searchKey, requestOptions);
    if (expectedTag == null) {
        Assert.assertTrue(tags.isEmpty());
        Assert.assertEquals(tags.getPaginationCurrentOffset(), 0);
        Assert.assertEquals(tags.getPaginationTotalNbRecords(), 0);
        Assert.assertEquals(tags.getPaginationMaxNbRecords(), 5);
    } else {
        Assert.assertEquals(tags.size(), 1);
        Assert.assertEquals(tags.get(0), expectedTag);
        Assert.assertEquals(tags.getPaginationCurrentOffset(), 0);
        Assert.assertEquals(tags.getPaginationTotalNbRecords(), 1);
        Assert.assertEquals(tags.getPaginationMaxNbRecords(), 5);
    }
}
Also used : Tags(org.killbill.billing.client.model.Tags) SystemTags(org.killbill.billing.util.tag.dao.SystemTags)

Example 5 with Tags

use of org.killbill.billing.client.model.Tags in project killbill by killbill.

the class TestTag method testSystemTagsPagination.

@Test(groups = "slow", description = "Can search system tags")
public void testSystemTagsPagination() throws Exception {
    final Account account = createAccount();
    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 Tags allTags = accountApi.getAccountTags(account.getAccountId(), requestOptions);
    Assert.assertEquals(allTags.size(), nbAllowedControlTagType);
    for (final ControlTagType controlTagType : ControlTagType.values()) {
        if (controlTagType.getApplicableObjectTypes().contains(ObjectType.ACCOUNT)) {
            Assert.assertEquals(tagApi.searchTags(controlTagType.toString(), requestOptions).size(), 1);
            // TODO Hack until we fix client api
            Assert.assertEquals(tagApi.searchTags(Utf8UrlEncoder.encodePath(controlTagType.getDescription()), requestOptions).size(), 1);
        }
    }
}
Also used : Account(org.killbill.billing.client.model.gen.Account) ControlTagType(org.killbill.billing.util.tag.ControlTagType) Tags(org.killbill.billing.client.model.Tags) SystemTags(org.killbill.billing.util.tag.dao.SystemTags) Test(org.testng.annotations.Test)

Aggregations

Tags (org.killbill.billing.client.model.Tags)15 Account (org.killbill.billing.client.model.gen.Account)13 Test (org.testng.annotations.Test)13 UUID (java.util.UUID)9 Subscription (org.killbill.billing.client.model.gen.Subscription)5 TagDefinition (org.killbill.billing.client.model.gen.TagDefinition)4 SystemTags (org.killbill.billing.util.tag.dao.SystemTags)4 Invoices (org.killbill.billing.client.model.Invoices)2 Invoice (org.killbill.billing.client.model.gen.Invoice)2 InvoicePayment (org.killbill.billing.client.model.gen.InvoicePayment)2 Payment (org.killbill.billing.client.model.gen.Payment)2 ControlTagType (org.killbill.billing.util.tag.ControlTagType)2 Predicate (com.google.common.base.Predicate)1 Nullable (javax.annotation.Nullable)1 DateTime (org.joda.time.DateTime)1 KillBillClientException (org.killbill.billing.client.KillBillClientException)1 RequestOptions (org.killbill.billing.client.RequestOptions)1 Account (org.killbill.billing.client.model.Account)1 Subscription (org.killbill.billing.client.model.Subscription)1 Tag (org.killbill.billing.client.model.gen.Tag)1