From e94c0e35a279ad01669f20a3018f8cc81932aa34 Mon Sep 17 00:00:00 2001 From: Isaac Kamga Date: Mon, 11 Jun 2018 02:26:48 +0100 Subject: [PATCH] Revert "Document the payroll API" --- service/build.gradle | 20 - service/src/doc/asciidoc/api-docs.adoc | 31 -- .../curl-request.adoc | 4 - .../http-request.adoc | 10 - .../http-response.adoc | 5 - .../httpie-request.adoc | 4 - .../curl-request.adoc | 4 - .../http-request.adoc | 8 - .../http-response.adoc | 5 - .../httpie-request.adoc | 4 - service/src/doc/html5/html5/api-docs.html | 508 ------------------ .../cn/payroll/AbstractPayrollTest.java | 114 ---- .../cn/payroll/SuiteTestEnvironment.java | 48 -- .../cn/payroll/TestPayrollConfiguration.java | 172 ------ .../cn/payroll/TestPayrollDistribution.java | 198 ------- .../apache/fineract/cn/payroll/TestSuite.java | 30 -- .../payroll/domain/DomainObjectGenerator.java | 49 -- .../listener/MigrationEventListener.java | 50 -- .../PayrollConfigurationListener.java | 56 -- .../listener/PayrollDistributionListener.java | 56 -- 20 files changed, 1376 deletions(-) delete mode 100644 service/src/doc/asciidoc/api-docs.adoc delete mode 100644 service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/curl-request.adoc delete mode 100644 service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/http-request.adoc delete mode 100644 service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/http-response.adoc delete mode 100644 service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/httpie-request.adoc delete mode 100644 service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/curl-request.adoc delete mode 100644 service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/http-request.adoc delete mode 100644 service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/http-response.adoc delete mode 100644 service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/httpie-request.adoc delete mode 100644 service/src/doc/html5/html5/api-docs.html delete mode 100644 service/src/test/java/org/apache/fineract/cn/payroll/AbstractPayrollTest.java delete mode 100644 service/src/test/java/org/apache/fineract/cn/payroll/SuiteTestEnvironment.java delete mode 100644 service/src/test/java/org/apache/fineract/cn/payroll/TestPayrollConfiguration.java delete mode 100644 service/src/test/java/org/apache/fineract/cn/payroll/TestPayrollDistribution.java delete mode 100644 service/src/test/java/org/apache/fineract/cn/payroll/TestSuite.java delete mode 100644 service/src/test/java/org/apache/fineract/cn/payroll/domain/DomainObjectGenerator.java delete mode 100644 service/src/test/java/org/apache/fineract/cn/payroll/listener/MigrationEventListener.java delete mode 100644 service/src/test/java/org/apache/fineract/cn/payroll/listener/PayrollConfigurationListener.java delete mode 100644 service/src/test/java/org/apache/fineract/cn/payroll/listener/PayrollDistributionListener.java diff --git a/service/build.gradle b/service/build.gradle index 79f2200..b7d4e95 100644 --- a/service/build.gradle +++ b/service/build.gradle @@ -26,7 +26,6 @@ buildscript { dependencies { classpath ("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") - classpath("org.asciidoctor:asciidoctor-gradle-plugin:1.5.3") } } @@ -37,7 +36,6 @@ plugins { apply from: '../shared.gradle' -apply plugin: 'org.asciidoctor.convert' apply plugin: 'spring-boot' springBoot { @@ -62,24 +60,6 @@ dependencies { [group: 'org.apache.fineract.cn', name: 'command', version: versions.frameworkcommand], [group: 'org.hibernate', name: 'hibernate-validator', version: versions.validator] ) - testCompile( - [group: 'org.apache.fineract.cn.payroll', name: 'api', version: project.version], - [group: 'org.apache.fineract.cn.anubis', name: 'test', version: versions.frameworkanubis], - [group: 'org.apache.fineract.cn', name: 'api', version: versions.frameworkapi], - [group: 'org.apache.fineract.cn', name: 'test', version: versions.frameworktest], - [group: 'org.apache.fineract.cn', name: 'lang', version: versions.frameworklang], - [group: 'org.springframework.boot', name: 'spring-boot-starter-test'], - [group: 'org.springframework.restdocs', name: 'spring-restdocs-mockmvc'], - [group: 'junit', name: 'junit', version: '4.12'] - ) -} - -asciidoctor { - sourceDir 'src/doc/asciidoc/' - outputDir 'src/doc/html5' - options backend: "html", doctype: "book" - attributes "source-highlighter": "highlightjs", \ - 'snippets': file('src/doc/generated-snippets/') } publishToMavenLocal.dependsOn bootRepackage diff --git a/service/src/doc/asciidoc/api-docs.adoc b/service/src/doc/asciidoc/api-docs.adoc deleted file mode 100644 index 8ab3b68..0000000 --- a/service/src/doc/asciidoc/api-docs.adoc +++ /dev/null @@ -1,31 +0,0 @@ -== Apache Fineract CN Payroll Management API Documentation == - -== Payroll Configurations == - -==== Configure Payroll Distribution ==== - -.curl-request -include::{snippets}/test-configurations/should-create-payroll-distribution/curl-request.adoc[] - -.http-request -include::{snippets}/test-configurations/should-create-payroll-distribution/http-request.adoc[] - -.http-response -include::{snippets}/test-configurations/should-create-payroll-distribution/http-response.adoc[] - -.httpie-request -include::{snippets}/test-configurations/should-create-payroll-distribution/httpie-request.adoc[] - -==== Update Payroll Distribution ==== - -.curl-request -include::{snippets}/test-configurations/should-update-payroll-distribution/curl-request.adoc[] - -.http-request -include::{snippets}/test-configurations/should-update-payroll-distribution/http-request.adoc[] - -.http-response -include::{snippets}/test-configurations/should-update-payroll-distribution/http-response.adoc[] - -.httpie-request -include::{snippets}/test-configurations/should-update-payroll-distribution/httpie-request.adoc[] \ No newline at end of file diff --git a/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/curl-request.adoc b/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/curl-request.adoc deleted file mode 100644 index 369d46e..0000000 --- a/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/curl-request.adoc +++ /dev/null @@ -1,4 +0,0 @@ -[source,bash] ----- -$ curl 'http://localhost:8080/payroll/v1/customers/wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3/payroll' -i -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d 'wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3' ----- \ No newline at end of file diff --git a/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/http-request.adoc b/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/http-request.adoc deleted file mode 100644 index 973bc8e..0000000 --- a/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/http-request.adoc +++ /dev/null @@ -1,10 +0,0 @@ -[source,http,options="nowrap"] ----- -POST /payroll/v1/customers/wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3/payroll HTTP/1.1 -Accept: application/json -Content-Type: application/json -Host: localhost:8080 -Content-Length: 32 - -wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3 ----- \ No newline at end of file diff --git a/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/http-response.adoc b/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/http-response.adoc deleted file mode 100644 index f3b256d..0000000 --- a/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/http-response.adoc +++ /dev/null @@ -1,5 +0,0 @@ -[source,http,options="nowrap"] ----- -HTTP/1.1 404 Not Found - ----- \ No newline at end of file diff --git a/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/httpie-request.adoc b/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/httpie-request.adoc deleted file mode 100644 index 58f2cf5..0000000 --- a/service/src/doc/generated-snippets/test-configurations/should-create-payroll-distribution/httpie-request.adoc +++ /dev/null @@ -1,4 +0,0 @@ -[source,bash] ----- -$ echo 'wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3' | http POST 'http://localhost:8080/payroll/v1/customers/wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3/payroll' 'Accept:application/json' 'Content-Type:application/json' ----- \ No newline at end of file diff --git a/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/curl-request.adoc b/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/curl-request.adoc deleted file mode 100644 index cf59595..0000000 --- a/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/curl-request.adoc +++ /dev/null @@ -1,4 +0,0 @@ -[source,bash] ----- -$ curl 'http://localhost:8080/payroll/v1/customers/WhfpMOMifcLw4XIoImryT51O75wTyfVa/payroll/org.apache.fineract.cn.payroll.api.v1.domain.PayrollConfiguration@42c661d4' -i -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' ----- \ No newline at end of file diff --git a/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/http-request.adoc b/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/http-request.adoc deleted file mode 100644 index da20ea8..0000000 --- a/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/http-request.adoc +++ /dev/null @@ -1,8 +0,0 @@ -[source,http,options="nowrap"] ----- -PUT /payroll/v1/customers/WhfpMOMifcLw4XIoImryT51O75wTyfVa/payroll/org.apache.fineract.cn.payroll.api.v1.domain.PayrollConfiguration@42c661d4 HTTP/1.1 -Accept: application/json -Content-Type: application/json -Host: localhost:8080 - ----- \ No newline at end of file diff --git a/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/http-response.adoc b/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/http-response.adoc deleted file mode 100644 index f3b256d..0000000 --- a/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/http-response.adoc +++ /dev/null @@ -1,5 +0,0 @@ -[source,http,options="nowrap"] ----- -HTTP/1.1 404 Not Found - ----- \ No newline at end of file diff --git a/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/httpie-request.adoc b/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/httpie-request.adoc deleted file mode 100644 index 352b69e..0000000 --- a/service/src/doc/generated-snippets/test-configurations/should-update-payroll-distribution/httpie-request.adoc +++ /dev/null @@ -1,4 +0,0 @@ -[source,bash] ----- -$ http PUT 'http://localhost:8080/payroll/v1/customers/WhfpMOMifcLw4XIoImryT51O75wTyfVa/payroll/org.apache.fineract.cn.payroll.api.v1.domain.PayrollConfiguration@42c661d4' 'Accept:application/json' 'Content-Type:application/json' ----- \ No newline at end of file diff --git a/service/src/doc/html5/html5/api-docs.html b/service/src/doc/html5/html5/api-docs.html deleted file mode 100644 index 105514b..0000000 --- a/service/src/doc/html5/html5/api-docs.html +++ /dev/null @@ -1,508 +0,0 @@ - - - - - - - -Apache Fineract CN Payroll Management API Documentation - - - - - -
-
-

Apache Fineract CN Payroll Management API Documentation

-
- -
-
-
-

Payroll Configurations

-
-
-

Configure Payroll Distribution

-
-
curl-request
-
-
$ curl 'http://localhost:8080/payroll/v1/customers/wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3/payroll' -i -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d 'wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3'
-
-
-
-
http-request
-
-
POST /payroll/v1/customers/wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3/payroll HTTP/1.1
-Accept: application/json
-Content-Type: application/json
-Host: localhost:8080
-Content-Length: 32
-
-wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3
-
-
-
-
http-response
-
-
HTTP/1.1 404 Not Found
-
-
-
-
httpie-request
-
-
$ echo 'wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3' | http POST 'http://localhost:8080/payroll/v1/customers/wwiP1hjgY4urDKHZZmE7K7Pbwr5OV9J3/payroll' 'Accept:application/json' 'Content-Type:application/json'
-
-
-
-
-

Update Payroll Distribution

-
-
curl-request
-
-
$ curl 'http://localhost:8080/payroll/v1/customers/WhfpMOMifcLw4XIoImryT51O75wTyfVa/payroll/org.apache.fineract.cn.payroll.api.v1.domain.PayrollConfiguration@42c661d4' -i -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json'
-
-
-
-
http-request
-
-
PUT /payroll/v1/customers/WhfpMOMifcLw4XIoImryT51O75wTyfVa/payroll/org.apache.fineract.cn.payroll.api.v1.domain.PayrollConfiguration@42c661d4 HTTP/1.1
-Accept: application/json
-Content-Type: application/json
-Host: localhost:8080
-
-
-
-
http-response
-
-
HTTP/1.1 404 Not Found
-
-
-
-
httpie-request
-
-
$ http PUT 'http://localhost:8080/payroll/v1/customers/WhfpMOMifcLw4XIoImryT51O75wTyfVa/payroll/org.apache.fineract.cn.payroll.api.v1.domain.PayrollConfiguration@42c661d4' 'Accept:application/json' 'Content-Type:application/json'
-
-
-
-
-
-
- - - - - - \ No newline at end of file diff --git a/service/src/test/java/org/apache/fineract/cn/payroll/AbstractPayrollTest.java b/service/src/test/java/org/apache/fineract/cn/payroll/AbstractPayrollTest.java deleted file mode 100644 index 5aca3d0..0000000 --- a/service/src/test/java/org/apache/fineract/cn/payroll/AbstractPayrollTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.fineract.cn.payroll; - - -import org.apache.fineract.cn.anubis.test.v1.TenantApplicationSecurityEnvironmentTestRule; -import org.apache.fineract.cn.api.context.AutoUserContext; -import org.apache.fineract.cn.payroll.api.v1.EventConstants; -import org.apache.fineract.cn.payroll.api.v1.client.PayrollManager; -import org.apache.fineract.cn.payroll.service.PayrollServiceConfiguration; -import org.apache.fineract.cn.test.fixture.TenantDataStoreContextTestRule; -import org.apache.fineract.cn.test.listener.EnableEventRecording; -import org.apache.fineract.cn.test.listener.EventRecorder; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.netflix.feign.EnableFeignClients; -import org.springframework.cloud.netflix.ribbon.RibbonClient; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest( - webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, - classes = { - AbstractPayrollTest.TestConfiguration.class - } -) -public class AbstractPayrollTest extends SuiteTestEnvironment { - - @Configuration - @EnableEventRecording - @EnableFeignClients(basePackages = { - "org.apache.fineract.cn.payroll.api.v1.client" - }) - @RibbonClient(name = SuiteTestEnvironment.APP_NAME) - @ComponentScan( - basePackages = { - "org.apache.fineract.cn.payroll.listener" - } - ) - @Import({ - PayrollServiceConfiguration.class - }) - public static class TestConfiguration { - public TestConfiguration() { - super(); - } - } - - static final String TEST_USER = "mage"; - - @ClassRule - public final static TenantDataStoreContextTestRule tenantDataStoreContext = - TenantDataStoreContextTestRule.forRandomTenantName(SuiteTestEnvironment.cassandraInitializer, - SuiteTestEnvironment.mariaDBInitializer); - - @Rule - public final TenantApplicationSecurityEnvironmentTestRule tenantApplicationSecurityEnvironment - = new TenantApplicationSecurityEnvironmentTestRule(SuiteTestEnvironment.testEnvironment, this::waitForInitialize); - - @Autowired - EventRecorder eventRecorder; - - private AutoUserContext userContext; - - @Autowired - PayrollManager testSubject; - - public AbstractPayrollTest() { - super(); - } - - @Before - public void prepareTest() { - this.userContext = this.tenantApplicationSecurityEnvironment.createAutoUserContext(AbstractPayrollTest.TEST_USER); - } - - @After - public void cleanupTest() { - userContext.close(); - } - - public boolean waitForInitialize() { - try { - return this.eventRecorder.wait(EventConstants.INITIALIZE, SuiteTestEnvironment.APP_VERSION); - } catch (final InterruptedException e) { - throw new IllegalStateException(e); - } - } - -} diff --git a/service/src/test/java/org/apache/fineract/cn/payroll/SuiteTestEnvironment.java b/service/src/test/java/org/apache/fineract/cn/payroll/SuiteTestEnvironment.java deleted file mode 100644 index ebe1880..0000000 --- a/service/src/test/java/org/apache/fineract/cn/payroll/SuiteTestEnvironment.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.fineract.cn.payroll; - -import org.apache.fineract.cn.test.env.TestEnvironment; -import org.apache.fineract.cn.test.fixture.cassandra.CassandraInitializer; -import org.apache.fineract.cn.test.fixture.mariadb.MariaDBInitializer; -import org.junit.ClassRule; -import org.junit.rules.RuleChain; -import org.junit.rules.RunExternalResourceOnce; -import org.junit.rules.TestRule; - -/** - * This contains the database resources required by the test. They are in a separate - * class so that the test suite can initialize them before the classes it calls. This - * makes test runs faster and prevents tests from "stepping on each other's toes" when - * initializing and de-initializing external resources. - */ -public class SuiteTestEnvironment { - static final String APP_VERSION = "1"; - static final String APP_NAME = "payroll-v" + APP_VERSION; - - static final TestEnvironment testEnvironment = new TestEnvironment(APP_NAME); - static final CassandraInitializer cassandraInitializer = new CassandraInitializer(); - static final MariaDBInitializer mariaDBInitializer = new MariaDBInitializer(); - - @ClassRule - public static TestRule orderClassRules = RuleChain - .outerRule(new RunExternalResourceOnce(testEnvironment)) - .around(new RunExternalResourceOnce(cassandraInitializer)) - .around(new RunExternalResourceOnce(mariaDBInitializer)); -} diff --git a/service/src/test/java/org/apache/fineract/cn/payroll/TestPayrollConfiguration.java b/service/src/test/java/org/apache/fineract/cn/payroll/TestPayrollConfiguration.java deleted file mode 100644 index d5e41d6..0000000 --- a/service/src/test/java/org/apache/fineract/cn/payroll/TestPayrollConfiguration.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.fineract.cn.payroll; - -import com.google.common.collect.Lists; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.fineract.cn.accounting.api.v1.domain.Account; -import org.apache.fineract.cn.customer.api.v1.domain.Customer; -import org.apache.fineract.cn.payroll.api.v1.EventConstants; -import org.apache.fineract.cn.payroll.api.v1.domain.PayrollAllocation; -import org.apache.fineract.cn.payroll.api.v1.domain.PayrollConfiguration; -import org.apache.fineract.cn.payroll.domain.DomainObjectGenerator; -import org.apache.fineract.cn.payroll.service.internal.service.adaptor.AccountingAdaptor; -import org.apache.fineract.cn.payroll.service.internal.service.adaptor.CustomerAdaptor; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.MediaType; -import org.springframework.restdocs.JUnitRestDocumentation; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; - -import java.math.BigDecimal; -import java.util.Optional; - -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -public class TestPayrollConfiguration extends AbstractPayrollTest { - - @Rule - public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("src/doc/generated-snippets/test-configurations"); - - @Autowired - private WebApplicationContext context; - - private MockMvc mockMvc; - - final String path = "/payroll/v1"; - - @Before - public void setUp(){ - - this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(documentationConfiguration(this.restDocumentation)) - .alwaysDo(document("{method-name}", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()))) - .build(); - } - - @MockBean - private CustomerAdaptor customerAdaptorSpy; - @MockBean - private AccountingAdaptor accountingAdaptorSpy; - - public TestPayrollConfiguration() { - super(); - } - - @Test - public void shouldCreatePayrollDistribution() throws Exception { - final String customerIdentifier = RandomStringUtils.randomAlphanumeric(32); - final PayrollConfiguration payrollConfiguration = DomainObjectGenerator.getPayrollConfiguration(); - this.prepareMocks(customerIdentifier, payrollConfiguration); - - super.testSubject.setPayrollConfiguration(customerIdentifier, payrollConfiguration); - Assert.assertTrue(super.eventRecorder.wait(EventConstants.PUT_CONFIGURATION, customerIdentifier)); - - try { - this.mockMvc.perform(post(path + "/customers/" + customerIdentifier + "/payroll") - .accept(MediaType.APPLICATION_JSON_VALUE) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .content(customerIdentifier)) - .andExpect(status().isNotFound()); - } catch (Exception e) { e.printStackTrace(); } - } - - @Test - public void shouldUpdatePayrollDistribution() throws Exception { - final String customerIdentifier = RandomStringUtils.randomAlphanumeric(32); - final PayrollConfiguration payrollConfiguration = DomainObjectGenerator.getPayrollConfiguration(); - this.prepareMocks(customerIdentifier, payrollConfiguration); - - super.testSubject.setPayrollConfiguration(customerIdentifier, payrollConfiguration); - Assert.assertTrue(super.eventRecorder.wait(EventConstants.PUT_CONFIGURATION, customerIdentifier)); - - final PayrollAllocation newPayrollAllocation = new PayrollAllocation(); - payrollConfiguration.setPayrollAllocations(Lists.newArrayList(newPayrollAllocation)); - newPayrollAllocation.setAccountNumber(RandomStringUtils.randomAlphanumeric(34)); - newPayrollAllocation.setAmount(BigDecimal.valueOf(15.00D)); - newPayrollAllocation.setProportional(Boolean.FALSE); - - Mockito - .doAnswer(invocation -> Optional.of(new Account())) - .when(this.accountingAdaptorSpy).findAccount(Matchers.eq(newPayrollAllocation.getAccountNumber())); - - super.testSubject.setPayrollConfiguration(customerIdentifier, payrollConfiguration); - Assert.assertTrue(super.eventRecorder.wait(EventConstants.PUT_CONFIGURATION, customerIdentifier)); - - Thread.sleep(500L); - - final PayrollConfiguration fetchedPayrollConfiguration = - super.testSubject.findPayrollConfiguration(customerIdentifier); - - Assert.assertNotNull(fetchedPayrollConfiguration.getLastModifiedBy()); - Assert.assertNotNull(fetchedPayrollConfiguration.getLastModifiedOn()); - Assert.assertEquals(1, fetchedPayrollConfiguration.getPayrollAllocations().size()); - - final Optional optionalPayrollAllocation = - fetchedPayrollConfiguration.getPayrollAllocations().stream().findFirst(); - - Assert.assertTrue(optionalPayrollAllocation.isPresent()); - - this.comparePayrollAllocations(newPayrollAllocation, optionalPayrollAllocation.get()); - - try { - this.mockMvc.perform(put(path + "/customers/" + customerIdentifier + "/payroll/" + payrollConfiguration.toString()) - .accept(MediaType.APPLICATION_JSON_VALUE) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().is4xxClientError()); - } catch ( Exception E) { E.printStackTrace(); } - } - - private void prepareMocks(final String customerIdentifier, final PayrollConfiguration payrollConfiguration) { - Mockito - .doAnswer(invocation -> Optional.of(new Customer())) - .when(this.customerAdaptorSpy).findCustomer(Matchers.eq(customerIdentifier)); - - Mockito - .doAnswer(invocation -> Optional.of(new Account())) - .when(this.accountingAdaptorSpy).findAccount(Matchers.eq(payrollConfiguration.getMainAccountNumber())); - - payrollConfiguration.getPayrollAllocations().forEach(payrollAllocation -> - Mockito - .doAnswer(invocation -> Optional.of(new Account())) - .when(this.accountingAdaptorSpy).findAccount(Matchers.eq(payrollAllocation.getAccountNumber())) - ); - } - - private void comparePayrollAllocations(final PayrollAllocation expected, final PayrollAllocation actual) { - Assert.assertEquals(expected.getAccountNumber(), actual.getAccountNumber()); - Assert.assertTrue(expected.getAmount().compareTo(actual.getAmount()) == 0); - Assert.assertEquals(expected.getProportional(), actual.getProportional()); - } -} diff --git a/service/src/test/java/org/apache/fineract/cn/payroll/TestPayrollDistribution.java b/service/src/test/java/org/apache/fineract/cn/payroll/TestPayrollDistribution.java deleted file mode 100644 index 68c2991..0000000 --- a/service/src/test/java/org/apache/fineract/cn/payroll/TestPayrollDistribution.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.fineract.cn.payroll; - -import com.google.common.collect.Lists; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.fineract.cn.accounting.api.v1.domain.Account; -import org.apache.fineract.cn.customer.api.v1.domain.Customer; -import org.apache.fineract.cn.payroll.api.v1.EventConstants; -import org.apache.fineract.cn.payroll.api.v1.client.PayrollPaymentValidationException; -import org.apache.fineract.cn.payroll.api.v1.domain.*; -import org.apache.fineract.cn.payroll.domain.DomainObjectGenerator; -import org.apache.fineract.cn.payroll.service.internal.repository.PayrollCollectionEntity; -import org.apache.fineract.cn.payroll.service.internal.service.adaptor.AccountingAdaptor; -import org.apache.fineract.cn.payroll.service.internal.service.adaptor.CustomerAdaptor; -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mockito; -import org.springframework.boot.test.mock.mockito.MockBean; - -import java.math.BigDecimal; -import java.util.List; -import java.util.Optional; - -public class TestPayrollDistribution extends AbstractPayrollTest { - - @MockBean - private CustomerAdaptor customerAdaptorSpy; - @MockBean - private AccountingAdaptor accountingAdaptorSpy; - - public TestPayrollDistribution() { - super(); - } - - @Test - public void shouldDistributePayments() throws Exception { - final String customerIdentifier = RandomStringUtils.randomAlphanumeric(32); - final PayrollConfiguration payrollConfiguration = DomainObjectGenerator.getPayrollConfiguration(); - this.prepareMocks(customerIdentifier, payrollConfiguration); - - super.testSubject.setPayrollConfiguration(customerIdentifier, payrollConfiguration); - Assert.assertTrue(super.eventRecorder.wait(EventConstants.PUT_CONFIGURATION, customerIdentifier)); - - final PayrollCollectionSheet payrollCollectionSheet = new PayrollCollectionSheet(); - payrollCollectionSheet.setSourceAccountNumber(RandomStringUtils.randomAlphanumeric(34)); - final PayrollPayment payrollPayment = new PayrollPayment(); - payrollPayment.setCustomerIdentifier(customerIdentifier); - payrollPayment.setEmployer("ACME, Inc."); - payrollPayment.setSalary(BigDecimal.valueOf(1234.56D)); - payrollCollectionSheet.setPayrollPayments(Lists.newArrayList(payrollPayment)); - - final Account sourceAccount = new Account(); - sourceAccount.setState(Account.State.OPEN.name()); - Mockito - .doAnswer(invocation -> Optional.of(sourceAccount)) - .when(this.accountingAdaptorSpy).findAccount(Matchers.eq(payrollCollectionSheet.getSourceAccountNumber())); - - Mockito - .doAnswer(invocation -> Optional.empty()) - .when(this.accountingAdaptorSpy).postPayrollPayment( - Matchers.any(PayrollCollectionEntity.class), - Matchers.refEq(payrollPayment), - Matchers.any(PayrollConfiguration.class) - ); - - super.testSubject.distribute(payrollCollectionSheet); - Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_DISTRIBUTION, payrollCollectionSheet.getSourceAccountNumber())); - - final List payrollCollectionHistories = super.testSubject.fetchDistributionHistory(); - Assert.assertEquals(1, payrollCollectionHistories.size()); - - final PayrollCollectionHistory payrollCollectionHistory = payrollCollectionHistories.get(0); - final PayrollPaymentPage payrollPaymentPage = - super.testSubject.fetchPayments(payrollCollectionHistory.getIdentifier(), 0, 10, null, null); - Assert.assertEquals(Long.valueOf(1L), payrollPaymentPage.getTotalElements()); - - final PayrollPayment fetchedPayrollPayment = payrollPaymentPage.getPayrollPayments().get(0); - Assert.assertTrue(fetchedPayrollPayment.getProcessed()); - } - - @Test(expected = PayrollPaymentValidationException.class) - public void shouldNotDistributePaymentsAllocatedAccountClosed() throws Exception { - final String customerIdentifier = RandomStringUtils.randomAlphanumeric(32); - final PayrollConfiguration payrollConfiguration = DomainObjectGenerator.getPayrollConfiguration(); - this.prepareMocks(customerIdentifier, payrollConfiguration); - - final PayrollAllocation invalidPayrollAllocation = new PayrollAllocation(); - invalidPayrollAllocation.setAccountNumber(RandomStringUtils.randomAlphanumeric(34)); - invalidPayrollAllocation.setProportional(Boolean.FALSE); - invalidPayrollAllocation.setAmount(BigDecimal.valueOf(200.00D)); - payrollConfiguration.getPayrollAllocations().add(invalidPayrollAllocation); - - final Account invalidPayrollAccount = new Account(); - invalidPayrollAccount.setState(Account.State.CLOSED.name()); - Mockito - .doAnswer(invocation -> Optional.of(invalidPayrollAccount)) - .when(this.accountingAdaptorSpy).findAccount(Matchers.eq(invalidPayrollAllocation.getAccountNumber())); - - super.testSubject.setPayrollConfiguration(customerIdentifier, payrollConfiguration); - Assert.assertTrue(super.eventRecorder.wait(EventConstants.PUT_CONFIGURATION, customerIdentifier)); - - final PayrollCollectionSheet payrollCollectionSheet = new PayrollCollectionSheet(); - payrollCollectionSheet.setSourceAccountNumber(RandomStringUtils.randomAlphanumeric(34)); - final PayrollPayment payrollPayment = new PayrollPayment(); - payrollPayment.setCustomerIdentifier(customerIdentifier); - payrollPayment.setEmployer("ACME, Inc."); - payrollPayment.setSalary(BigDecimal.valueOf(1234.56D)); - payrollCollectionSheet.setPayrollPayments(Lists.newArrayList(payrollPayment)); - - final Account sourceAccount = new Account(); - sourceAccount.setState(Account.State.OPEN.name()); - Mockito - .doAnswer(invocation -> Optional.of(sourceAccount)) - .when(this.accountingAdaptorSpy).findAccount(Matchers.eq(payrollCollectionSheet.getSourceAccountNumber())); - - Mockito - .doAnswer(invocation -> Optional.empty()) - .when(this.accountingAdaptorSpy).postPayrollPayment( - Matchers.any(PayrollCollectionEntity.class), - Matchers.refEq(payrollPayment), - Matchers.any(PayrollConfiguration.class) - ); - - super.testSubject.distribute(payrollCollectionSheet); - } - - @Test(expected = PayrollPaymentValidationException.class) - public void shouldNotDistributePaymentsSourceAccountClosed() throws Exception { - final String customerIdentifier = RandomStringUtils.randomAlphanumeric(32); - final PayrollConfiguration payrollConfiguration = DomainObjectGenerator.getPayrollConfiguration(); - this.prepareMocks(customerIdentifier, payrollConfiguration); - - super.testSubject.setPayrollConfiguration(customerIdentifier, payrollConfiguration); - Assert.assertTrue(super.eventRecorder.wait(EventConstants.PUT_CONFIGURATION, customerIdentifier)); - - final PayrollCollectionSheet payrollCollectionSheet = new PayrollCollectionSheet(); - payrollCollectionSheet.setSourceAccountNumber(RandomStringUtils.randomAlphanumeric(34)); - final PayrollPayment payrollPayment = new PayrollPayment(); - payrollPayment.setCustomerIdentifier(customerIdentifier); - payrollPayment.setEmployer("ACME, Inc."); - payrollPayment.setSalary(BigDecimal.valueOf(1234.56D)); - payrollCollectionSheet.setPayrollPayments(Lists.newArrayList(payrollPayment)); - - final Account sourceAccount = new Account(); - sourceAccount.setState(Account.State.CLOSED.name()); - Mockito - .doAnswer(invocation -> Optional.of(sourceAccount)) - .when(this.accountingAdaptorSpy).findAccount(Matchers.eq(payrollCollectionSheet.getSourceAccountNumber())); - - Mockito - .doAnswer(invocation -> Optional.empty()) - .when(this.accountingAdaptorSpy).postPayrollPayment( - Matchers.any(PayrollCollectionEntity.class), - Matchers.refEq(payrollPayment), - Matchers.any(PayrollConfiguration.class) - ); - - super.testSubject.distribute(payrollCollectionSheet); - } - - private void prepareMocks(final String customerIdentifier, final PayrollConfiguration payrollConfiguration) { - Mockito - .doAnswer(invocation -> Optional.of(new Customer())) - .when(this.customerAdaptorSpy).findCustomer(Matchers.eq(customerIdentifier)); - - final Account mainAccount = new Account(); - mainAccount.setState(Account.State.OPEN.name()); - Mockito - .doAnswer(invocation -> Optional.of(mainAccount)) - .when(this.accountingAdaptorSpy).findAccount(Matchers.eq(payrollConfiguration.getMainAccountNumber())); - - payrollConfiguration.getPayrollAllocations().forEach(payrollAllocation -> { - final Account allocatedAccount = new Account(); - allocatedAccount.setState(Account.State.OPEN.name()); - Mockito - .doAnswer(invocation -> Optional.of(allocatedAccount)) - .when(this.accountingAdaptorSpy).findAccount(Matchers.eq(payrollAllocation.getAccountNumber())); - }); - } -} diff --git a/service/src/test/java/org/apache/fineract/cn/payroll/TestSuite.java b/service/src/test/java/org/apache/fineract/cn/payroll/TestSuite.java deleted file mode 100644 index 5fe0817..0000000 --- a/service/src/test/java/org/apache/fineract/cn/payroll/TestSuite.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.fineract.cn.payroll; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses({ - TestPayrollConfiguration.class, - TestPayrollDistribution.class -}) -public class TestSuite extends SuiteTestEnvironment { -} diff --git a/service/src/test/java/org/apache/fineract/cn/payroll/domain/DomainObjectGenerator.java b/service/src/test/java/org/apache/fineract/cn/payroll/domain/DomainObjectGenerator.java deleted file mode 100644 index dc3dbfe..0000000 --- a/service/src/test/java/org/apache/fineract/cn/payroll/domain/DomainObjectGenerator.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.fineract.cn.payroll.domain; - -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.fineract.cn.payroll.api.v1.domain.PayrollAllocation; -import org.apache.fineract.cn.payroll.api.v1.domain.PayrollConfiguration; - -import java.math.BigDecimal; -import java.util.ArrayList; - -public class DomainObjectGenerator { - - private DomainObjectGenerator() { - super(); - } - - public static PayrollConfiguration getPayrollConfiguration() { - final PayrollConfiguration payrollConfiguration = new PayrollConfiguration(); - payrollConfiguration.setMainAccountNumber(RandomStringUtils.randomAlphanumeric(34)); - - final ArrayList payrollAllocations = new ArrayList<>(); - payrollConfiguration.setPayrollAllocations(payrollAllocations); - - final PayrollAllocation savingsAllocation = new PayrollAllocation(); - payrollAllocations.add(savingsAllocation); - savingsAllocation.setAccountNumber(RandomStringUtils.randomAlphanumeric(34)); - savingsAllocation.setAmount(BigDecimal.valueOf(5.00D)); - savingsAllocation.setProportional(Boolean.TRUE); - - return payrollConfiguration; - } -} diff --git a/service/src/test/java/org/apache/fineract/cn/payroll/listener/MigrationEventListener.java b/service/src/test/java/org/apache/fineract/cn/payroll/listener/MigrationEventListener.java deleted file mode 100644 index fc5867b..0000000 --- a/service/src/test/java/org/apache/fineract/cn/payroll/listener/MigrationEventListener.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.fineract.cn.payroll.listener; - -import org.apache.fineract.cn.lang.config.TenantHeaderFilter; -import org.apache.fineract.cn.payroll.api.v1.EventConstants; -import org.apache.fineract.cn.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 MigrationEventListener { - - private final EventRecorder eventRecorder; - - @Autowired - public MigrationEventListener(@SuppressWarnings("SpringJavaAutowiringInspection") final EventRecorder eventRecorder) { - super(); - this.eventRecorder = eventRecorder; - } - - @JmsListener( - subscription = EventConstants.DESTINATION, - destination = EventConstants.DESTINATION, - selector = EventConstants.SELECTOR_INITIALIZE - ) - public void onInitialization(@Header(TenantHeaderFilter.TENANT_HEADER) final String tenant, - final String payload) { - this.eventRecorder.event(tenant, EventConstants.INITIALIZE, payload, String.class); - } -} diff --git a/service/src/test/java/org/apache/fineract/cn/payroll/listener/PayrollConfigurationListener.java b/service/src/test/java/org/apache/fineract/cn/payroll/listener/PayrollConfigurationListener.java deleted file mode 100644 index 776112d..0000000 --- a/service/src/test/java/org/apache/fineract/cn/payroll/listener/PayrollConfigurationListener.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.fineract.cn.payroll.listener; - -import org.apache.fineract.cn.lang.config.TenantHeaderFilter; -import org.apache.fineract.cn.payroll.api.v1.EventConstants; -import org.apache.fineract.cn.payroll.service.ServiceConstants; -import org.apache.fineract.cn.test.listener.EventRecorder; -import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.jms.annotation.JmsListener; -import org.springframework.messaging.handler.annotation.Header; -import org.springframework.stereotype.Component; - -@Component -public class PayrollConfigurationListener { - - private final Logger logger; - private final EventRecorder eventRecorder; - - @Autowired - public PayrollConfigurationListener(@Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger, - final EventRecorder eventRecorder) { - super(); - this.logger = logger; - this.eventRecorder = eventRecorder; - } - - @JmsListener( - subscription = EventConstants.DESTINATION, - destination = EventConstants.DESTINATION, - selector = EventConstants.SELECTOR_PUT_CONFIGURATION - ) - public void onPutConfiguration(@Header(TenantHeaderFilter.TENANT_HEADER) final String tenant, - final String payload) { - this.logger.info("Payment configuration for customer {} processed.", payload); - this.eventRecorder.event(tenant, EventConstants.PUT_CONFIGURATION, payload, String.class); - } -} diff --git a/service/src/test/java/org/apache/fineract/cn/payroll/listener/PayrollDistributionListener.java b/service/src/test/java/org/apache/fineract/cn/payroll/listener/PayrollDistributionListener.java deleted file mode 100644 index c489f2a..0000000 --- a/service/src/test/java/org/apache/fineract/cn/payroll/listener/PayrollDistributionListener.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.fineract.cn.payroll.listener; - -import org.apache.fineract.cn.lang.config.TenantHeaderFilter; -import org.apache.fineract.cn.payroll.api.v1.EventConstants; -import org.apache.fineract.cn.payroll.service.ServiceConstants; -import org.apache.fineract.cn.test.listener.EventRecorder; -import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.jms.annotation.JmsListener; -import org.springframework.messaging.handler.annotation.Header; -import org.springframework.stereotype.Component; - -@Component -public class PayrollDistributionListener { - - private final Logger logger; - private final EventRecorder eventRecorder; - - @Autowired - public PayrollDistributionListener(@Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger, - final EventRecorder eventRecorder) { - super(); - this.logger = logger; - this.eventRecorder = eventRecorder; - } - - @JmsListener( - subscription = EventConstants.DESTINATION, - destination = EventConstants.DESTINATION, - selector = EventConstants.SELECTOR_POST_DISTRIBUTION - ) - public void onPostCollection(@Header(TenantHeaderFilter.TENANT_HEADER) final String tenant, - final String payload) { - this.logger.info("Payment distribution with source account {0} processed.", payload); - this.eventRecorder.event(tenant, EventConstants.POST_DISTRIBUTION, payload, String.class); - } -}