You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "galovics (via GitHub)" <gi...@apache.org> on 2023/05/23 08:24:50 UTC

[GitHub] [fineract] galovics opened a new pull request, #3196: FINERACT-1724: Client search V2 API

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

   ## Description
   
   Describe the changes made and why they were made.
   
   Ignore if these details are present on the associated [Apache Fineract JIRA ticket](https://github.com/apache/fineract/pull/1284).
   
   
   ## Checklist
   
   Please make sure these boxes are checked before submitting your pull request - thanks!
   
   - [ ] Write the commit message as per https://github.com/apache/fineract/#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 for verifying the changes made.
   
   - [ ] Follow coding conventions at 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
   
   - [ ] Submission is not a "code dump".  (Large changes can be made "in repository" via a branch.  Ask on the developer mailing list for guidance, if required.)
   
   FYI our guidelines for code reviews are at 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: commits-unsubscribe@fineract.apache.org

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


[GitHub] [fineract] adamsaghy commented on a diff in pull request #3196: FINERACT-1724: Client search V2 API

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


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ClientSearchTest.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * 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;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+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 org.apache.fineract.client.models.GetClientsClientIdResponse;
+import org.apache.fineract.client.models.PageClientSearchData;
+import org.apache.fineract.client.models.PostClientsRequest;
+import org.apache.fineract.client.models.PostClientsResponse;
+import org.apache.fineract.client.models.SortOrder;
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class ClientSearchTest {
+
+    private ResponseSpecification responseSpec;
+    private RequestSpecification requestSpec;
+    private ClientHelper clientHelper;
+
+    @BeforeEach
+    public void setup() {
+        Utils.initializeRESTAssured();
+        requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
+        requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+        responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
+        clientHelper = new ClientHelper(requestSpec, responseSpec);
+    }
+
+    @Test
+    public void testClientSearchWorks_WithLastnameTextOnDefaultOrdering() {
+        // given
+        String lastname = Utils.randomStringGenerator("Client_LastName_", 5);
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        request1.setLastname(lastname);
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        request2.setLastname(lastname);
+        clientHelper.createClient(request2);
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        request3.setLastname(lastname);
+        clientHelper.createClient(request3);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(lastname);
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(3);
+        assertThat(result.getContent().get(0).getExternalId().getValue()).isEqualTo(request3.getExternalId());
+        assertThat(result.getContent().get(1).getExternalId().getValue()).isEqualTo(request2.getExternalId());
+        assertThat(result.getContent().get(2).getExternalId().getValue()).isEqualTo(request1.getExternalId());
+    }
+
+    @Test
+    public void testClientSearchWorks_WithLastnameText_OrderedByIdAsc() {
+        // given
+        String lastname = Utils.randomStringGenerator("Client_LastName_", 5);
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        request1.setLastname(lastname);
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        request2.setLastname(lastname);
+        clientHelper.createClient(request2);
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        request3.setLastname(lastname);
+        clientHelper.createClient(request3);
+
+        SortOrder sortOrder = new SortOrder().property("id").direction(SortOrder.DirectionEnum.ASC);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(lastname, sortOrder);
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(3);
+        assertThat(result.getContent().get(0).getExternalId().getValue()).isEqualTo(request1.getExternalId());
+        assertThat(result.getContent().get(1).getExternalId().getValue()).isEqualTo(request2.getExternalId());
+        assertThat(result.getContent().get(2).getExternalId().getValue()).isEqualTo(request3.getExternalId());
+    }
+
+    @Test
+    public void testClientSearchWorks_ByExternalId() {
+        // given
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request2);
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request3);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(request2.getExternalId());
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(1);
+        assertThat(result.getContent().get(0).getExternalId().getValue()).isEqualTo(request2.getExternalId());
+    }
+
+    @Test
+    public void testClientSearchWorks_ByAccountNumber() {
+        // given
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        PostClientsResponse response2 = clientHelper.createClient(request2);
+        GetClientsClientIdResponse client2Data = ClientHelper.getClient(requestSpec, responseSpec,
+                Math.toIntExact(response2.getClientId()));
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request3);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(client2Data.getAccountNo());
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(1);
+        assertThat(result.getContent().get(0).getAccountNo()).isEqualTo(client2Data.getAccountNo());
+    }
+
+    @Test
+    public void testClientSearchWorks_ByDisplayName() {
+        // given
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request2);
+        String client2DisplayName = "%s %s".formatted(request2.getFirstname(), request2.getLastname());
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request3);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(client2DisplayName);
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(1);
+        assertThat(result.getContent().get(0).getDisplayName()).isEqualTo(client2DisplayName);
+    }
+
+    @Test
+    public void testClientSearchWorks_ByMobileNo() {
+        // given
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        request2.setMobileNo(Utils.randomNumberGenerator(8).toString());
+        clientHelper.createClient(request2);
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request3);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(request2.getMobileNo());
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(1);
+        assertThat(result.getContent().get(0).getMobileNo()).isEqualTo(request2.getMobileNo());
+    }

Review Comment:
   you might wanna add a negative test case, when there is no found item.



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

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


[GitHub] [fineract] adamsaghy commented on a diff in pull request #3196: FINERACT-1724: Client search V2 API

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


##########
integration-tests/build.gradle:
##########
@@ -93,8 +93,8 @@ cargoStartLocal.dependsOn ':fineract-war:war'
 cargoStartLocal.mustRunAfter 'testClasses'
 
 test {
-    dependsOn(cargoStartLocal)

Review Comment:
   you might wanna uncomment this.



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

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


[GitHub] [fineract] galovics merged pull request #3196: FINERACT-1724: Client search V2 API

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


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

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


[GitHub] [fineract] galovics commented on a diff in pull request #3196: FINERACT-1724: Client search V2 API

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


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ClientSearchTest.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * 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;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+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 org.apache.fineract.client.models.GetClientsClientIdResponse;
+import org.apache.fineract.client.models.PageClientSearchData;
+import org.apache.fineract.client.models.PostClientsRequest;
+import org.apache.fineract.client.models.PostClientsResponse;
+import org.apache.fineract.client.models.SortOrder;
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class ClientSearchTest {
+
+    private ResponseSpecification responseSpec;
+    private RequestSpecification requestSpec;
+    private ClientHelper clientHelper;
+
+    @BeforeEach
+    public void setup() {
+        Utils.initializeRESTAssured();
+        requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
+        requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+        responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
+        clientHelper = new ClientHelper(requestSpec, responseSpec);
+    }
+
+    @Test
+    public void testClientSearchWorks_WithLastnameTextOnDefaultOrdering() {
+        // given
+        String lastname = Utils.randomStringGenerator("Client_LastName_", 5);
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        request1.setLastname(lastname);
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        request2.setLastname(lastname);
+        clientHelper.createClient(request2);
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        request3.setLastname(lastname);
+        clientHelper.createClient(request3);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(lastname);
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(3);
+        assertThat(result.getContent().get(0).getExternalId().getValue()).isEqualTo(request3.getExternalId());
+        assertThat(result.getContent().get(1).getExternalId().getValue()).isEqualTo(request2.getExternalId());
+        assertThat(result.getContent().get(2).getExternalId().getValue()).isEqualTo(request1.getExternalId());
+    }
+
+    @Test
+    public void testClientSearchWorks_WithLastnameText_OrderedByIdAsc() {
+        // given
+        String lastname = Utils.randomStringGenerator("Client_LastName_", 5);
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        request1.setLastname(lastname);
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        request2.setLastname(lastname);
+        clientHelper.createClient(request2);
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        request3.setLastname(lastname);
+        clientHelper.createClient(request3);
+
+        SortOrder sortOrder = new SortOrder().property("id").direction(SortOrder.DirectionEnum.ASC);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(lastname, sortOrder);
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(3);
+        assertThat(result.getContent().get(0).getExternalId().getValue()).isEqualTo(request1.getExternalId());
+        assertThat(result.getContent().get(1).getExternalId().getValue()).isEqualTo(request2.getExternalId());
+        assertThat(result.getContent().get(2).getExternalId().getValue()).isEqualTo(request3.getExternalId());
+    }
+
+    @Test
+    public void testClientSearchWorks_ByExternalId() {
+        // given
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request2);
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request3);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(request2.getExternalId());
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(1);
+        assertThat(result.getContent().get(0).getExternalId().getValue()).isEqualTo(request2.getExternalId());
+    }
+
+    @Test
+    public void testClientSearchWorks_ByAccountNumber() {
+        // given
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        PostClientsResponse response2 = clientHelper.createClient(request2);
+        GetClientsClientIdResponse client2Data = ClientHelper.getClient(requestSpec, responseSpec,
+                Math.toIntExact(response2.getClientId()));
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request3);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(client2Data.getAccountNo());
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(1);
+        assertThat(result.getContent().get(0).getAccountNo()).isEqualTo(client2Data.getAccountNo());
+    }
+
+    @Test
+    public void testClientSearchWorks_ByDisplayName() {
+        // given
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request2);
+        String client2DisplayName = "%s %s".formatted(request2.getFirstname(), request2.getLastname());
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request3);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(client2DisplayName);
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(1);
+        assertThat(result.getContent().get(0).getDisplayName()).isEqualTo(client2DisplayName);
+    }
+
+    @Test
+    public void testClientSearchWorks_ByMobileNo() {
+        // given
+        PostClientsRequest request1 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request1);
+
+        PostClientsRequest request2 = ClientHelper.defaultClientCreationRequest();
+        request2.setMobileNo(Utils.randomNumberGenerator(8).toString());
+        clientHelper.createClient(request2);
+
+        PostClientsRequest request3 = ClientHelper.defaultClientCreationRequest();
+        clientHelper.createClient(request3);
+        // when
+        PageClientSearchData result = clientHelper.searchClients(request2.getMobileNo());
+        // then
+        assertThat(result.getTotalElements()).isEqualTo(1);
+        assertThat(result.getContent().get(0).getMobileNo()).isEqualTo(request2.getMobileNo());
+    }

Review Comment:
   done



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

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