fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-deposit-account-management] 21/23: added test case
Date Mon, 22 Jan 2018 15:28:54 GMT
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-deposit-account-management.git

commit 223b4cfae7faabe39d3742b5cc25b96d250deefb
Author: mgeiss <mgeiss@mifos.org>
AuthorDate: Thu Jul 6 11:06:53 2017 +0200

    added test case
---
 .../io/mifos/deposit/TestProductDefinition.java    |  4 +++
 .../java/io/mifos/deposit/TestProductInstance.java | 40 ++++++++++++++++++++++
 .../listener/ProductInstanceEventListener.java     |  6 ++--
 3 files changed, 47 insertions(+), 3 deletions(-)

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 @@ public class TestProductDefinition extends AbstractDepositAccountManagementTest
     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 @@ package io.mifos.deposit;
 
 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 org.mockito.Mockito;
 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 class TestProductInstance extends AbstractDepositAccountManagementTest
{
   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 class ProductInstanceEventListener {
   )
   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 class ProductInstanceEventListener {
   )
   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 class ProductInstanceEventListener {
   )
   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);
   }
 }

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message