You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by "DeathGun44 (via GitHub)" <gi...@apache.org> on 2026/06/07 13:16:21 UTC

[PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

DeathGun44 opened a new pull request, #5954:
URL: https://github.com/apache/fineract/pull/5954

   ## Description
   
   Extends FeignClientHelper from 4 to 16 methods and adds ClientRequestBuilders and FeignClientLifecycleTest covering the full client lifecycle - pending creation, activate, close, reject, reactivate, withdraw, undo-reject, undo-withdraw, update, delete, search, and account retrieval.
   
   Depends on: FINERACT-2632
   
   ## Checklist
   
   Please make sure these boxes are checked before submitting your pull request - thanks!
   
   - [ ] Write the commit message as per [our guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#pull-requests)
   - [ ] Acknowledge that we will not review PRs that are not passing the build _("green")_ - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
   - [ ] Create/update [unit or integration tests](https://fineract.apache.org/docs/current/#_testing) for verifying the changes made.
   - [ ] Follow our [coding conventions](https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions).
   - [ ] Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
   - [ ] [This PR must not be a "code dump"](https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit). Large changes can be made in a branch, with assistance. Ask for help on the [developer mailing list](https://fineract.apache.org/#contribute).
   
   Your assigned reviewer(s) will follow our [guidelines for code reviews](https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide).
   


-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

Posted by "DeathGun44 (via GitHub)" <gi...@apache.org>.
DeathGun44 commented on code in PR #5954:
URL: https://github.com/apache/fineract/pull/5954#discussion_r3373285404


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/modules/ClientRequestBuilders.java:
##########
@@ -0,0 +1,100 @@
+/**
+ * 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.client.feign.modules;
+
+import org.apache.fineract.client.models.PostClientsClientIdRequest;
+import org.apache.fineract.client.models.PostClientsRequest;
+import org.apache.fineract.client.models.PutClientsClientIdRequest;
+import org.apache.fineract.integrationtests.common.Utils;
+
+public final class ClientRequestBuilders {
+
+    private ClientRequestBuilders() {}
+
+    public static PostClientsRequest createPendingClient(String submittedOnDate) {
+        return new PostClientsRequest()//
+                .officeId(1L)//
+                .legalFormId(1L)//
+                .firstname(Utils.randomFirstNameGenerator())//
+                .lastname(Utils.randomLastNameGenerator())//
+                .externalId(Utils.randomStringGenerator("EXT_", 7))//
+                .active(false)//
+                .submittedOnDate(submittedOnDate)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .locale(LoanTestData.LOCALE);
+    }
+
+    public static PostClientsClientIdRequest activateClient(String activationDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .activationDate(activationDate);
+    }
+
+    public static PostClientsClientIdRequest closeClient(Long closureReasonId, String closureDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .closureReasonId(closureReasonId)//
+                .closureDate(closureDate);
+    }
+
+    public static PostClientsClientIdRequest rejectClient(Long rejectionReasonId, String rejectionDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .rejectionReasonId(rejectionReasonId)//
+                .rejectionDate(rejectionDate);
+    }
+
+    public static PostClientsClientIdRequest reactivateClient(String reactivationDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .reactivationDate(reactivationDate);
+    }
+
+    public static PostClientsClientIdRequest withdrawClient(Long withdrawalReasonId, String withdrawalDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .withdrawalReasonId(withdrawalReasonId)//
+                .withdrawalDate(withdrawalDate);
+    }
+
+    public static PostClientsClientIdRequest undoRejectClient(String reopenedDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .reopenedDate(reopenedDate);
+    }
+
+    public static PostClientsClientIdRequest undoWithdrawnClient(String reopenedDate) {

Review Comment:
   yes they are (both send reopenedDate), but they map to different server commands undoRejectClient sends ?command=undoRejection and undoWithdrawnClient sends ?command=undoWithdrawal. Keeping separate builders makes test code read which transition is being exercised.



-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on PR #5954:
URL: https://github.com/apache/fineract/pull/5954#issuecomment-4659958544

   @budaidev Please re-review it. (it is blocked till you rereview it)


-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

Posted by "DeathGun44 (via GitHub)" <gi...@apache.org>.
DeathGun44 commented on PR #5954:
URL: https://github.com/apache/fineract/pull/5954#issuecomment-4651721508

   @adamsaghy @budaidev rebased and ready for re review!


-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

Posted by "DeathGun44 (via GitHub)" <gi...@apache.org>.
DeathGun44 commented on code in PR #5954:
URL: https://github.com/apache/fineract/pull/5954#discussion_r3373275608


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignClientLifecycleTest.java:
##########
@@ -0,0 +1,255 @@
+/**
+ * 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.client.feign.tests;
+
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.List;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.GetClientsClientIdAccountsResponse;
+import org.apache.fineract.client.models.GetClientsClientIdResponse;
+import org.apache.fineract.client.models.GetCodeValuesDataResponse;
+import org.apache.fineract.client.models.GetCodesResponse;
+import org.apache.fineract.client.models.PageClientSearchData;
+import org.apache.fineract.client.models.PostClientsClientIdResponse;
+import org.apache.fineract.client.models.PostClientsResponse;
+import org.apache.fineract.client.models.PostCodeValueDataResponse;
+import org.apache.fineract.client.models.PostCodeValuesDataRequest;
+import org.apache.fineract.client.models.PutClientsClientIdResponse;
+import org.apache.fineract.integrationtests.client.FeignIntegrationTest;
+import org.apache.fineract.integrationtests.client.feign.helpers.FeignClientHelper;
+import org.apache.fineract.integrationtests.client.feign.modules.ClientRequestBuilders;
+import org.apache.fineract.integrationtests.client.feign.modules.LoanTestData;
+import org.apache.fineract.integrationtests.common.FineractFeignClientHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+public class FeignClientLifecycleTest extends FeignIntegrationTest {
+
+    private static final String STATUS_PENDING = "clientStatusType.pending";
+    private static final String STATUS_ACTIVE = "clientStatusType.active";
+    private static final String STATUS_CLOSED = "clientStatusType.closed";
+    private static final String STATUS_REJECTED = "clientStatusType.rejected";
+    private static final String STATUS_WITHDRAWN = "clientStatusType.withdrawn";
+
+    private static FeignClientHelper clientHelper;
+    private static FineractFeignClient fineractClient;
+
+    @BeforeAll
+    public static void setup() {
+        fineractClient = FineractFeignClientHelper.getFineractFeignClient();
+        clientHelper = new FeignClientHelper(fineractClient);
+    }
+
+    private Long resolveOrCreateCodeValue(String codeName) {
+        GetCodesResponse code = ok(() -> fineractClient.codes().retrieveCodeByName(codeName));
+        assertNotNull(code.getId());
+
+        List<GetCodeValuesDataResponse> values = ok(() -> fineractClient.codeValues().retrieveAllCodeValues(code.getId()));
+        if (values != null && !values.isEmpty()) {
+            return values.get(0).getId();
+        }
+
+        PostCodeValuesDataRequest createRequest = new PostCodeValuesDataRequest()//
+                .name(Utils.randomStringGenerator(codeName + "_", 5))//
+                .isActive(true);
+        PostCodeValueDataResponse created = ok(() -> fineractClient.codeValues().createCodeValue(code.getId(), createRequest));
+        return created.getResourceId();
+    }
+
+    private void assertClientStatus(Long clientId, String expectedStatusCode) {
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertNotNull(details.getStatus());
+        assertEquals(expectedStatusCode, details.getStatus().getCode());
+    }
+
+    @Test
+    @Order(1)
+    void testCreatePendingAndActivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+
+        PostClientsClientIdResponse activateResp = clientHelper.activateClient(pending.getClientId(),
+                ClientRequestBuilders.activateClient(today));
+        assertNotNull(activateResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(2)
+    void testCreatePendingAndRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+
+        PostClientsClientIdResponse rejectResp = clientHelper.rejectClient(pending.getClientId(),
+                ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertNotNull(rejectResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+    }
+
+    @Test
+    @Order(3)
+    void testRejectAndUndoRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+        clientHelper.rejectClient(pending.getClientId(), ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoRejectClient(pending.getClientId(),
+                ClientRequestBuilders.undoRejectClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(4)
+    void testWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+
+        PostClientsClientIdResponse withdrawResp = clientHelper.withdrawClient(pending.getClientId(),
+                ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertNotNull(withdrawResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+    }
+
+    @Test
+    @Order(5)
+    void testWithdrawAndUndoWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+        clientHelper.withdrawClient(pending.getClientId(), ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoWithdrawnClient(pending.getClientId(),
+                ClientRequestBuilders.undoWithdrawnClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(6)
+    void testCloseAndReactivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        Long closureReasonId = resolveOrCreateCodeValue("ClientClosureReason");
+
+        PostClientsClientIdResponse closeResp = clientHelper.closeClient(clientId,
+                ClientRequestBuilders.closeClient(closureReasonId, today));
+        assertNotNull(closeResp.getClientId());
+        assertClientStatus(clientId, STATUS_CLOSED);
+
+        PostClientsClientIdResponse reactivateResp = clientHelper.reactivateClient(clientId, ClientRequestBuilders.reactivateClient(today));
+        assertNotNull(reactivateResp.getClientId());
+        assertClientStatus(clientId, STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(7)
+    void testUpdateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        String newFirstName = Utils.randomFirstNameGenerator();
+        String newLastName = Utils.randomLastNameGenerator();
+        PutClientsClientIdResponse updateResp = clientHelper.updateClient(clientId,
+                ClientRequestBuilders.updateClientName(newFirstName, newLastName));
+        assertNotNull(updateResp.getClientId());
+
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertEquals(newFirstName, details.getFirstname());
+        assertEquals(newLastName, details.getLastname());
+    }
+
+    @Test
+    @Order(8)
+    void testDeletePendingClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        clientHelper.deleteClient(pending.getClientId());
+    }
+
+    @Test
+    @Order(9)
+    void testSearchClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        String uniqueLastName = Utils.randomStringGenerator("SearchTest_", 8);
+        PostClientsResponse created = clientHelper.createClientPending(new org.apache.fineract.client.models.PostClientsRequest()//
+                .officeId(1L)//
+                .legalFormId(1L)//
+                .firstname(Utils.randomFirstNameGenerator())//
+                .lastname(uniqueLastName)//
+                .externalId(Utils.randomStringGenerator("EXT_", 7))//
+                .active(true)//
+                .activationDate(today)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .locale(LoanTestData.LOCALE));
+        assertNotNull(created.getClientId());
+
+        PageClientSearchData results = clientHelper.searchClients(uniqueLastName);

Review Comment:
   fixed now creating a client via createClient(), searching by its last name, and asserting the results contain a match with the exact client ID.



-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

Posted by "DeathGun44 (via GitHub)" <gi...@apache.org>.
DeathGun44 commented on code in PR #5954:
URL: https://github.com/apache/fineract/pull/5954#discussion_r3373269027


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignClientLifecycleTest.java:
##########
@@ -0,0 +1,255 @@
+/**
+ * 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.client.feign.tests;
+
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.List;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.GetClientsClientIdAccountsResponse;
+import org.apache.fineract.client.models.GetClientsClientIdResponse;
+import org.apache.fineract.client.models.GetCodeValuesDataResponse;
+import org.apache.fineract.client.models.GetCodesResponse;
+import org.apache.fineract.client.models.PageClientSearchData;
+import org.apache.fineract.client.models.PostClientsClientIdResponse;
+import org.apache.fineract.client.models.PostClientsResponse;
+import org.apache.fineract.client.models.PostCodeValueDataResponse;
+import org.apache.fineract.client.models.PostCodeValuesDataRequest;
+import org.apache.fineract.client.models.PutClientsClientIdResponse;
+import org.apache.fineract.integrationtests.client.FeignIntegrationTest;
+import org.apache.fineract.integrationtests.client.feign.helpers.FeignClientHelper;
+import org.apache.fineract.integrationtests.client.feign.modules.ClientRequestBuilders;
+import org.apache.fineract.integrationtests.client.feign.modules.LoanTestData;
+import org.apache.fineract.integrationtests.common.FineractFeignClientHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+public class FeignClientLifecycleTest extends FeignIntegrationTest {
+
+    private static final String STATUS_PENDING = "clientStatusType.pending";
+    private static final String STATUS_ACTIVE = "clientStatusType.active";
+    private static final String STATUS_CLOSED = "clientStatusType.closed";
+    private static final String STATUS_REJECTED = "clientStatusType.rejected";
+    private static final String STATUS_WITHDRAWN = "clientStatusType.withdrawn";
+
+    private static FeignClientHelper clientHelper;
+    private static FineractFeignClient fineractClient;
+
+    @BeforeAll
+    public static void setup() {
+        fineractClient = FineractFeignClientHelper.getFineractFeignClient();
+        clientHelper = new FeignClientHelper(fineractClient);
+    }
+
+    private Long resolveOrCreateCodeValue(String codeName) {
+        GetCodesResponse code = ok(() -> fineractClient.codes().retrieveCodeByName(codeName));
+        assertNotNull(code.getId());
+
+        List<GetCodeValuesDataResponse> values = ok(() -> fineractClient.codeValues().retrieveAllCodeValues(code.getId()));
+        if (values != null && !values.isEmpty()) {
+            return values.get(0).getId();
+        }
+
+        PostCodeValuesDataRequest createRequest = new PostCodeValuesDataRequest()//
+                .name(Utils.randomStringGenerator(codeName + "_", 5))//
+                .isActive(true);
+        PostCodeValueDataResponse created = ok(() -> fineractClient.codeValues().createCodeValue(code.getId(), createRequest));
+        return created.getResourceId();
+    }
+
+    private void assertClientStatus(Long clientId, String expectedStatusCode) {
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertNotNull(details.getStatus());
+        assertEquals(expectedStatusCode, details.getStatus().getCode());
+    }
+
+    @Test
+    @Order(1)
+    void testCreatePendingAndActivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+
+        PostClientsClientIdResponse activateResp = clientHelper.activateClient(pending.getClientId(),
+                ClientRequestBuilders.activateClient(today));
+        assertNotNull(activateResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(2)
+    void testCreatePendingAndRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+
+        PostClientsClientIdResponse rejectResp = clientHelper.rejectClient(pending.getClientId(),
+                ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertNotNull(rejectResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+    }
+
+    @Test
+    @Order(3)
+    void testRejectAndUndoRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+        clientHelper.rejectClient(pending.getClientId(), ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoRejectClient(pending.getClientId(),
+                ClientRequestBuilders.undoRejectClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(4)
+    void testWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+
+        PostClientsClientIdResponse withdrawResp = clientHelper.withdrawClient(pending.getClientId(),
+                ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertNotNull(withdrawResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+    }
+
+    @Test
+    @Order(5)
+    void testWithdrawAndUndoWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+        clientHelper.withdrawClient(pending.getClientId(), ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoWithdrawnClient(pending.getClientId(),
+                ClientRequestBuilders.undoWithdrawnClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(6)
+    void testCloseAndReactivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        Long closureReasonId = resolveOrCreateCodeValue("ClientClosureReason");
+
+        PostClientsClientIdResponse closeResp = clientHelper.closeClient(clientId,
+                ClientRequestBuilders.closeClient(closureReasonId, today));
+        assertNotNull(closeResp.getClientId());
+        assertClientStatus(clientId, STATUS_CLOSED);
+
+        PostClientsClientIdResponse reactivateResp = clientHelper.reactivateClient(clientId, ClientRequestBuilders.reactivateClient(today));
+        assertNotNull(reactivateResp.getClientId());
+        assertClientStatus(clientId, STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(7)
+    void testUpdateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        String newFirstName = Utils.randomFirstNameGenerator();
+        String newLastName = Utils.randomLastNameGenerator();
+        PutClientsClientIdResponse updateResp = clientHelper.updateClient(clientId,
+                ClientRequestBuilders.updateClientName(newFirstName, newLastName));
+        assertNotNull(updateResp.getClientId());
+
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertEquals(newFirstName, details.getFirstname());
+        assertEquals(newLastName, details.getLastname());
+    }
+
+    @Test
+    @Order(8)
+    void testDeletePendingClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        clientHelper.deleteClient(pending.getClientId());

Review Comment:
   fair point, added getClientExpectingError() using the fail() pattern (same as FeignLoanOriginatorApiTest) and now asserting 404 after deletion.



-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on PR #5954:
URL: https://github.com/apache/fineract/pull/5954#issuecomment-4650665797

   ```
                                                                        ^
   /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/modules/ClientRequestBuilders.java:38: error: cannot find symbol
                   .submittedOnDate(submittedOnDate)//
                   ^
     symbol:   method submittedOnDate(String)
     location: class PostClientsRequest
   /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/modules/ClientRequestBuilders.java:77: error: cannot find symbol
                   .withdrawalReasonId(withdrawalReasonId)//
                   ^
     symbol:   method withdrawalReasonId(Long)
     location: class PostClientsClientIdRequest
   /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/modules/ClientRequestBuilders.java:85: error: cannot find symbol
                   .reopenedDate(reopenedDate);
                   ^
     symbol:   method reopenedDate(String)
     location: class PostClientsClientIdRequest
   /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/modules/ClientRequestBuilders.java:92: error: cannot find symbol
                   .reopenedDate(reopenedDate);
                   ^
     symbol:   method reopenedDate(String)
     location: class PostClientsClientIdRequest
   /home/runner/work/fineract/fineract/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/modules/ClientRequestBuilders.java:97: error: cannot find symbol
                   .firstname(firstname)//
                   ^
   ```
   
   Please run:
   `./gradlew spotlessApply spotbugsMain spotbugsTest checkstyleMain checkstyleTest`
   `./gradlew --no-daemon build -x test -x cucumber -x doc`                
                   
                 


-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

Posted by "budaidev (via GitHub)" <gi...@apache.org>.
budaidev commented on code in PR #5954:
URL: https://github.com/apache/fineract/pull/5954#discussion_r3372292895


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignClientLifecycleTest.java:
##########
@@ -0,0 +1,255 @@
+/**
+ * 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.client.feign.tests;
+
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.List;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.GetClientsClientIdAccountsResponse;
+import org.apache.fineract.client.models.GetClientsClientIdResponse;
+import org.apache.fineract.client.models.GetCodeValuesDataResponse;
+import org.apache.fineract.client.models.GetCodesResponse;
+import org.apache.fineract.client.models.PageClientSearchData;
+import org.apache.fineract.client.models.PostClientsClientIdResponse;
+import org.apache.fineract.client.models.PostClientsResponse;
+import org.apache.fineract.client.models.PostCodeValueDataResponse;
+import org.apache.fineract.client.models.PostCodeValuesDataRequest;
+import org.apache.fineract.client.models.PutClientsClientIdResponse;
+import org.apache.fineract.integrationtests.client.FeignIntegrationTest;
+import org.apache.fineract.integrationtests.client.feign.helpers.FeignClientHelper;
+import org.apache.fineract.integrationtests.client.feign.modules.ClientRequestBuilders;
+import org.apache.fineract.integrationtests.client.feign.modules.LoanTestData;
+import org.apache.fineract.integrationtests.common.FineractFeignClientHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+public class FeignClientLifecycleTest extends FeignIntegrationTest {
+
+    private static final String STATUS_PENDING = "clientStatusType.pending";
+    private static final String STATUS_ACTIVE = "clientStatusType.active";
+    private static final String STATUS_CLOSED = "clientStatusType.closed";
+    private static final String STATUS_REJECTED = "clientStatusType.rejected";
+    private static final String STATUS_WITHDRAWN = "clientStatusType.withdrawn";
+
+    private static FeignClientHelper clientHelper;
+    private static FineractFeignClient fineractClient;
+
+    @BeforeAll
+    public static void setup() {
+        fineractClient = FineractFeignClientHelper.getFineractFeignClient();
+        clientHelper = new FeignClientHelper(fineractClient);
+    }
+
+    private Long resolveOrCreateCodeValue(String codeName) {
+        GetCodesResponse code = ok(() -> fineractClient.codes().retrieveCodeByName(codeName));
+        assertNotNull(code.getId());
+
+        List<GetCodeValuesDataResponse> values = ok(() -> fineractClient.codeValues().retrieveAllCodeValues(code.getId()));
+        if (values != null && !values.isEmpty()) {
+            return values.get(0).getId();
+        }
+
+        PostCodeValuesDataRequest createRequest = new PostCodeValuesDataRequest()//
+                .name(Utils.randomStringGenerator(codeName + "_", 5))//
+                .isActive(true);
+        PostCodeValueDataResponse created = ok(() -> fineractClient.codeValues().createCodeValue(code.getId(), createRequest));
+        return created.getResourceId();
+    }
+
+    private void assertClientStatus(Long clientId, String expectedStatusCode) {
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertNotNull(details.getStatus());
+        assertEquals(expectedStatusCode, details.getStatus().getCode());
+    }
+
+    @Test
+    @Order(1)
+    void testCreatePendingAndActivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+
+        PostClientsClientIdResponse activateResp = clientHelper.activateClient(pending.getClientId(),
+                ClientRequestBuilders.activateClient(today));
+        assertNotNull(activateResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(2)
+    void testCreatePendingAndRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+
+        PostClientsClientIdResponse rejectResp = clientHelper.rejectClient(pending.getClientId(),
+                ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertNotNull(rejectResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+    }
+
+    @Test
+    @Order(3)
+    void testRejectAndUndoRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+        clientHelper.rejectClient(pending.getClientId(), ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoRejectClient(pending.getClientId(),
+                ClientRequestBuilders.undoRejectClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(4)
+    void testWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+
+        PostClientsClientIdResponse withdrawResp = clientHelper.withdrawClient(pending.getClientId(),
+                ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertNotNull(withdrawResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+    }
+
+    @Test
+    @Order(5)
+    void testWithdrawAndUndoWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+        clientHelper.withdrawClient(pending.getClientId(), ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoWithdrawnClient(pending.getClientId(),
+                ClientRequestBuilders.undoWithdrawnClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(6)
+    void testCloseAndReactivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        Long closureReasonId = resolveOrCreateCodeValue("ClientClosureReason");
+
+        PostClientsClientIdResponse closeResp = clientHelper.closeClient(clientId,
+                ClientRequestBuilders.closeClient(closureReasonId, today));
+        assertNotNull(closeResp.getClientId());
+        assertClientStatus(clientId, STATUS_CLOSED);
+
+        PostClientsClientIdResponse reactivateResp = clientHelper.reactivateClient(clientId, ClientRequestBuilders.reactivateClient(today));
+        assertNotNull(reactivateResp.getClientId());
+        assertClientStatus(clientId, STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(7)
+    void testUpdateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        String newFirstName = Utils.randomFirstNameGenerator();
+        String newLastName = Utils.randomLastNameGenerator();
+        PutClientsClientIdResponse updateResp = clientHelper.updateClient(clientId,
+                ClientRequestBuilders.updateClientName(newFirstName, newLastName));
+        assertNotNull(updateResp.getClientId());
+
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertEquals(newFirstName, details.getFirstname());
+        assertEquals(newLastName, details.getLastname());
+    }
+
+    @Test
+    @Order(8)
+    void testDeletePendingClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        clientHelper.deleteClient(pending.getClientId());

Review Comment:
   shouldn't we verify if it was deleted?



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/helpers/FeignClientHelper.java:
##########
@@ -62,7 +80,67 @@ public Long createClient(PostClientsRequest request) {
         return response.getClientId();
     }
 
+    public PostClientsResponse createClientPending() {

Review Comment:
   Why do we call this createClientPending? What does it do exactly?



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignClientLifecycleTest.java:
##########
@@ -0,0 +1,255 @@
+/**
+ * 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.client.feign.tests;
+
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.List;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.GetClientsClientIdAccountsResponse;
+import org.apache.fineract.client.models.GetClientsClientIdResponse;
+import org.apache.fineract.client.models.GetCodeValuesDataResponse;
+import org.apache.fineract.client.models.GetCodesResponse;
+import org.apache.fineract.client.models.PageClientSearchData;
+import org.apache.fineract.client.models.PostClientsClientIdResponse;
+import org.apache.fineract.client.models.PostClientsResponse;
+import org.apache.fineract.client.models.PostCodeValueDataResponse;
+import org.apache.fineract.client.models.PostCodeValuesDataRequest;
+import org.apache.fineract.client.models.PutClientsClientIdResponse;
+import org.apache.fineract.integrationtests.client.FeignIntegrationTest;
+import org.apache.fineract.integrationtests.client.feign.helpers.FeignClientHelper;
+import org.apache.fineract.integrationtests.client.feign.modules.ClientRequestBuilders;
+import org.apache.fineract.integrationtests.client.feign.modules.LoanTestData;
+import org.apache.fineract.integrationtests.common.FineractFeignClientHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+public class FeignClientLifecycleTest extends FeignIntegrationTest {
+
+    private static final String STATUS_PENDING = "clientStatusType.pending";
+    private static final String STATUS_ACTIVE = "clientStatusType.active";
+    private static final String STATUS_CLOSED = "clientStatusType.closed";
+    private static final String STATUS_REJECTED = "clientStatusType.rejected";
+    private static final String STATUS_WITHDRAWN = "clientStatusType.withdrawn";
+
+    private static FeignClientHelper clientHelper;
+    private static FineractFeignClient fineractClient;
+
+    @BeforeAll
+    public static void setup() {
+        fineractClient = FineractFeignClientHelper.getFineractFeignClient();
+        clientHelper = new FeignClientHelper(fineractClient);
+    }
+
+    private Long resolveOrCreateCodeValue(String codeName) {
+        GetCodesResponse code = ok(() -> fineractClient.codes().retrieveCodeByName(codeName));
+        assertNotNull(code.getId());
+
+        List<GetCodeValuesDataResponse> values = ok(() -> fineractClient.codeValues().retrieveAllCodeValues(code.getId()));
+        if (values != null && !values.isEmpty()) {
+            return values.get(0).getId();
+        }
+
+        PostCodeValuesDataRequest createRequest = new PostCodeValuesDataRequest()//
+                .name(Utils.randomStringGenerator(codeName + "_", 5))//
+                .isActive(true);
+        PostCodeValueDataResponse created = ok(() -> fineractClient.codeValues().createCodeValue(code.getId(), createRequest));
+        return created.getResourceId();
+    }
+
+    private void assertClientStatus(Long clientId, String expectedStatusCode) {
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertNotNull(details.getStatus());
+        assertEquals(expectedStatusCode, details.getStatus().getCode());
+    }
+
+    @Test
+    @Order(1)
+    void testCreatePendingAndActivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+
+        PostClientsClientIdResponse activateResp = clientHelper.activateClient(pending.getClientId(),
+                ClientRequestBuilders.activateClient(today));
+        assertNotNull(activateResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(2)
+    void testCreatePendingAndRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+
+        PostClientsClientIdResponse rejectResp = clientHelper.rejectClient(pending.getClientId(),
+                ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertNotNull(rejectResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+    }
+
+    @Test
+    @Order(3)
+    void testRejectAndUndoRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+        clientHelper.rejectClient(pending.getClientId(), ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoRejectClient(pending.getClientId(),
+                ClientRequestBuilders.undoRejectClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(4)
+    void testWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+
+        PostClientsClientIdResponse withdrawResp = clientHelper.withdrawClient(pending.getClientId(),
+                ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertNotNull(withdrawResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+    }
+
+    @Test
+    @Order(5)
+    void testWithdrawAndUndoWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+        clientHelper.withdrawClient(pending.getClientId(), ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoWithdrawnClient(pending.getClientId(),
+                ClientRequestBuilders.undoWithdrawnClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(6)
+    void testCloseAndReactivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        Long closureReasonId = resolveOrCreateCodeValue("ClientClosureReason");
+
+        PostClientsClientIdResponse closeResp = clientHelper.closeClient(clientId,
+                ClientRequestBuilders.closeClient(closureReasonId, today));
+        assertNotNull(closeResp.getClientId());
+        assertClientStatus(clientId, STATUS_CLOSED);
+
+        PostClientsClientIdResponse reactivateResp = clientHelper.reactivateClient(clientId, ClientRequestBuilders.reactivateClient(today));
+        assertNotNull(reactivateResp.getClientId());
+        assertClientStatus(clientId, STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(7)
+    void testUpdateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        String newFirstName = Utils.randomFirstNameGenerator();
+        String newLastName = Utils.randomLastNameGenerator();
+        PutClientsClientIdResponse updateResp = clientHelper.updateClient(clientId,
+                ClientRequestBuilders.updateClientName(newFirstName, newLastName));
+        assertNotNull(updateResp.getClientId());
+
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertEquals(newFirstName, details.getFirstname());
+        assertEquals(newLastName, details.getLastname());
+    }
+
+    @Test
+    @Order(8)
+    void testDeletePendingClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        clientHelper.deleteClient(pending.getClientId());
+    }
+
+    @Test
+    @Order(9)
+    void testSearchClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        String uniqueLastName = Utils.randomStringGenerator("SearchTest_", 8);
+        PostClientsResponse created = clientHelper.createClientPending(new org.apache.fineract.client.models.PostClientsRequest()//
+                .officeId(1L)//
+                .legalFormId(1L)//
+                .firstname(Utils.randomFirstNameGenerator())//
+                .lastname(uniqueLastName)//
+                .externalId(Utils.randomStringGenerator("EXT_", 7))//
+                .active(true)//
+                .activationDate(today)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .locale(LoanTestData.LOCALE));
+        assertNotNull(created.getClientId());
+
+        PageClientSearchData results = clientHelper.searchClients(uniqueLastName);

Review Comment:
   we can have a more exact assertation, like checking the id or name of the result.



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignClientLifecycleTest.java:
##########
@@ -0,0 +1,255 @@
+/**
+ * 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.client.feign.tests;
+
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.List;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.GetClientsClientIdAccountsResponse;
+import org.apache.fineract.client.models.GetClientsClientIdResponse;
+import org.apache.fineract.client.models.GetCodeValuesDataResponse;
+import org.apache.fineract.client.models.GetCodesResponse;
+import org.apache.fineract.client.models.PageClientSearchData;
+import org.apache.fineract.client.models.PostClientsClientIdResponse;
+import org.apache.fineract.client.models.PostClientsResponse;
+import org.apache.fineract.client.models.PostCodeValueDataResponse;
+import org.apache.fineract.client.models.PostCodeValuesDataRequest;
+import org.apache.fineract.client.models.PutClientsClientIdResponse;
+import org.apache.fineract.integrationtests.client.FeignIntegrationTest;
+import org.apache.fineract.integrationtests.client.feign.helpers.FeignClientHelper;
+import org.apache.fineract.integrationtests.client.feign.modules.ClientRequestBuilders;
+import org.apache.fineract.integrationtests.client.feign.modules.LoanTestData;
+import org.apache.fineract.integrationtests.common.FineractFeignClientHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+public class FeignClientLifecycleTest extends FeignIntegrationTest {
+
+    private static final String STATUS_PENDING = "clientStatusType.pending";
+    private static final String STATUS_ACTIVE = "clientStatusType.active";
+    private static final String STATUS_CLOSED = "clientStatusType.closed";
+    private static final String STATUS_REJECTED = "clientStatusType.rejected";
+    private static final String STATUS_WITHDRAWN = "clientStatusType.withdrawn";
+
+    private static FeignClientHelper clientHelper;
+    private static FineractFeignClient fineractClient;
+
+    @BeforeAll
+    public static void setup() {
+        fineractClient = FineractFeignClientHelper.getFineractFeignClient();
+        clientHelper = new FeignClientHelper(fineractClient);
+    }
+
+    private Long resolveOrCreateCodeValue(String codeName) {
+        GetCodesResponse code = ok(() -> fineractClient.codes().retrieveCodeByName(codeName));
+        assertNotNull(code.getId());
+
+        List<GetCodeValuesDataResponse> values = ok(() -> fineractClient.codeValues().retrieveAllCodeValues(code.getId()));
+        if (values != null && !values.isEmpty()) {
+            return values.get(0).getId();
+        }
+
+        PostCodeValuesDataRequest createRequest = new PostCodeValuesDataRequest()//
+                .name(Utils.randomStringGenerator(codeName + "_", 5))//
+                .isActive(true);
+        PostCodeValueDataResponse created = ok(() -> fineractClient.codeValues().createCodeValue(code.getId(), createRequest));
+        return created.getResourceId();
+    }
+
+    private void assertClientStatus(Long clientId, String expectedStatusCode) {
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertNotNull(details.getStatus());
+        assertEquals(expectedStatusCode, details.getStatus().getCode());
+    }
+
+    @Test
+    @Order(1)
+    void testCreatePendingAndActivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+
+        PostClientsClientIdResponse activateResp = clientHelper.activateClient(pending.getClientId(),
+                ClientRequestBuilders.activateClient(today));
+        assertNotNull(activateResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(2)
+    void testCreatePendingAndRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+
+        PostClientsClientIdResponse rejectResp = clientHelper.rejectClient(pending.getClientId(),
+                ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertNotNull(rejectResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+    }
+
+    @Test
+    @Order(3)
+    void testRejectAndUndoRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+        clientHelper.rejectClient(pending.getClientId(), ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoRejectClient(pending.getClientId(),
+                ClientRequestBuilders.undoRejectClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(4)
+    void testWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+
+        PostClientsClientIdResponse withdrawResp = clientHelper.withdrawClient(pending.getClientId(),
+                ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertNotNull(withdrawResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+    }
+
+    @Test
+    @Order(5)
+    void testWithdrawAndUndoWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+        clientHelper.withdrawClient(pending.getClientId(), ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoWithdrawnClient(pending.getClientId(),
+                ClientRequestBuilders.undoWithdrawnClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(6)
+    void testCloseAndReactivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        Long closureReasonId = resolveOrCreateCodeValue("ClientClosureReason");
+
+        PostClientsClientIdResponse closeResp = clientHelper.closeClient(clientId,
+                ClientRequestBuilders.closeClient(closureReasonId, today));
+        assertNotNull(closeResp.getClientId());
+        assertClientStatus(clientId, STATUS_CLOSED);
+
+        PostClientsClientIdResponse reactivateResp = clientHelper.reactivateClient(clientId, ClientRequestBuilders.reactivateClient(today));
+        assertNotNull(reactivateResp.getClientId());
+        assertClientStatus(clientId, STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(7)
+    void testUpdateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        String newFirstName = Utils.randomFirstNameGenerator();
+        String newLastName = Utils.randomLastNameGenerator();
+        PutClientsClientIdResponse updateResp = clientHelper.updateClient(clientId,
+                ClientRequestBuilders.updateClientName(newFirstName, newLastName));
+        assertNotNull(updateResp.getClientId());
+
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertEquals(newFirstName, details.getFirstname());
+        assertEquals(newLastName, details.getLastname());
+    }
+
+    @Test
+    @Order(8)
+    void testDeletePendingClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        clientHelper.deleteClient(pending.getClientId());
+    }
+
+    @Test
+    @Order(9)
+    void testSearchClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        String uniqueLastName = Utils.randomStringGenerator("SearchTest_", 8);
+        PostClientsResponse created = clientHelper.createClientPending(new org.apache.fineract.client.models.PostClientsRequest()//
+                .officeId(1L)//

Review Comment:
   minor: magic numbers in multiple locations, would be a bit nicer in constant



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/modules/ClientRequestBuilders.java:
##########
@@ -0,0 +1,100 @@
+/**
+ * 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.client.feign.modules;
+
+import org.apache.fineract.client.models.PostClientsClientIdRequest;
+import org.apache.fineract.client.models.PostClientsRequest;
+import org.apache.fineract.client.models.PutClientsClientIdRequest;
+import org.apache.fineract.integrationtests.common.Utils;
+
+public final class ClientRequestBuilders {
+
+    private ClientRequestBuilders() {}
+
+    public static PostClientsRequest createPendingClient(String submittedOnDate) {
+        return new PostClientsRequest()//
+                .officeId(1L)//
+                .legalFormId(1L)//
+                .firstname(Utils.randomFirstNameGenerator())//
+                .lastname(Utils.randomLastNameGenerator())//
+                .externalId(Utils.randomStringGenerator("EXT_", 7))//
+                .active(false)//
+                .submittedOnDate(submittedOnDate)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .locale(LoanTestData.LOCALE);
+    }
+
+    public static PostClientsClientIdRequest activateClient(String activationDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .activationDate(activationDate);
+    }
+
+    public static PostClientsClientIdRequest closeClient(Long closureReasonId, String closureDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .closureReasonId(closureReasonId)//
+                .closureDate(closureDate);
+    }
+
+    public static PostClientsClientIdRequest rejectClient(Long rejectionReasonId, String rejectionDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .rejectionReasonId(rejectionReasonId)//
+                .rejectionDate(rejectionDate);
+    }
+
+    public static PostClientsClientIdRequest reactivateClient(String reactivationDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .reactivationDate(reactivationDate);
+    }
+
+    public static PostClientsClientIdRequest withdrawClient(Long withdrawalReasonId, String withdrawalDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .withdrawalReasonId(withdrawalReasonId)//
+                .withdrawalDate(withdrawalDate);
+    }
+
+    public static PostClientsClientIdRequest undoRejectClient(String reopenedDate) {
+        return new PostClientsClientIdRequest()//
+                .locale(LoanTestData.LOCALE)//
+                .dateFormat(LoanTestData.DATETIME_PATTERN)//
+                .reopenedDate(reopenedDate);
+    }
+
+    public static PostClientsClientIdRequest undoWithdrawnClient(String reopenedDate) {

Review Comment:
   isn't this the same as undoRejectClient?



-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

Posted by "DeathGun44 (via GitHub)" <gi...@apache.org>.
DeathGun44 commented on code in PR #5954:
URL: https://github.com/apache/fineract/pull/5954#discussion_r3373272609


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/helpers/FeignClientHelper.java:
##########
@@ -62,7 +80,67 @@ public Long createClient(PostClientsRequest request) {
         return response.getClientId();
     }
 
+    public PostClientsResponse createClientPending() {

Review Comment:
   It creates a client in pending status (active=false), the server concept where a client is submitted but not yet activated. It returns the full PostClientsResponse (not just the ID) so the caller has access to resourceExternalId. The naming mirrors the status code clientStatusType.pending.



-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy merged PR #5954:
URL: https://github.com/apache/fineract/pull/5954


-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

Posted by "DeathGun44 (via GitHub)" <gi...@apache.org>.
DeathGun44 commented on code in PR #5954:
URL: https://github.com/apache/fineract/pull/5954#discussion_r3373278192


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignClientLifecycleTest.java:
##########
@@ -0,0 +1,255 @@
+/**
+ * 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.client.feign.tests;
+
+import static org.apache.fineract.client.feign.util.FeignCalls.ok;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.List;
+import org.apache.fineract.client.feign.FineractFeignClient;
+import org.apache.fineract.client.models.GetClientsClientIdAccountsResponse;
+import org.apache.fineract.client.models.GetClientsClientIdResponse;
+import org.apache.fineract.client.models.GetCodeValuesDataResponse;
+import org.apache.fineract.client.models.GetCodesResponse;
+import org.apache.fineract.client.models.PageClientSearchData;
+import org.apache.fineract.client.models.PostClientsClientIdResponse;
+import org.apache.fineract.client.models.PostClientsResponse;
+import org.apache.fineract.client.models.PostCodeValueDataResponse;
+import org.apache.fineract.client.models.PostCodeValuesDataRequest;
+import org.apache.fineract.client.models.PutClientsClientIdResponse;
+import org.apache.fineract.integrationtests.client.FeignIntegrationTest;
+import org.apache.fineract.integrationtests.client.feign.helpers.FeignClientHelper;
+import org.apache.fineract.integrationtests.client.feign.modules.ClientRequestBuilders;
+import org.apache.fineract.integrationtests.client.feign.modules.LoanTestData;
+import org.apache.fineract.integrationtests.common.FineractFeignClientHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+public class FeignClientLifecycleTest extends FeignIntegrationTest {
+
+    private static final String STATUS_PENDING = "clientStatusType.pending";
+    private static final String STATUS_ACTIVE = "clientStatusType.active";
+    private static final String STATUS_CLOSED = "clientStatusType.closed";
+    private static final String STATUS_REJECTED = "clientStatusType.rejected";
+    private static final String STATUS_WITHDRAWN = "clientStatusType.withdrawn";
+
+    private static FeignClientHelper clientHelper;
+    private static FineractFeignClient fineractClient;
+
+    @BeforeAll
+    public static void setup() {
+        fineractClient = FineractFeignClientHelper.getFineractFeignClient();
+        clientHelper = new FeignClientHelper(fineractClient);
+    }
+
+    private Long resolveOrCreateCodeValue(String codeName) {
+        GetCodesResponse code = ok(() -> fineractClient.codes().retrieveCodeByName(codeName));
+        assertNotNull(code.getId());
+
+        List<GetCodeValuesDataResponse> values = ok(() -> fineractClient.codeValues().retrieveAllCodeValues(code.getId()));
+        if (values != null && !values.isEmpty()) {
+            return values.get(0).getId();
+        }
+
+        PostCodeValuesDataRequest createRequest = new PostCodeValuesDataRequest()//
+                .name(Utils.randomStringGenerator(codeName + "_", 5))//
+                .isActive(true);
+        PostCodeValueDataResponse created = ok(() -> fineractClient.codeValues().createCodeValue(code.getId(), createRequest));
+        return created.getResourceId();
+    }
+
+    private void assertClientStatus(Long clientId, String expectedStatusCode) {
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertNotNull(details.getStatus());
+        assertEquals(expectedStatusCode, details.getStatus().getCode());
+    }
+
+    @Test
+    @Order(1)
+    void testCreatePendingAndActivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+
+        PostClientsClientIdResponse activateResp = clientHelper.activateClient(pending.getClientId(),
+                ClientRequestBuilders.activateClient(today));
+        assertNotNull(activateResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(2)
+    void testCreatePendingAndRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+
+        PostClientsClientIdResponse rejectResp = clientHelper.rejectClient(pending.getClientId(),
+                ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertNotNull(rejectResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+    }
+
+    @Test
+    @Order(3)
+    void testRejectAndUndoRejectClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long rejectionReasonId = resolveOrCreateCodeValue("ClientRejectReason");
+        clientHelper.rejectClient(pending.getClientId(), ClientRequestBuilders.rejectClient(rejectionReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_REJECTED);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoRejectClient(pending.getClientId(),
+                ClientRequestBuilders.undoRejectClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(4)
+    void testWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+
+        PostClientsClientIdResponse withdrawResp = clientHelper.withdrawClient(pending.getClientId(),
+                ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertNotNull(withdrawResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+    }
+
+    @Test
+    @Order(5)
+    void testWithdrawAndUndoWithdrawClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        Long withdrawalReasonId = resolveOrCreateCodeValue("ClientWithdrawReason");
+        clientHelper.withdrawClient(pending.getClientId(), ClientRequestBuilders.withdrawClient(withdrawalReasonId, today));
+        assertClientStatus(pending.getClientId(), STATUS_WITHDRAWN);
+
+        PostClientsClientIdResponse undoResp = clientHelper.undoWithdrawnClient(pending.getClientId(),
+                ClientRequestBuilders.undoWithdrawnClient(today));
+        assertNotNull(undoResp.getClientId());
+        assertClientStatus(pending.getClientId(), STATUS_PENDING);
+    }
+
+    @Test
+    @Order(6)
+    void testCloseAndReactivateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        Long closureReasonId = resolveOrCreateCodeValue("ClientClosureReason");
+
+        PostClientsClientIdResponse closeResp = clientHelper.closeClient(clientId,
+                ClientRequestBuilders.closeClient(closureReasonId, today));
+        assertNotNull(closeResp.getClientId());
+        assertClientStatus(clientId, STATUS_CLOSED);
+
+        PostClientsClientIdResponse reactivateResp = clientHelper.reactivateClient(clientId, ClientRequestBuilders.reactivateClient(today));
+        assertNotNull(reactivateResp.getClientId());
+        assertClientStatus(clientId, STATUS_ACTIVE);
+    }
+
+    @Test
+    @Order(7)
+    void testUpdateClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        Long clientId = clientHelper.createClient(today);
+
+        String newFirstName = Utils.randomFirstNameGenerator();
+        String newLastName = Utils.randomLastNameGenerator();
+        PutClientsClientIdResponse updateResp = clientHelper.updateClient(clientId,
+                ClientRequestBuilders.updateClientName(newFirstName, newLastName));
+        assertNotNull(updateResp.getClientId());
+
+        GetClientsClientIdResponse details = clientHelper.getClient(clientId);
+        assertEquals(newFirstName, details.getFirstname());
+        assertEquals(newLastName, details.getLastname());
+    }
+
+    @Test
+    @Order(8)
+    void testDeletePendingClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        PostClientsResponse pending = clientHelper.createClientPending(today);
+        assertNotNull(pending.getClientId());
+
+        clientHelper.deleteClient(pending.getClientId());
+    }
+
+    @Test
+    @Order(9)
+    void testSearchClient() {
+        String today = Utils.dateFormatter.format(Utils.getLocalDateOfTenant());
+
+        String uniqueLastName = Utils.randomStringGenerator("SearchTest_", 8);
+        PostClientsResponse created = clientHelper.createClientPending(new org.apache.fineract.client.models.PostClientsRequest()//
+                .officeId(1L)//

Review Comment:
   removed the inline request construction entirely, the test now uses createClient() which delegates to ClientRequestBuilders where officeId/legalFormId are already centralised.



-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2631: Extend FeignClientHelper with pending client creation, status transitions, and CRUD [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on PR #5954:
URL: https://github.com/apache/fineract/pull/5954#issuecomment-4672100676

   @budaidev Please re-review it. (it is blocked till you rereview it)


-- 
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: issues-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org