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-customer.git

commit 5d94ca2d07324881eea0f6fc44f7c1339c6e15d7
Author: mgeiss <[email protected]>
AuthorDate: Fri Sep 8 09:34:34 2017 +0200

    renamed customer endpoit to customers
    fixed taks execution
---
 .../customer/api/v1/client/CustomerManager.java    |  6 +-
 .../java/io/mifos/customer/TestTaskInstance.java   | 73 +++++++++++++++++++++-
 .../internal/command/handler/TaskAggregate.java    |  5 +-
 .../rest/controller/CustomerRestController.java    |  6 +-
 4 files changed, 80 insertions(+), 10 deletions(-)

diff --git 
a/api/src/main/java/io/mifos/customer/api/v1/client/CustomerManager.java 
b/api/src/main/java/io/mifos/customer/api/v1/client/CustomerManager.java
index 67ef6c0..024dd2c 100644
--- a/api/src/main/java/io/mifos/customer/api/v1/client/CustomerManager.java
+++ b/api/src/main/java/io/mifos/customer/api/v1/client/CustomerManager.java
@@ -386,7 +386,7 @@ public interface CustomerManager {
   void updateTask(@PathVariable("identifier") final String identifier, 
@RequestBody final TaskDefinition taskDefinition);
 
   @RequestMapping(
-      value = "/customer/{identifier}/actions",
+      value = "/customers/{identifier}/actions",
       method = RequestMethod.GET,
       produces = MediaType.ALL_VALUE,
       consumes = MediaType.APPLICATION_JSON_VALUE
@@ -395,7 +395,7 @@ public interface CustomerManager {
   List<ProcessStep> fetchProcessSteps(@PathVariable(value = "identifier") 
final String customerIdentifier);
 
   @RequestMapping(
-      value = "/customer/{identifier}/payroll",
+      value = "/customers/{identifier}/payroll",
       method = RequestMethod.PUT,
       produces = MediaType.APPLICATION_JSON_VALUE,
       consumes = MediaType.APPLICATION_JSON_VALUE
@@ -408,7 +408,7 @@ public interface CustomerManager {
                               @RequestBody @Valid final PayrollDistribution 
payrollDistribution);
 
   @RequestMapping(
-      value = "/customer/{identifier}/payroll",
+      value = "/customers/{identifier}/payroll",
       method = RequestMethod.GET,
       produces = MediaType.ALL_VALUE,
       consumes = MediaType.APPLICATION_JSON_VALUE
diff --git 
a/component-test/src/main/java/io/mifos/customer/TestTaskInstance.java 
b/component-test/src/main/java/io/mifos/customer/TestTaskInstance.java
index a35fa97..7ff792c 100644
--- a/component-test/src/main/java/io/mifos/customer/TestTaskInstance.java
+++ b/component-test/src/main/java/io/mifos/customer/TestTaskInstance.java
@@ -19,6 +19,7 @@ import io.mifos.customer.api.v1.CustomerEventConstants;
 import io.mifos.customer.api.v1.client.TaskExecutionException;
 import io.mifos.customer.api.v1.domain.Command;
 import io.mifos.customer.api.v1.domain.Customer;
+import io.mifos.customer.api.v1.domain.IdentificationCard;
 import io.mifos.customer.api.v1.domain.TaskDefinition;
 import io.mifos.customer.util.CustomerGenerator;
 import io.mifos.customer.util.IdentificationCardGenerator;
@@ -72,8 +73,9 @@ public class TestTaskInstance extends AbstractCustomerTest {
     }
 
     // set the ID card for the customer
-    
this.customerManager.createIdentificationCard(randomCustomer.getIdentifier(), 
IdentificationCardGenerator.createRandomIdentificationCard());
-    this.eventRecorder.wait(CustomerEventConstants.POST_IDENTIFICATION_CARD, 
randomCustomer.getIdentifier());
+    final IdentificationCard randomIdentificationCard = 
IdentificationCardGenerator.createRandomIdentificationCard();
+    
this.customerManager.createIdentificationCard(randomCustomer.getIdentifier(), 
randomIdentificationCard);
+    this.eventRecorder.wait(CustomerEventConstants.POST_IDENTIFICATION_CARD, 
randomIdentificationCard.getNumber());
 
     // close the task
     
this.customerManager.taskForCustomerExecuted(randomCustomer.getIdentifier(), 
taskDefinition.getIdentifier());
@@ -120,4 +122,71 @@ public class TestTaskInstance extends AbstractCustomerTest 
{
     Assert.assertEquals(1, tasksForCustomer.size());
   }
 
+  @Test
+  public void shouldUnlockCustomerMultipleTasks() throws Exception{
+    final TaskDefinition customTask1 = new TaskDefinition();
+    customTask1.setIdentifier("custom-task-1");
+    customTask1.setType(TaskDefinition.Type.CUSTOM.name());
+    customTask1.setName("Do the barrel roll");
+    customTask1.setCommands(
+        TaskDefinition.Command.ACTIVATE.name(),
+        TaskDefinition.Command.UNLOCK.name()
+    );
+    customTask1.setPredefined(Boolean.TRUE);
+    customTask1.setMandatory(Boolean.TRUE);
+
+    this.customerManager.createTask(customTask1);
+    this.eventRecorder.wait(CustomerEventConstants.POST_TASK, 
customTask1.getIdentifier());
+
+    final TaskDefinition customTask2 = new TaskDefinition();
+    customTask2.setIdentifier("custom-task-2");
+    customTask2.setType(TaskDefinition.Type.CUSTOM.name());
+    customTask2.setName("Do the barrel roll");
+    customTask2.setCommands(
+        TaskDefinition.Command.ACTIVATE.name(),
+        TaskDefinition.Command.UNLOCK.name()
+    );
+    customTask2.setPredefined(Boolean.TRUE);
+    customTask2.setMandatory(Boolean.TRUE);
+
+    this.customerManager.createTask(customTask2);
+    this.eventRecorder.wait(CustomerEventConstants.POST_TASK, 
customTask2.getIdentifier());
+
+    // create a random customer
+    final Customer randomCustomer = CustomerGenerator.createRandomCustomer();
+    this.customerManager.createCustomer(randomCustomer);
+    this.eventRecorder.wait(CustomerEventConstants.POST_CUSTOMER, 
randomCustomer.getIdentifier());
+
+    // close the task
+    
this.customerManager.taskForCustomerExecuted(randomCustomer.getIdentifier(), 
customTask1.getIdentifier());
+    this.eventRecorder.wait(CustomerEventConstants.PUT_CUSTOMER, 
randomCustomer.getIdentifier());
+
+    
this.customerManager.taskForCustomerExecuted(randomCustomer.getIdentifier(), 
customTask2.getIdentifier());
+    this.eventRecorder.wait(CustomerEventConstants.PUT_CUSTOMER, 
randomCustomer.getIdentifier());
+
+    final Command activateCustomer = new Command();
+    activateCustomer.setAction(Command.Action.ACTIVATE.name());
+    this.customerManager.customerCommand(randomCustomer.getIdentifier(), 
activateCustomer);
+    
Assert.assertTrue(this.eventRecorder.wait(CustomerEventConstants.ACTIVATE_CUSTOMER,
 randomCustomer.getIdentifier()));
+
+    final Command lockCustomer = new Command();
+    lockCustomer.setAction(Command.Action.LOCK.name());
+    this.customerManager.customerCommand(randomCustomer.getIdentifier(), 
lockCustomer);
+    
Assert.assertTrue(this.eventRecorder.wait(CustomerEventConstants.LOCK_CUSTOMER, 
randomCustomer.getIdentifier()));
+
+    // close the task
+    
this.customerManager.taskForCustomerExecuted(randomCustomer.getIdentifier(), 
customTask1.getIdentifier());
+    this.eventRecorder.wait(CustomerEventConstants.PUT_CUSTOMER, 
randomCustomer.getIdentifier());
+
+    
this.customerManager.taskForCustomerExecuted(randomCustomer.getIdentifier(), 
customTask2.getIdentifier());
+    this.eventRecorder.wait(CustomerEventConstants.PUT_CUSTOMER, 
randomCustomer.getIdentifier());
+
+    final Command unlockCustomer = new Command();
+    unlockCustomer.setAction(Command.Action.UNLOCK.name());
+    this.customerManager.customerCommand(randomCustomer.getIdentifier(), 
unlockCustomer);
+    
Assert.assertTrue(this.eventRecorder.wait(CustomerEventConstants.UNLOCK_CUSTOMER,
 randomCustomer.getIdentifier()));
+
+    final Customer customer = 
this.customerManager.findCustomer(randomCustomer.getIdentifier());
+    Assert.assertEquals(Customer.State.ACTIVE.name(), 
customer.getCurrentState());
+  }
 }
diff --git 
a/service/src/main/java/io/mifos/customer/service/internal/command/handler/TaskAggregate.java
 
b/service/src/main/java/io/mifos/customer/service/internal/command/handler/TaskAggregate.java
index 65a03d5..5e1bac6 100644
--- 
a/service/src/main/java/io/mifos/customer/service/internal/command/handler/TaskAggregate.java
+++ 
b/service/src/main/java/io/mifos/customer/service/internal/command/handler/TaskAggregate.java
@@ -114,8 +114,9 @@ public class TaskAggregate {
       final Optional<TaskInstanceEntity> taskInstanceEntityOptional = 
taskInstanceEntities
           .stream()
           .filter(
-              taskInstanceEntity -> 
taskInstanceEntity.getTaskDefinition().getIdentifier()
-                  .equals(executeTaskForCustomerCommand.taskIdentifier()))
+              taskInstanceEntity -> 
taskInstanceEntity.getTaskDefinition().getIdentifier().equals(executeTaskForCustomerCommand.taskIdentifier())
+                  && taskInstanceEntity.getExecutedBy() == null
+          )
           .findAny();
 
       if (taskInstanceEntityOptional.isPresent()) {
diff --git 
a/service/src/main/java/io/mifos/customer/service/rest/controller/CustomerRestController.java
 
b/service/src/main/java/io/mifos/customer/service/rest/controller/CustomerRestController.java
index 401f1d9..d7ad048 100644
--- 
a/service/src/main/java/io/mifos/customer/service/rest/controller/CustomerRestController.java
+++ 
b/service/src/main/java/io/mifos/customer/service/rest/controller/CustomerRestController.java
@@ -734,7 +734,7 @@ public class CustomerRestController {
 
   @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.CUSTOMER)
   @RequestMapping(
-      value = "/customer/{identifier}/actions",
+      value = "/customers/{identifier}/actions",
       method = RequestMethod.GET,
       produces = MediaType.APPLICATION_JSON_VALUE,
       consumes = MediaType.ALL_VALUE
@@ -748,7 +748,7 @@ public class CustomerRestController {
 
   @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.CUSTOMER)
   @RequestMapping(
-      value = "customer/{identifier}/payroll",
+      value = "/customers/{identifier}/payroll",
       method = RequestMethod.PUT,
       produces = MediaType.APPLICATION_JSON_VALUE,
       consumes = MediaType.APPLICATION_JSON_VALUE
@@ -764,7 +764,7 @@ public class CustomerRestController {
 
   @Permittable(value = AcceptedTokenType.TENANT, groupId = 
PermittableGroupIds.CUSTOMER)
   @RequestMapping(
-      value = "customer/{identifier}/payroll",
+      value = "/customers/{identifier}/payroll",
       method = RequestMethod.GET,
       produces = MediaType.APPLICATION_JSON_VALUE,
       consumes = MediaType.ALL_VALUE

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to