我有一个主报告和两个子报告。我正在使用自定义数据源来获取报告内容。但在 jasper studio 中预览主报表时,仅显示一个子报表(以先出现的子报表为准)。
例如。仅显示report1.jrxml。如果我删除该子报表,则会显示report2.jrxml。
主.jrxml
<detail>
<band height="250">
<subreport runToBottom="true">
<reportElement positionType="Float" x="0" y="130" width="1960" height="120" uuid="89a9f872-756e-4c82-922d-537cfde30cca"/>
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
<subreportExpression><![CDATA["report1.jrxml"]]></subreportExpression>
</subreport>
</band>
<band height="250">
<subreport runToBottom="true">
<reportElement positionType="Float" x="0" y="90" width="1960" height="120" uuid="892c0849-9532-48cb-94c0-f2e87528232a"/>
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
<subreportExpression><![CDATA["report2.jrxml"]]></subreportExpression>
</subreport>
</band>
</detail>
Run Code Online (Sandbox Code Playgroud)
我已经尝试过以下方法:
我有一个带有私有静态方法的final类,它在另一个静态方法中调用
public final class GenerateResponse{
private static Map<String, String> getErrorDetails(JSONObject jsonObject) {
// implementation
}
public static String method1(params...){
Map<String, String> map = getErrorDetails(new JsonObject());
// implementation
}
}
Run Code Online (Sandbox Code Playgroud)
我需要模拟私有静态方法调用getErrorDetails(),但我的测试是调用实际方法.这是我的代码:
@RunWith(PowerMockRunner.class)
@PrepareForTest(GenerateResponse.class)
public class GenerateResponseTest{
@Test
public void testFrameQtcErrorResponse() throws Exception {
Map<String, String> errorDtls = new HashMap<String, String>();
PowerMockito.spy(GenerateResponse.class);
PowerMockito.doReturn(errorDtls).when(GenerateResponse.class, "getErrorDetails", JSONObject.class);
String response = GenerateResponse.method1(params...);
}
Run Code Online (Sandbox Code Playgroud)