-
Notifications
You must be signed in to change notification settings - Fork 2.4k
FINERACT-1678-Restrict-COB-catchup-api-for-batch-managers #2984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
galovics
merged 1 commit into
apache:develop
from
ruchiD:FINERACT-1678-Restrict-COB-catchup-api-for-batch-managers
Feb 20, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
.../java/org/apache/fineract/integrationtests/LoanCOBCatchUpInstanceModeIntegrationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| /** | ||
| * 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.integrationtests; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
|
||
| import io.restassured.builder.RequestSpecBuilder; | ||
| import io.restassured.builder.ResponseSpecBuilder; | ||
| import io.restassured.http.ContentType; | ||
| import io.restassured.specification.RequestSpecification; | ||
| import io.restassured.specification.ResponseSpecification; | ||
| import java.time.LocalDate; | ||
| import org.apache.fineract.client.util.CallFailedRuntimeException; | ||
| import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; | ||
| import org.apache.fineract.integrationtests.common.BusinessDateHelper; | ||
| import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper; | ||
| import org.apache.fineract.integrationtests.common.Utils; | ||
| import org.apache.fineract.integrationtests.common.loans.LoanCOBCatchUpHelper; | ||
| import org.apache.fineract.integrationtests.support.instancemode.ConfigureInstanceMode; | ||
| import org.apache.fineract.integrationtests.support.instancemode.InstanceModeSupportExtension; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.extension.ExtendWith; | ||
|
|
||
| @ExtendWith(InstanceModeSupportExtension.class) | ||
| public class LoanCOBCatchUpInstanceModeIntegrationTest { | ||
|
|
||
| private LoanCOBCatchUpHelper loanCOBCatchUpHelper; | ||
| private ResponseSpecification responseSpec; | ||
| private RequestSpecification requestSpec; | ||
|
|
||
| @BeforeEach | ||
| public void setup() throws InterruptedException { | ||
| Utils.initializeRESTAssured(); | ||
| loanCOBCatchUpHelper = new LoanCOBCatchUpHelper(); | ||
| this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); | ||
| this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); | ||
| this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); | ||
| final LocalDate todaysDate = Utils.getLocalDateOfTenant(); | ||
| GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE); | ||
| BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, todaysDate); | ||
| } | ||
|
|
||
| @ConfigureInstanceMode(readEnabled = false, writeEnabled = false, batchWorkerEnabled = false, batchManagerEnabled = true) | ||
| @Test | ||
| public void testLoanCOBCatchUpWorksWhenInBatchManagerMode() { | ||
| loanCOBCatchUpHelper.executeLoanCOBCatchUp(); | ||
| } | ||
|
|
||
| @ConfigureInstanceMode(readEnabled = false, writeEnabled = false, batchWorkerEnabled = true, batchManagerEnabled = false) | ||
| @Test | ||
| public void testLoanCOBCatchUpDoesNotWorksWhenNotInBatchManagerMode() { | ||
| CallFailedRuntimeException exception = assertThrows(CallFailedRuntimeException.class, | ||
| () -> loanCOBCatchUpHelper.executeLoanCOBCatchUp()); | ||
| assertEquals(405, exception.getResponse().code()); | ||
| } | ||
|
|
||
| @ConfigureInstanceMode(readEnabled = false, writeEnabled = false, batchWorkerEnabled = false, batchManagerEnabled = true) | ||
| @Test | ||
| public void testLoanCOBCatchUpGetStatusWorksWhenInBatchManagerMode() { | ||
| loanCOBCatchUpHelper.executeGetLoanCatchUpStatus(); | ||
| } | ||
|
|
||
| @ConfigureInstanceMode(readEnabled = false, writeEnabled = false, batchWorkerEnabled = true, batchManagerEnabled = false) | ||
| @Test | ||
| public void testLoanCOBCatchUpGetStatusDoesNotWorksWhenNotInBatchManagerMode() { | ||
| CallFailedRuntimeException exception = assertThrows(CallFailedRuntimeException.class, | ||
| () -> loanCOBCatchUpHelper.executeGetLoanCatchUpStatus()); | ||
| assertEquals(405, exception.getResponse().code()); | ||
| } | ||
|
|
||
| @ConfigureInstanceMode(readEnabled = true, writeEnabled = false, batchWorkerEnabled = false, batchManagerEnabled = true) | ||
| @Test | ||
| public void testLoanCOBCatchUpOtherGetApisWorksWhenInBatchManagerAndReadMode() { | ||
| loanCOBCatchUpHelper.executeRetrieveOldestCOBProcessedLoan(); | ||
| } | ||
|
|
||
| @ConfigureInstanceMode(readEnabled = true, writeEnabled = false, batchWorkerEnabled = false, batchManagerEnabled = false) | ||
| @Test | ||
| public void testLoanCOBCatchUpOtherGetApisWorksWhenInReadOnlyMode() { | ||
| loanCOBCatchUpHelper.executeRetrieveOldestCOBProcessedLoan(); | ||
| } | ||
|
|
||
| @AfterEach | ||
| public void tearDown() throws InterruptedException { | ||
| GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE); | ||
| } | ||
|
|
||
| } |
41 changes: 41 additions & 0 deletions
41
...src/test/java/org/apache/fineract/integrationtests/common/loans/LoanCOBCatchUpHelper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /** | ||
| * 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.integrationtests.common.loans; | ||
|
|
||
| import org.apache.fineract.client.models.GetOldestCOBProcessedLoanResponse; | ||
| import org.apache.fineract.client.models.IsCatchUpRunningResponse; | ||
| import org.apache.fineract.integrationtests.client.IntegrationTest; | ||
| import retrofit2.Response; | ||
|
|
||
| public class LoanCOBCatchUpHelper extends IntegrationTest { | ||
|
|
||
| public LoanCOBCatchUpHelper() {} | ||
|
|
||
| public Response<Void> executeLoanCOBCatchUp() { | ||
| return okR(fineract().loanCobCatchUpApi.executeLoanCOBCatchUp()); | ||
| } | ||
|
|
||
| public GetOldestCOBProcessedLoanResponse executeRetrieveOldestCOBProcessedLoan() { | ||
| return ok(fineract().loanCobCatchUpApi.getOldestCOBProcessedLoan()); | ||
| } | ||
|
|
||
| public Response<IsCatchUpRunningResponse> executeGetLoanCatchUpStatus() { | ||
| return okR(fineract().loanCobCatchUpApi.isCatchUpRunning()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch Ruchi.