Skip to content

Commit 76982d9

Browse files
author
TanyaEf
committed
Fixed bugs #104, #105
1 parent 8bde095 commit 76982d9

File tree

4 files changed

+55
-9
lines changed

4 files changed

+55
-9
lines changed

src/integration-test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportingServiceIT.java

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.jaspersoft.jasperserver.jaxrs.client.core.JasperserverRestClient;
44
import com.jaspersoft.jasperserver.jaxrs.client.core.RestClientConfiguration;
55
import com.jaspersoft.jasperserver.jaxrs.client.core.operationresult.OperationResult;
6+
import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionDescriptor;
7+
import com.jaspersoft.jasperserver.jaxrs.client.dto.reports.ReportExecutionRequest;
68
import java.io.InputStream;
79
import junit.framework.Assert;
810
import org.testng.annotations.AfterMethod;
@@ -24,7 +26,7 @@ public void before() {
2426
}
2527

2628
@Test
27-
public void should_return_proper_entity_if_pass_jrprint_report_output_format() {
29+
public void should_return_proper_entity_if_pass_pdf_report_output_format() {
2830

2931
/** When **/
3032
OperationResult<InputStream> result = client
@@ -44,6 +46,50 @@ public void should_return_proper_entity_if_pass_jrprint_report_output_format() {
4446

4547
}
4648

49+
@Test
50+
public void should_return_proper_entity_without_numbers_of_pages() {
51+
52+
/** When **/
53+
OperationResult<InputStream> result = client
54+
.authenticate("superuser", "superuser")
55+
.reportingService()
56+
.report("/organizations/organization_1/adhoc/topics/Cascading_multi_select_topic")
57+
.prepareForRun(ReportOutputFormat.PDF)
58+
.parameter("Cascading_state_multi_select", "CA")
59+
.parameter("Cascading_state_multi_select", "OR", "WA")
60+
.parameter("Cascading_name_single_select", "Adams-Steen Transportation Holdings")
61+
.parameter("Country_multi_select", "USA")
62+
.run();
63+
64+
InputStream entity = result.getEntity();
65+
/** Then **/
66+
Assert.assertNotNull(entity);
67+
68+
}
69+
70+
@Test
71+
public void should_return_proper_entity_in_asunc_mode() {
72+
73+
/** When **/
74+
ReportExecutionRequest request = new ReportExecutionRequest();
75+
request.setReportUnitUri("/organizations/organization_1/adhoc/topics/Cascading_multi_select_topic");
76+
request
77+
.setAsync(true) //this means that report will be run on server asynchronously
78+
.setOutputFormat(ReportOutputFormat.HTML); //report can be requested in different formats e.g. html, pdf, etc.
79+
80+
81+
82+
83+
OperationResult<ReportExecutionDescriptor> operationResult =client.authenticate("superuser", "superuser").
84+
reportingService()
85+
.newReportExecutionRequest(request);
86+
87+
ReportExecutionDescriptor reportExecutionDescriptor = operationResult.getEntity();
88+
/** Then **/
89+
Assert.assertNotNull(reportExecutionDescriptor);
90+
91+
}
92+
4793
@AfterMethod
4894
public void after() {
4995
client = null;

src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/ReportsAdapter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,8 @@ public RunReportAdapter prepareForRun(ReportOutputFormat format, PageRange range
5858
return new RunReportAdapter(sessionStorage, reportUnitUri, format, range);
5959
}
6060

61+
public RunReportAdapter prepareForRun(ReportOutputFormat format){
62+
return new RunReportAdapter(sessionStorage, reportUnitUri, format);
63+
}
64+
6165
}

src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/reporting/RunReportAdapter.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,14 @@
3939

4040
import static java.util.regex.Pattern.compile;
4141

42-
/**
43-
* @author
44-
* @author Tetiana Iefimenko
45-
* */
4642
public class RunReportAdapter extends AbstractAdapter {
4743

4844
private final MultivaluedMap<String, String> params;
4945
private final String reportUnitUri;
5046
private final ReportOutputFormat format;
5147
private String[] pages;
5248

53-
private RunReportAdapter(SessionStorage sessionStorage, String reportUnitUri, ReportOutputFormat format) {
49+
public RunReportAdapter(SessionStorage sessionStorage, String reportUnitUri, ReportOutputFormat format) {
5450
super(sessionStorage);
5551
this.params = new MultivaluedHashMap<String, String>();
5652
this.reportUnitUri = reportUnitUri;

src/main/java/com/jaspersoft/jasperserver/jaxrs/client/dto/reports/ReportExecutionRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public String getOutputFormat() {
119119
return outputFormat;
120120
}
121121

122-
public ReportExecutionRequest setOutputFormat(String outputFormat) {
123-
this.outputFormat = outputFormat;
122+
public ReportExecutionRequest setOutputFormat(ReportOutputFormat outputFormat) {
123+
this.outputFormat = outputFormat.toString().toLowerCase();
124124
return this;
125125
}
126126

@@ -315,7 +315,7 @@ public Builder setTransformerKey(String transformerKey) {
315315
* <b>Required</b>
316316
*/
317317
public Builder setOutputFormat(ReportOutputFormat outputFormat) {
318-
request.setOutputFormat(outputFormat.name());
318+
request.setOutputFormat(outputFormat);
319319
return this;
320320
}
321321

0 commit comments

Comments
 (0)