in component-test/src/main/java/org/apache/fineract/cn/deposit/TestProductInstance.java [219:250]
public void shouldFindProductInstance() 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 Account account = new Account();
account.setBalance(1234.56D);
final List<ProductInstance> productInstances =
super.depositAccountManager.findProductInstances(productDefinition.getIdentifier());
Assert.assertEquals(1, productInstances.size());
final ProductInstance fetchedProductInstance = productInstances.get(0);
Mockito.doAnswer(invocation -> account)
.when(super.accountingServiceSpy).findAccount(fetchedProductInstance.getAccountIdentifier());
final ProductInstance foundProductInstance =
super.depositAccountManager.findProductInstance(fetchedProductInstance.getAccountIdentifier());
Assert.assertNotNull(foundProductInstance);
Assert.assertEquals(account.getBalance(), foundProductInstance.getBalance());
}