Add missing ReportsTest Swagger IT (see FINERACT-1173 & FINERACT-1263)
This commit is contained in:
committed by
Aleksandar Vidakovic
parent
b29558062c
commit
834d8550fb
@@ -14,3 +14,6 @@
|
|||||||
**/client/*.java
|
**/client/*.java
|
||||||
!**/client/CollectionFormats.java
|
!**/client/CollectionFormats.java
|
||||||
!**/client/StringUtil.java
|
!**/client/StringUtil.java
|
||||||
|
|
||||||
|
# https://issues.apache.org/jira/browse/FINERACT-1263
|
||||||
|
**/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);
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -105,7 +105,7 @@ public class RunreportsApiResource {
|
|||||||
+ "\n" + "\n"
|
+ "\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")
|
+ "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({
|
@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,
|
public Response runReport(@PathParam("reportName") @Parameter(description = "reportName") final String reportName,
|
||||||
@Context final UriInfo uriInfo,
|
@Context final UriInfo uriInfo,
|
||||||
@DefaultValue("false") @QueryParam("isSelfServiceUserReport") @Parameter(description = "isSelfServiceUserReport") final boolean isSelfServiceUserReport) {
|
@DefaultValue("false") @QueryParam("isSelfServiceUserReport") @Parameter(description = "isSelfServiceUserReport") final boolean isSelfServiceUserReport) {
|
||||||
|
|||||||
+8
-11
@@ -19,26 +19,23 @@
|
|||||||
package org.apache.fineract.infrastructure.dataqueries.api;
|
package org.apache.fineract.infrastructure.dataqueries.api;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
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.ResultsetColumnHeaderData;
|
||||||
import org.apache.fineract.infrastructure.dataqueries.data.ResultsetRowData;
|
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 {
|
final class RunreportsApiResourceSwagger {
|
||||||
|
|
||||||
private RunreportsApiResourceSwagger() {
|
private RunreportsApiResourceSwagger() {}
|
||||||
|
|
||||||
}
|
@Schema
|
||||||
|
public static final class RunReportsResponse {
|
||||||
|
|
||||||
@Schema(description = "GetReportNameResponse")
|
private RunReportsResponse() {}
|
||||||
public static final class GetReportNameResponse {
|
|
||||||
|
|
||||||
private GetReportNameResponse() {
|
public List<ResultsetColumnHeaderData> columnHeaders;
|
||||||
|
public List<ResultsetRowData> data;
|
||||||
}
|
|
||||||
|
|
||||||
public ResultsetColumnHeaderData columnHeaders;
|
|
||||||
public ResultsetRowData row;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+58
@@ -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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user