Merge branch 'develop' of https://github.com/KuelapInc/demo-server into develop
diff --git a/build.gradle b/build.gradle
index 75e1ac8..1d5ef2a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -32,6 +32,7 @@
         mifosdeposit            : '0.1.0-BUILD-SNAPSHOT',
         mifosteller             : '0.1.0-BUILD-SNAPSHOT',
         mifosreporting          : '0.1.0-BUILD-SNAPSHOT',
+        kuelapcheques           : '0.1.0-BUILD-SNAPSHOT',
         frameworkapi            : '0.1.0-BUILD-SNAPSHOT',
         frameworklang           : '0.1.0-BUILD-SNAPSHOT',
         frameworktest           : '0.1.0-BUILD-SNAPSHOT',
@@ -86,6 +87,7 @@
             [group: 'io.mifos.deposit-account-management', name: 'api', version: versions.mifosdeposit],
             [group: 'io.mifos.teller', name: 'api', version: versions.mifosteller],
             [group: 'io.mifos.reporting', name: 'api', version: versions.mifosreporting],
+            [group: 'io.mifos.cheques', name: 'api', version: versions.kuelapcheques],
 
             [group: 'io.mifos.anubis', name: 'api', version: versions.frameworkanubis],
             [group: 'io.mifos.anubis', name: 'test', version: versions.frameworkanubis],
diff --git a/src/main/java/io/mifos/dev/ServiceRunner.java b/src/main/java/io/mifos/dev/ServiceRunner.java
index 84f4197..32a7b67 100644
--- a/src/main/java/io/mifos/dev/ServiceRunner.java
+++ b/src/main/java/io/mifos/dev/ServiceRunner.java
@@ -21,6 +21,7 @@
 import io.mifos.accounting.importer.AccountImporter;
 import io.mifos.accounting.importer.LedgerImporter;
 import io.mifos.anubis.api.v1.domain.AllowedOperation;
+import io.mifos.cheque.api.v1.client.ChequeManager;
 import io.mifos.core.api.config.EnableApiFactory;
 import io.mifos.core.api.context.AutoGuest;
 import io.mifos.core.api.context.AutoSeshat;
@@ -102,6 +103,7 @@
   private static Microservice<DepositAccountManager> depositAccountManager;
   private static Microservice<TellerManager> tellerManager;
   private static Microservice<ReportManager> reportManager;
+  private static Microservice<ChequeManager> chequeManager;
 
 
   private static DB embeddedMariaDb;
@@ -209,7 +211,8 @@
 
     ServiceRunner.portfolioManager = new Microservice<>(PortfolioManager.class, "portfolio", "0.1.0-BUILD-SNAPSHOT", ServiceRunner.INTEGRATION_TEST_ENVIRONMENT)
             .addProperties(new ExtraProperties() {{
-              setProperty("portfolio.bookLateFeesAndInterestAsUser", SCHEDULER_USER_NAME);}});
+              setProperty("portfolio.bookLateFeesAndInterestAsUser", SCHEDULER_USER_NAME);
+            }});
     startService(generalProperties, portfolioManager);
 
     ServiceRunner.depositAccountManager = new Microservice<>(DepositAccountManager.class, "deposit-account-management", "0.1.0-BUILD-SNAPSHOT", ServiceRunner.INTEGRATION_TEST_ENVIRONMENT);
@@ -220,10 +223,14 @@
 
     ServiceRunner.reportManager = new Microservice<>(ReportManager.class, "reporting", "0.1.0-BUILD-SNAPSHOT", ServiceRunner.INTEGRATION_TEST_ENVIRONMENT);
     startService(generalProperties, ServiceRunner.reportManager);
+
+    ServiceRunner.chequeManager = new Microservice<>(ChequeManager.class, "cheques", "0.1.0-BUILD-SNAPSHOT", ServiceRunner.INTEGRATION_TEST_ENVIRONMENT);
+    startService(generalProperties, ServiceRunner.chequeManager);
   }
 
   @After
   public void tearDown() throws Exception {
+    ServiceRunner.chequeManager.kill();
     ServiceRunner.reportManager.kill();
     ServiceRunner.tellerManager.kill();
     ServiceRunner.depositAccountManager.kill();
@@ -261,6 +268,7 @@
     System.out.println("Deposit Service: " + ServiceRunner.depositAccountManager.getProcessEnvironment().serverURI());
     System.out.println("Teller Service: " + ServiceRunner.tellerManager.getProcessEnvironment().serverURI());
     System.out.println("Reporting Service: " + ServiceRunner.reportManager.getProcessEnvironment().serverURI());
+    System.out.println("Cheque Service: " + ServiceRunner.chequeManager.getProcessEnvironment().serverURI());
 
     boolean run = true;
 
@@ -321,7 +329,8 @@
             ApplicationBuilder.create(ServiceRunner.portfolioManager.name(), ServiceRunner.portfolioManager.uri()),
             ApplicationBuilder.create(ServiceRunner.depositAccountManager.name(), ServiceRunner.depositAccountManager.uri()),
             ApplicationBuilder.create(ServiceRunner.tellerManager.name(), ServiceRunner.tellerManager.uri()),
-            ApplicationBuilder.create(ServiceRunner.reportManager.name(), ServiceRunner.reportManager.uri())
+            ApplicationBuilder.create(ServiceRunner.reportManager.name(), ServiceRunner.reportManager.uri()),
+            ApplicationBuilder.create(ServiceRunner.chequeManager.name(), ServiceRunner.chequeManager.uri())
     );
 
     final List<Tenant> tenantsToCreate = Arrays.asList(
@@ -420,6 +429,8 @@
 
       provisionApp(tenant, ServiceRunner.reportManager, io.mifos.reporting.api.v1.EventConstants.INITIALIZE);
 
+      provisionApp(tenant, ServiceRunner.chequeManager, io.mifos.cheque.api.v1.EventConstants.INITIALIZE);
+
       final UserWithPassword orgAdminUserPassword = createOrgAdminRoleAndUser(tenantAdminPassword.getAdminPassword());
 
       createChartOfAccounts(orgAdminUserPassword);
diff --git a/src/main/java/io/mifos/dev/listener/ChequesListener.java b/src/main/java/io/mifos/dev/listener/ChequesListener.java
new file mode 100644
index 0000000..908454b
--- /dev/null
+++ b/src/main/java/io/mifos/dev/listener/ChequesListener.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2016 The Mifos Initiative.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.mifos.dev.listener;
+
+import io.mifos.cheque.api.v1.EventConstants;
+import io.mifos.core.lang.config.TenantHeaderFilter;
+import io.mifos.core.test.listener.EventRecorder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.annotation.JmsListener;
+import org.springframework.messaging.handler.annotation.Header;
+import org.springframework.stereotype.Component;
+
+@SuppressWarnings("unused")
+@Component
+public class ChequesListener {
+
+  private final EventRecorder eventRecorder;
+
+  @Autowired
+  public ChequesListener(final EventRecorder eventRecorder) {
+    this.eventRecorder = eventRecorder;
+  }
+
+  @JmsListener(
+          subscription = EventConstants.DESTINATION,
+          destination = EventConstants.DESTINATION,
+          selector = EventConstants.SELECTOR_INITIALIZE
+  )
+  public void onInitialized(@Header(TenantHeaderFilter.TENANT_HEADER) final String tenant,
+                            final String payload) {
+    this.eventRecorder.event(tenant, EventConstants.INITIALIZE, payload, String.class);
+  }
+}
+