From adaac8958324439c01527b6cadbd89eb59f05056 Mon Sep 17 00:00:00 2001 From: Jose Alberto Hernandez Date: Sun, 10 Jul 2022 14:53:13 -0500 Subject: [PATCH] Fix makerchecker inbox list group by error --- .../service/AuditReadPlatformServiceImpl.java | 2 +- .../integrationtests/CurrenciesTest.java | 2 +- .../integrationtests/MakercheckerTest.java | 59 +++++++++++++++++++ .../common/commands/MakercheckersHelper.java | 51 ++++++++++++++++ 4 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 integration-tests/src/test/java/org/apache/fineract/integrationtests/MakercheckerTest.java create mode 100644 integration-tests/src/test/java/org/apache/fineract/integrationtests/common/commands/MakercheckersHelper.java diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java index 481c20232..8aa3bf7a6 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/service/AuditReadPlatformServiceImpl.java @@ -201,7 +201,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService { @Override public Collection retrieveAllEntriesToBeChecked(final SQLBuilder extraCriteria, final boolean includeJson) { extraCriteria.addCriteria("aud.processing_result_enum = ", 2); - return retrieveEntries("makerchecker", extraCriteria, " group by aud.id order by aud.id", includeJson); + return retrieveEntries("makerchecker", extraCriteria, " order by aud.id, mk.username", includeJson); } private Collection retrieveEntries(final String useType, final SQLBuilder extraCriteria, final String groupAndOrderBySQL, diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/CurrenciesTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/CurrenciesTest.java index 583de979f..0125dfb5c 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/CurrenciesTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/CurrenciesTest.java @@ -32,7 +32,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -@SuppressWarnings({ "unused", "rawtypes" }) +@SuppressWarnings({ "unused" }) public class CurrenciesTest { private ResponseSpecification responseSpec; diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/MakercheckerTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/MakercheckerTest.java new file mode 100644 index 000000000..1b7faf84e --- /dev/null +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/MakercheckerTest.java @@ -0,0 +1,59 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.integrationtests; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.builder.ResponseSpecBuilder; +import io.restassured.http.ContentType; +import io.restassured.specification.RequestSpecification; +import io.restassured.specification.ResponseSpecification; +import java.util.ArrayList; +import org.apache.fineract.client.models.GetMakerCheckerResponse; +import org.apache.fineract.integrationtests.common.Utils; +import org.apache.fineract.integrationtests.common.commands.MakercheckersHelper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +@SuppressWarnings({ "unused" }) +public class MakercheckerTest { + + private ResponseSpecification responseSpec; + private RequestSpecification requestSpec; + private MakercheckersHelper makercheckersHelper; + + @BeforeEach + public void setup() { + Utils.initializeRESTAssured(); + this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); + this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); + this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); + this.makercheckersHelper = new MakercheckersHelper(this.requestSpec, this.responseSpec); + } + + @Test + public void testMakerchekerInboxList() { + // given + // when + final ArrayList makerCheckerList = this.makercheckersHelper.getMakerCheckerList(); + + assertNotNull(makerCheckerList); + } +} diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/commands/MakercheckersHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/commands/MakercheckersHelper.java new file mode 100644 index 000000000..27996ce45 --- /dev/null +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/commands/MakercheckersHelper.java @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.integrationtests.common.commands; + +import com.google.gson.Gson; +import com.linecorp.armeria.internal.shaded.guava.reflect.TypeToken; +import io.restassured.specification.RequestSpecification; +import io.restassured.specification.ResponseSpecification; +import java.lang.reflect.Type; +import java.util.ArrayList; +import org.apache.fineract.client.models.GetMakerCheckerResponse; +import org.apache.fineract.client.util.JSON; +import org.apache.fineract.integrationtests.common.Utils; + +public class MakercheckersHelper { + + private static final Gson GSON = new JSON().getGson(); + + private static final String MAKERCHECKER_URL = "/fineract-provider/api/v1/makercheckers?" + Utils.TENANT_IDENTIFIER; + + private final RequestSpecification requestSpec; + private final ResponseSpecification responseSpec; + + public MakercheckersHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { + this.requestSpec = requestSpec; + this.responseSpec = responseSpec; + } + + public ArrayList getMakerCheckerList() { + final String response = Utils.performServerGet(this.requestSpec, this.responseSpec, MAKERCHECKER_URL); + Type makerCheckerList = new TypeToken>() {}.getType(); + return GSON.fromJson(response, makerCheckerList); + } + +}