This is an automated email from the ASF dual-hosted git repository.
aleks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new 834d855 Add missing ReportsTest Swagger IT (see FINERACT-1173 &
FINERACT-1263)
834d855 is described below
commit 834d8550fb97288caa79891ef906bd02d0da59fb
Author: Michael Vorburger <[email protected]>
AuthorDate: Sat Nov 21 13:15:13 2020 +0100
Add missing ReportsTest Swagger IT (see FINERACT-1173 & FINERACT-1263)
---
fineract-client/.openapi-generator-ignore | 3 +
.../fineract/client/services/RunReportsApi.java | 65 ++++++++++++++++++++++
.../dataqueries/api/RunreportsApiResource.java | 2 +-
.../api/RunreportsApiResourceSwagger.java | 19 +++----
.../integrationtests/client/ReportsTest.java | 58 +++++++++++++++++++
5 files changed, 135 insertions(+), 12 deletions(-)
diff --git a/fineract-client/.openapi-generator-ignore
b/fineract-client/.openapi-generator-ignore
index 8a62e9a..d28fd23 100644
--- a/fineract-client/.openapi-generator-ignore
+++ b/fineract-client/.openapi-generator-ignore
@@ -14,3 +14,6 @@
**/client/*.java
!**/client/CollectionFormats.java
!**/client/StringUtil.java
+
+# https://issues.apache.org/jira/browse/FINERACT-1263
+**/services/RunReportsApi.java
diff --git
a/fineract-client/src/main/java/org/apache/fineract/client/services/RunReportsApi.java
b/fineract-client/src/main/java/org/apache/fineract/client/services/RunReportsApi.java
new file mode 100644
index 0000000..06817a3
--- /dev/null
+++
b/fineract-client/src/main/java/org/apache/fineract/client/services/RunReportsApi.java
@@ -0,0 +1,65 @@
+/**
+ * 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.client.services;
+
+import java.util.Map;
+import okhttp3.ResponseBody;
+import org.apache.fineract.client.models.RunReportsResponse;
+import retrofit2.Call;
+import retrofit2.http.GET;
+import retrofit2.http.QueryMap;
+
+// https://issues.apache.org/jira/browse/FINERACT-1263
+public interface RunReportsApi {
+
+ /**
+ * Running a Report This resource allows you to run and receive output
from pre-defined Apache Fineract reports.
+ * Reports can also be used to provide data for searching and workflow
functionality. The default output is a JSON
+ * formatted \"Generic Resultset\". The Generic Resultset
contains Column Heading as well as Data
+ * information. However, you can export to CSV format by simply adding
\"&exportCSV=true\" to the
+ * end of your URL. If Pentaho reports have been pre-defined, they can
also be run through this resource. Pentaho
+ * reports can return HTML, PDF or CSV formats. The Apache Fineract
reference application uses a JQuery plugin
+ * called stretchy reporting which, itself, uses this reports resource to
provide a pretty flexible reporting User
+ * Interface (UI). Example Requests:
runreports/Client%20Listing?R_officeId=1
+ * runreports/Client%20Listing?R_officeId=1&exportCSV=true
+ *
runreports/OfficeIdSelectOne?R_officeId=1&parameterType=true
+ *
runreports/OfficeIdSelectOne?R_officeId=1&parameterType=true&exportCSV=true
+ *
runreports/Expected%20Payments%20By%20Date%20-%20Formatted?R_endDate=2013-04-30&R_loanOfficerId=-1&R_officeId=1&R_startDate=2013-04-16&output-type=HTML&R_officeId=1
+ *
runreports/Expected%20Payments%20By%20Date%20-%20Formatted?R_endDate=2013-04-30&R_loanOfficerId=-1&R_officeId=1&R_startDate=2013-04-16&output-type=XLS&R_officeId=1
+ *
runreports/Expected%20Payments%20By%20Date%20-%20Formatted?R_endDate=2013-04-30&R_loanOfficerId=-1&R_officeId=1&R_startDate=2013-04-16&output-type=CSV&R_officeId=1
+ *
runreports/Expected%20Payments%20By%20Date%20-%20Formatted?R_endDate=2013-04-30&R_loanOfficerId=-1&R_officeId=1&R_startDate=2013-04-16&output-type=PDF&R_officeId=1
+ *
+ * @param reportName
+ * reportName (required)
+ * @param isSelfServiceUserReport
+ * isSelfServiceUserReport (optional, default to false)
+ * @return Call<GetReportNameResponse>
+ */
+ @GET("runreports/{reportName}")
+ Call<RunReportsResponse>
runReportGetData(@retrofit2.http.Path("reportName") String reportName,
+ @QueryMap Map<String, String> parameters,
@retrofit2.http.Query("isSelfServiceUserReport") Boolean
isSelfServiceUserReport);
+
+ /**
+ * Run Report which returns a response such as a PDF, CSV, XLS or XSLX
file.
+ */
+ @GET("runreports/{reportName}")
+ Call<ResponseBody> runReportGetFile(@retrofit2.http.Path("reportName")
String reportName, @QueryMap Map<String, String> parameters,
+ @retrofit2.http.Query("isSelfServiceUserReport") Boolean
isSelfServiceUserReport);
+
+}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResource.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResource.java
index cf11232..d257103 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResource.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResource.java
@@ -105,7 +105,7 @@ public class RunreportsApiResource {
+ "\n" + "\n"
+
"runreports/Expected%20Payments%20By%20Date%20-%20Formatted?R_endDate=2013-04-30&R_loanOfficerId=-1&R_officeId=1&R_startDate=2013-04-16&output-type=PDF&R_officeId=1")
@ApiResponses({
- @ApiResponse(responseCode = "200", description = "OK", content =
@Content(schema = @Schema(implementation =
RunreportsApiResourceSwagger.GetReportNameResponse.class))) })
+ @ApiResponse(responseCode = "200", description = "OK", content =
@Content(schema = @Schema(implementation =
RunreportsApiResourceSwagger.RunReportsResponse.class))) })
public Response runReport(@PathParam("reportName") @Parameter(description
= "reportName") final String reportName,
@Context final UriInfo uriInfo,
@DefaultValue("false") @QueryParam("isSelfServiceUserReport")
@Parameter(description = "isSelfServiceUserReport") final boolean
isSelfServiceUserReport) {
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResourceSwagger.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResourceSwagger.java
index 63fb562..f91ab04 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResourceSwagger.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResourceSwagger.java
@@ -19,26 +19,23 @@
package org.apache.fineract.infrastructure.dataqueries.api;
import io.swagger.v3.oas.annotations.media.Schema;
+import java.util.List;
import
org.apache.fineract.infrastructure.dataqueries.data.ResultsetColumnHeaderData;
import org.apache.fineract.infrastructure.dataqueries.data.ResultsetRowData;
/**
- * Created by sanyam on 5/8/17.
+ * Created by sanyam on 5/8/17. Fixed ;) by Michael Vorburger.ch on 2020/11/21.
*/
final class RunreportsApiResourceSwagger {
- private RunreportsApiResourceSwagger() {
+ private RunreportsApiResourceSwagger() {}
- }
-
- @Schema(description = "GetReportNameResponse")
- public static final class GetReportNameResponse {
-
- private GetReportNameResponse() {
+ @Schema
+ public static final class RunReportsResponse {
- }
+ private RunReportsResponse() {}
- public ResultsetColumnHeaderData columnHeaders;
- public ResultsetRowData row;
+ public List<ResultsetColumnHeaderData> columnHeaders;
+ public List<ResultsetRowData> data;
}
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ReportsTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ReportsTest.java
new file mode 100644
index 0000000..8eebfe9
--- /dev/null
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ReportsTest.java
@@ -0,0 +1,58 @@
+/**
+ * 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 java.util.Map;
+import okhttp3.MediaType;
+import okhttp3.ResponseBody;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Integration Test for /staff API.
+ *
+ * @author Michael Vorburger.ch
+ */
+public class ReportsTest extends IntegrationTest {
+
+ @Test
+ void listReports() {
+ assertThat(ok(fineract().reports.retrieveReportList())).hasSize(115);
+ }
+
+ @Test
+ void runClientListingTableReport() {
+ assertThat(ok(fineract().reportsRun.runReportGetData("Client Listing",
Map.of("R_officeId", "1"), false)).getColumnHeaders().get(0)
+ .getColumnName()).isEqualTo("Office/Branch");
+ }
+
+ @Test
+ void runExpectedPaymentsPentahoReportWithoutPlugin() {
+ assertThat(fineract().reportsRun.runReportGetFile("Expected Payments
By Date - Formatted", Map.of("R_endDate", "2013-04-30",
+ "R_loanOfficerId", "-1", "R_officeId", "1", "R_startDate",
"2013-04-16", "output-type", "PDF"), false)).hasHttpStatus(404);
+ }
+
+ @Test
+ @Disabled
+ void runExpectedPaymentsPentahoReport() {
+ ResponseBody r = ok(fineract().reportsRun.runReportGetFile("Expected
Payments By Date - Formatted", Map.of("R_endDate",
+ "2013-04-30", "R_loanOfficerId", "-1", "R_officeId", "1",
"R_startDate", "2013-04-16", "output-type", "PDF"), false));
+
assertThat(r.contentType()).isEqualTo(MediaType.get("application/pdf"));
+ }
+}