use of org.killbill.billing.client.model.Account in project killbill by killbill.
the class TestPaymentGateway method testBuildFormDescriptor.
@Test(groups = "slow")
public void testBuildFormDescriptor() throws Exception {
final Account account = createAccountWithDefaultPaymentMethod();
final HostedPaymentPageFields hppFields = new HostedPaymentPageFields();
final HostedPaymentPageFormDescriptor hostedPaymentPageFormDescriptor = killBillClient.buildFormDescriptor(hppFields, account.getAccountId(), null, ImmutableMap.<String, String>of(), requestOptions);
Assert.assertEquals(hostedPaymentPageFormDescriptor.getKbAccountId(), account.getAccountId());
}
use of org.killbill.billing.client.model.Account in project killbill by killbill.
the class TestPaymentGateway method testComboBuildFormDescriptor.
@Test(groups = "slow")
public void testComboBuildFormDescriptor() throws Exception {
final Account account = getAccount();
account.setAccountId(null);
final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
final PaymentMethod paymentMethod = new PaymentMethod(null, UUID.randomUUID().toString(), null, true, PLUGIN_NAME, info);
final HostedPaymentPageFields hppFields = new HostedPaymentPageFields();
final ComboHostedPaymentPage comboHostedPaymentPage = new ComboHostedPaymentPage(account, paymentMethod, ImmutableList.<PluginProperty>of(), hppFields);
final HostedPaymentPageFormDescriptor hostedPaymentPageFormDescriptor = killBillClient.buildFormDescriptor(comboHostedPaymentPage, ImmutableMap.<String, String>of(), requestOptions);
Assert.assertNotNull(hostedPaymentPageFormDescriptor.getKbAccountId());
}
use of org.killbill.billing.client.model.Account in project killbill by killbill.
the class TestPaymentMethod method testSearchPaymentMethods.
@Test(groups = "slow", description = "Can search payment methods")
public void testSearchPaymentMethods() throws Exception {
// Search random key
Assert.assertEquals(killBillClient.searchPaymentMethodsByKey(UUID.randomUUID().toString()).size(), 0);
Assert.assertEquals(killBillClient.searchPaymentMethodsByKeyAndPlugin(UUID.randomUUID().toString(), PLUGIN_NAME).size(), 0);
// Create a payment method
final List<PluginProperty> pmProperties = new ArrayList<PluginProperty>();
pmProperties.add(new PluginProperty("CC_NAME", "Bozo", false));
pmProperties.add(new PluginProperty("CC_CITY", "SF", false));
pmProperties.add(new PluginProperty("CC_LAST_4", "4365", false));
pmProperties.add(new PluginProperty("CC_STATE", "CA", false));
pmProperties.add(new PluginProperty("CC_COUNTRY", "Zimbawe", false));
final Account accountJson = createAccountWithDefaultPaymentMethod(UUID.randomUUID().toString(), pmProperties);
final PaymentMethod paymentMethodJson = killBillClient.getPaymentMethod(accountJson.getPaymentMethodId(), true);
// Search random key again
Assert.assertEquals(killBillClient.searchPaymentMethodsByKey(UUID.randomUUID().toString()).size(), 0);
Assert.assertEquals(killBillClient.searchPaymentMethodsByKeyAndPlugin(UUID.randomUUID().toString(), PLUGIN_NAME).size(), 0);
// Last 4
doSearch("4365", paymentMethodJson);
// Name
doSearch("Bozo", paymentMethodJson);
// City
doSearch("SF", paymentMethodJson);
// State
doSearch("CA", paymentMethodJson);
// Country
doSearch("Zimbawe", paymentMethodJson);
}
use of org.killbill.billing.client.model.Account in project killbill by killbill.
the class TestPaymentMethod method testPaymentMethodCustomFields.
@Test(groups = "slow", description = "Can create, retrieve and delete custom fields")
public void testPaymentMethodCustomFields() throws Exception {
final Account account = createAccountWithDefaultPaymentMethod();
final UUID paymentMethodId = account.getPaymentMethodId();
final CustomField customField = new CustomField();
customField.setObjectId(paymentMethodId);
customField.setObjectType(ObjectType.PAYMENT_METHOD);
customField.setName("testKey");
customField.setValue("testValue");
// Create custom field
final CustomFields createdCustomFields = killBillClient.createPaymentMethodCustomField(paymentMethodId, customField, createdBy, reason, comment);
Assert.assertEquals(createdCustomFields.size(), 1);
final CustomField createdCustomField = createdCustomFields.get(0);
Assert.assertEquals(createdCustomField.getName(), "testKey");
Assert.assertEquals(createdCustomField.getValue(), "testValue");
Assert.assertEquals(createdCustomField.getObjectId(), paymentMethodId);
Assert.assertEquals(createdCustomField.getObjectType(), ObjectType.PAYMENT_METHOD);
// Retrieve custom field
final CustomFields retrievedCustomFields = killBillClient.getPaymentMethodCustomFields(paymentMethodId, AuditLevel.NONE);
Assert.assertEquals(retrievedCustomFields.size(), 1);
final CustomField retrievedCustomField = retrievedCustomFields.get(0);
Assert.assertEquals(retrievedCustomField.getName(), "testKey");
Assert.assertEquals(retrievedCustomField.getValue(), "testValue");
Assert.assertEquals(retrievedCustomField.getObjectId(), paymentMethodId);
Assert.assertEquals(retrievedCustomField.getObjectType(), ObjectType.PAYMENT_METHOD);
// Delete custom field
killBillClient.deletePaymentMethodCustomFields(paymentMethodId, Collections.<UUID>singletonList(createdCustomField.getCustomFieldId()), createdBy, reason, comment);
final CustomFields deletedCustomFields = killBillClient.getPaymentMethodCustomFields(paymentMethodId, AuditLevel.NONE);
Assert.assertEquals(deletedCustomFields.size(), 0);
}
use of org.killbill.billing.client.model.Account 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