use of org.killbill.billing.util.customfield.dao.CustomFieldModelDao in project killbill by killbill.
the class DefaultCustomFieldUserApi method addCustomFields.
@Override
public void addCustomFields(final List<CustomField> customFields, final CallContext context) throws CustomFieldApiException {
if (!customFields.isEmpty()) {
final InternalCallContext internalCallContext = internalCallContextFactory.createInternalCallContext(customFields.get(0).getObjectId(), customFields.get(0).getObjectType(), context);
final Iterable<CustomFieldModelDao> transformed = Iterables.transform(customFields, new Function<CustomField, CustomFieldModelDao>() {
@Override
public CustomFieldModelDao apply(final CustomField input) {
// TODO See https://github.com/killbill/killbill/issues/35
if (input.getId() != null) {
return new CustomFieldModelDao(input.getId(), context.getCreatedDate(), context.getCreatedDate(), input.getFieldName(), input.getFieldValue(), input.getObjectId(), input.getObjectType());
} else {
return new CustomFieldModelDao(context.getCreatedDate(), input.getFieldName(), input.getFieldValue(), input.getObjectId(), input.getObjectType());
}
}
});
((DefaultCustomFieldDao) customFieldDao).create(transformed, internalCallContext);
}
}
use of org.killbill.billing.util.customfield.dao.CustomFieldModelDao in project killbill by killbill.
the class DefaultCustomFieldUserApi method updateCustomFields.
@Override
public void updateCustomFields(final List<CustomField> customFields, final CallContext context) throws CustomFieldApiException {
if (!customFields.isEmpty()) {
final InternalCallContext internalCallContext = internalCallContextFactory.createInternalCallContext(customFields.get(0).getObjectId(), customFields.get(0).getObjectType(), context);
final Iterable<CustomFieldModelDao> customFieldIds = Iterables.transform(customFields, new Function<CustomField, CustomFieldModelDao>() {
@Override
public CustomFieldModelDao apply(final CustomField input) {
return new CustomFieldModelDao(input.getId(), internalCallContext.getCreatedDate(), internalCallContext.getUpdatedDate(), input.getFieldName(), input.getFieldValue(), input.getObjectId(), input.getObjectType());
}
});
customFieldDao.updateCustomFields(customFieldIds, internalCallContext);
}
}
use of org.killbill.billing.util.customfield.dao.CustomFieldModelDao in project killbill by killbill.
the class TestFieldStore method testCreateCustomField.
@Test(groups = "slow")
public void testCreateCustomField() throws CustomFieldApiException {
final UUID id = UUID.randomUUID();
final ObjectType objectType = ObjectType.ACCOUNT;
String fieldName = "TestField1";
String fieldValue = "Kitty Hawk";
eventsListener.pushExpectedEvent(NextEvent.CUSTOM_FIELD);
customFieldDao.create(new CustomFieldModelDao(internalCallContext.getCreatedDate(), fieldName, fieldValue, id, objectType), internalCallContext);
assertListenerStatus();
fieldName = "TestField2";
fieldValue = "Cape Canaveral";
eventsListener.pushExpectedEvent(NextEvent.CUSTOM_FIELD);
customFieldDao.create(new CustomFieldModelDao(internalCallContext.getCreatedDate(), fieldName, fieldValue, id, objectType), internalCallContext);
assertListenerStatus();
}
use of org.killbill.billing.util.customfield.dao.CustomFieldModelDao in project killbill by killbill.
the class TestAccountDao method testCustomFields.
@Test(groups = "slow", description = "Test Account DAO: custom fields")
public void testCustomFields() throws CustomFieldApiException {
final UUID accountId = UUID.randomUUID();
final String fieldName = UUID.randomUUID().toString().substring(0, 4);
final String fieldValue = UUID.randomUUID().toString();
customFieldDao.create(new CustomFieldModelDao(internalCallContext.getCreatedDate(), fieldName, fieldValue, accountId, ObjectType.ACCOUNT), internalCallContext);
final List<CustomFieldModelDao> customFieldMap = customFieldDao.getCustomFieldsForObject(accountId, ObjectType.ACCOUNT, internalCallContext);
Assert.assertEquals(customFieldMap.size(), 1);
final CustomFieldModelDao customField = customFieldMap.get(0);
Assert.assertEquals(customField.getFieldName(), fieldName);
Assert.assertEquals(customField.getFieldValue(), fieldValue);
}
Aggregations