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