added test case
diff --git a/component-test/src/main/java/io/mifos/deposit/TestProductDefinition.java b/component-test/src/main/java/io/mifos/deposit/TestProductDefinition.java
index b29ddf9..7125390 100644
--- a/component-test/src/main/java/io/mifos/deposit/TestProductDefinition.java
+++ b/component-test/src/main/java/io/mifos/deposit/TestProductDefinition.java
@@ -177,6 +177,10 @@
super.depositAccountManager.changeProductDefinition(newProductDefinition.getIdentifier(), newProductDefinition);
Assert.assertTrue(super.eventRecorder.wait(EventConstants.PUT_PRODUCT_DEFINITION, newProductDefinition.getIdentifier()));
+
+ final ProductDefinition fetchedProductDefinition = super.depositAccountManager.findProductDefinition(newProductDefinition.getIdentifier());
+
+ Assert.assertNotNull(fetchedProductDefinition);
}
@Test(expected = ProductDefinitionValidationException.class)
diff --git a/component-test/src/main/java/io/mifos/deposit/TestProductInstance.java b/component-test/src/main/java/io/mifos/deposit/TestProductInstance.java
index 5727908..e867830 100644
--- a/component-test/src/main/java/io/mifos/deposit/TestProductInstance.java
+++ b/component-test/src/main/java/io/mifos/deposit/TestProductInstance.java
@@ -17,6 +17,7 @@
import io.mifos.accounting.api.v1.domain.Account;
import io.mifos.deposit.api.v1.EventConstants;
+import io.mifos.deposit.api.v1.definition.domain.Charge;
import io.mifos.deposit.api.v1.definition.domain.ProductDefinition;
import io.mifos.deposit.api.v1.instance.ProductInstanceNotFoundException;
import io.mifos.deposit.api.v1.instance.ProductInstanceValidationException;
@@ -29,6 +30,7 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
+import java.util.Set;
public class TestProductInstance extends AbstractDepositAccountManagementTest {
@@ -240,4 +242,42 @@
public void shouldNotFindProductInstanceNotFound() {
super.depositAccountManager.findProductInstance(RandomStringUtils.randomAlphanumeric(32));
}
+
+ @Test
+ public void shouldOpenAccountAfterUpdatingDefinition() 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 Charge openingCharge = new Charge();
+ openingCharge.setActionIdentifier("Open");
+ openingCharge.setAmount(5.00D);
+ openingCharge.setName("Opening Account Charge");
+ openingCharge.setIncomeAccountIdentifier("10123");
+ openingCharge.setProportional(Boolean.TRUE);
+
+ productDefinition.setCharges(new HashSet<>(Arrays.asList(openingCharge)));
+
+ super.depositAccountManager.changeProductDefinition(productDefinition.getIdentifier(), productDefinition);
+
+ super.eventRecorder.wait(EventConstants.PUT_PRODUCT_DEFINITION, productDefinition.getIdentifier());
+
+ final List<ProductInstance> productInstances = super.depositAccountManager.fetchProductInstances(productInstance.getCustomerIdentifier());
+ final ProductInstance fetchedProductInstance = productInstances.get(0);
+
+ super.depositAccountManager.postProductInstanceCommand(
+ fetchedProductInstance.getAccountIdentifier(), EventConstants.ACTIVATE_PRODUCT_INSTANCE_COMMAND);
+
+ Assert.assertTrue(
+ super.eventRecorder.wait(EventConstants.ACTIVATE_PRODUCT_INSTANCE,
+ fetchedProductInstance.getAccountIdentifier()));
+ }
}
diff --git a/component-test/src/main/java/io/mifos/deposit/listener/ProductInstanceEventListener.java b/component-test/src/main/java/io/mifos/deposit/listener/ProductInstanceEventListener.java
index 9216f0a..88541a4 100644
--- a/component-test/src/main/java/io/mifos/deposit/listener/ProductInstanceEventListener.java
+++ b/component-test/src/main/java/io/mifos/deposit/listener/ProductInstanceEventListener.java
@@ -58,7 +58,7 @@
)
public void onActivateInstance(@Header(TenantHeaderFilter.TENANT_HEADER) final String tenant,
final String payload) {
- this.logger.debug("Product instance created.");
+ this.logger.debug("Product instance activated.");
this.eventRecorder.event(tenant, EventConstants.ACTIVATE_PRODUCT_INSTANCE, payload, String.class);
}
@@ -69,7 +69,7 @@
)
public void onCloseInstance(@Header(TenantHeaderFilter.TENANT_HEADER) final String tenant,
final String payload) {
- this.logger.debug("Product instance created.");
+ this.logger.debug("Product instance closed.");
this.eventRecorder.event(tenant, EventConstants.CLOSE_PRODUCT_INSTANCE, payload, String.class);
}
@@ -80,7 +80,7 @@
)
public void onUpdateInstance(@Header(TenantHeaderFilter.TENANT_HEADER) final String tenant,
final String payload) {
- this.logger.debug("Product instance created.");
+ this.logger.debug("Product instance updated.");
this.eventRecorder.event(tenant, EventConstants.PUT_PRODUCT_INSTANCE, payload, String.class);
}
}