Search in sources :

Example 6 with CustomFields

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

the class TestCustomField method doSearchCustomField.

private void doSearchCustomField(final String searchKey, @Nullable final CustomField expectedCustomField) throws KillBillClientException {
    final CustomFields customFields = customFieldApi.searchCustomFields(searchKey, requestOptions);
    if (expectedCustomField == null) {
        Assert.assertTrue(customFields.isEmpty());
        Assert.assertEquals(customFields.getPaginationCurrentOffset(), 0);
        Assert.assertEquals(customFields.getPaginationTotalNbRecords(), 0);
        Assert.assertEquals(customFields.getPaginationMaxNbRecords(), 5);
    } else {
        Assert.assertEquals(customFields.size(), 1);
        Assert.assertEquals(customFields.get(0), expectedCustomField);
        Assert.assertEquals(customFields.getPaginationCurrentOffset(), 0);
        Assert.assertEquals(customFields.getPaginationTotalNbRecords(), 1);
        Assert.assertEquals(customFields.getPaginationMaxNbRecords(), 5);
    }
}
Also used : CustomFields(org.killbill.billing.client.model.CustomFields)

Example 7 with CustomFields

use of org.killbill.billing.client.model.CustomFields 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);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) CustomFields(org.killbill.billing.client.model.CustomFields) CustomField(org.killbill.billing.client.model.gen.CustomField) UUID(java.util.UUID) Test(org.testng.annotations.Test)

Example 8 with CustomFields

use of org.killbill.billing.client.model.CustomFields 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);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) CustomFields(org.killbill.billing.client.model.CustomFields) CustomField(org.killbill.billing.client.model.gen.CustomField) Test(org.testng.annotations.Test)

Aggregations

CustomFields (org.killbill.billing.client.model.CustomFields)8 Account (org.killbill.billing.client.model.gen.Account)7 CustomField (org.killbill.billing.client.model.gen.CustomField)7 Test (org.testng.annotations.Test)7 UUID (java.util.UUID)2 LinkedHashMap (java.util.LinkedHashMap)1 AuditLogs (org.killbill.billing.client.model.AuditLogs)1 Invoices (org.killbill.billing.client.model.Invoices)1 AuditLog (org.killbill.billing.client.model.gen.AuditLog)1 InvoiceItem (org.killbill.billing.client.model.gen.InvoiceItem)1