in component-test/src/main/java/org/apache/fineract/cn/deposit/TestProductInstance.java [131:169]
public void shouldUpdateProductInstance() throws Exception {
final ProductDefinition productDefinition = Fixture.productDefinition();
super.depositAccountManager.create(productDefinition);
super.eventRecorder.wait(EventConstants.POST_PRODUCT_DEFINITION, productDefinition.getIdentifier());
final ProductInstance productInstance = Fixture.productInstance(productDefinition.getIdentifier());
super.depositAccountManager.create(productInstance);
super.eventRecorder.wait(EventConstants.POST_PRODUCT_INSTANCE, productInstance.getCustomerIdentifier());
final List<ProductInstance> productInstances =
super.depositAccountManager.findProductInstances(productDefinition.getIdentifier());
Assert.assertEquals(1, productInstances.size());
final ProductInstance fetchedProductInstance = productInstances.get(0);
final HashSet<String> newBeneficiaries = new HashSet<>(Arrays.asList("one", "two"));
fetchedProductInstance.setBeneficiaries(newBeneficiaries);
final Account account = new Account();
account.setIdentifier(fetchedProductInstance.getAccountIdentifier());
account.setName(RandomStringUtils.randomAlphanumeric(256));
account.setLedger(RandomStringUtils.randomAlphanumeric(32));
account.setBalance(0.00D);
Mockito.doAnswer(invocation -> account)
.when(super.accountingServiceSpy).findAccount(fetchedProductInstance.getAccountIdentifier());
super.depositAccountManager.changeProductInstance(fetchedProductInstance.getAccountIdentifier(),
fetchedProductInstance);
Assert.assertTrue(super.eventRecorder.wait(EventConstants.PUT_PRODUCT_INSTANCE,
fetchedProductInstance.getAccountIdentifier()));
}