use of org.killbill.billing.client.model.gen.CustomField 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");
final CustomFields body = new CustomFields();
body.add(customField);
// Create custom field
final CustomFields createdCustomFields = paymentMethodApi.createPaymentMethodCustomFields(paymentMethodId, body, requestOptions);
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 = paymentMethodApi.getPaymentMethodCustomFields(paymentMethodId, requestOptions);
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
paymentMethodApi.deletePaymentMethodCustomFields(paymentMethodId, Collections.<UUID>singletonList(createdCustomField.getCustomFieldId()), requestOptions);
final CustomFields deletedCustomFields = paymentMethodApi.getPaymentMethodCustomFields(paymentMethodId, requestOptions);
Assert.assertEquals(deletedCustomFields.size(), 0);
}
use of org.killbill.billing.client.model.gen.CustomField in project killbill by killbill.
the class TestCustomField method testBasicCustomFields.
@Test(groups = "slow", description = "Can create/modify/delete custom fields")
public void testBasicCustomFields() throws Exception {
final Account account = createAccount();
final CustomField customField = new CustomField();
customField.setName("MyName");
customField.setValue("InitialValue");
final CustomFields input = new CustomFields();
input.add(customField);
accountApi.createAccountCustomFields(account.getAccountId(), input, requestOptions);
CustomFields allCustomFields = accountApi.getAccountCustomFields(account.getAccountId(), requestOptions);
Assert.assertEquals(allCustomFields.size(), 1);
Assert.assertEquals(allCustomFields.get(0).getName(), "MyName");
Assert.assertEquals(allCustomFields.get(0).getValue(), "InitialValue");
final CustomField customFieldModified = new CustomField();
customFieldModified.setCustomFieldId(allCustomFields.get(0).getCustomFieldId());
customFieldModified.setValue("NewValue");
input.clear();
input.add(customFieldModified);
accountApi.modifyAccountCustomFields(account.getAccountId(), input, requestOptions);
allCustomFields = accountApi.getAccountCustomFields(account.getAccountId(), requestOptions);
Assert.assertEquals(allCustomFields.size(), 1);
Assert.assertEquals(allCustomFields.get(0).getName(), "MyName");
Assert.assertEquals(allCustomFields.get(0).getValue(), "NewValue");
accountApi.deleteAccountCustomFields(account.getAccountId(), ImmutableList.<UUID>of(allCustomFields.get(0).getCustomFieldId()), requestOptions);
allCustomFields = accountApi.getAccountCustomFields(account.getAccountId(), requestOptions);
Assert.assertEquals(allCustomFields.size(), 0);
}
Aggregations