in component-test/src/main/java/org/apache/fineract/cn/customer/catalog/TestCatalog.java [182:212]
public void shouldSaveCustomValues() throws Exception {
final Catalog randomCatalog = CatalogGenerator.createRandomCatalog();
this.catalogManager.createCatalog(randomCatalog);
this.eventRecorder.wait(CatalogEventConstants.POST_CATALOG, randomCatalog.getIdentifier());
final Customer randomCustomer = CustomerGenerator.createRandomCustomer();
randomCustomer.setCustomValues(randomCatalog.getFields()
.stream()
.map(field -> {
final Value value = new Value();
value.setCatalogIdentifier(randomCatalog.getIdentifier());
value.setFieldIdentifier(field.getIdentifier());
switch (Field.DataType.valueOf(field.getDataType())) {
case NUMBER:
value.setValue("123.45");
break;
case SINGLE_SELECTION:
value.setValue("1");
}
return value;
})
.collect(Collectors.toList())
);
this.customerManager.createCustomer(randomCustomer);
this.eventRecorder.wait(CustomerEventConstants.POST_CUSTOMER, randomCustomer.getIdentifier());
final Customer savedCustomer = this.customerManager.findCustomer(randomCustomer.getIdentifier());
Assert.assertTrue(savedCustomer.getCustomValues().size() == 2);
}