adamsaghy commented on code in PR #4222: URL: https://github.com/apache/fineract/pull/4222#discussion_r1890052900
########## integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanInterestPauseApiTest.java: ########## @@ -0,0 +1,104 @@ +/** + * 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 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 lombok.extern.slf4j.Slf4j; +import org.apache.fineract.integrationtests.common.Utils; +import org.apache.fineract.integrationtests.common.loans.InterestPauseHelper; +import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +@Slf4j +@ExtendWith({ LoanTestLifecycleExtension.class }) +public class LoanInterestPauseApiTest extends BaseLoanIntegrationTest { + + private static RequestSpecification REQUEST_SPEC; + private static ResponseSpecification RESPONSE_SPEC; + private static ResponseSpecification RESPONSE_SPEC_403; + private static InterestPauseHelper INTEREST_PAUSE_HELPER; + + @BeforeAll + public static void setupTests() { + Utils.initializeRESTAssured(); + REQUEST_SPEC = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); + REQUEST_SPEC.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); + RESPONSE_SPEC = new ResponseSpecBuilder().expectStatusCode(200).build(); + + RESPONSE_SPEC_403 = new ResponseSpecBuilder().expectStatusCode(403).build(); + + INTEREST_PAUSE_HELPER = new InterestPauseHelper(REQUEST_SPEC, RESPONSE_SPEC); + } + + @Test + public void testCreateInterestPauseByLoanId_validRequest_shouldSucceed() { + Long loanId = 1L; + + String response = INTEREST_PAUSE_HELPER.createInterestPauseByLoanId(loanId, "2024-12-01", "2024-12-05", "yyyy-MM-dd", "en"); + + Assertions.assertNotNull(response); + Assertions.assertTrue(response.contains("resourceId")); + } + + @Test + public void testCreateInterestPauseByLoanId_endDateBeforeStartDate_shouldFail() { + Long loanId = 1L; + + String response = INTEREST_PAUSE_HELPER.createInterestPauseByLoanId(loanId, "2024-12-05", "2024-12-01", "yyyy-MM-dd", "en", + RESPONSE_SPEC_403); + + Assertions.assertTrue(response.contains("interest.pause.end.date.before.start.date")); + } + + @Test + public void testCreateInterestPauseByLoanId_startDateBeforeLoanStart_shouldFail() { + Long loanId = 1L; + + String response = INTEREST_PAUSE_HELPER.createInterestPauseByLoanId(loanId, "2022-12-01", "2024-12-05", "yyyy-MM-dd", "en", + RESPONSE_SPEC_403); + + Assertions.assertTrue(response.contains("interest.pause.start.date.before.loan.start.date")); + } + + @Test + public void testCreateInterestPauseByLoanId_endDateAfterLoanMaturity_shouldFail() { + Long loanId = 1L; + + String response = INTEREST_PAUSE_HELPER.createInterestPauseByLoanId(loanId, "2024-12-01", "2025-12-05", "yyyy-MM-dd", "en", + RESPONSE_SPEC_403); + + Assertions.assertTrue(response.contains("interest.pause.end.date.after.loan.maturity.date")); + } + + @Test + public void testRetrieveInterestPausesByLoanId_shouldReturnData() { + Long loanId = 1L; + + String response = INTEREST_PAUSE_HELPER.retrieveInterestPausesByLoanId(loanId); + + Assertions.assertNotNull(response); Review Comment: Asserting whether the response is not null is highly inefficient and testing the bare minimum. Kindly asking you to check whether each fields are correct that was returned! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
