summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportHandlerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportHandlerTest.java')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportHandlerTest.java448
1 files changed, 441 insertions, 7 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportHandlerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportHandlerTest.java
index f44739d1..35f7700c 100644
--- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportHandlerTest.java
+++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportHandlerTest.java
@@ -44,9 +44,17 @@ package org.onap.portalsdk.analytics.model;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
@@ -61,10 +69,12 @@ import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.onap.portalsdk.analytics.controller.WizardSequence;
+import org.onap.portalsdk.analytics.error.RaptorException;
import org.onap.portalsdk.analytics.model.base.IdNameValue;
import org.onap.portalsdk.analytics.model.definition.ReportDefinition;
import org.onap.portalsdk.analytics.model.runtime.ReportRuntime;
import org.onap.portalsdk.analytics.system.AppUtils;
+import org.onap.portalsdk.analytics.system.ConnectionUtils;
import org.onap.portalsdk.analytics.system.DbUtils;
import org.onap.portalsdk.analytics.system.Globals;
import org.onap.portalsdk.analytics.system.IAppUtils;
@@ -74,15 +84,23 @@ import org.onap.portalsdk.analytics.view.DataValue;
import org.onap.portalsdk.analytics.view.ReportColumnHeaderRows;
import org.onap.portalsdk.analytics.view.ReportData;
import org.onap.portalsdk.analytics.view.ReportRowHeaderCols;
+import org.onap.portalsdk.analytics.xmlobj.DataColumnList;
+import org.onap.portalsdk.analytics.xmlobj.DataColumnType;
import org.onap.portalsdk.analytics.xmlobj.DataSourceList;
+import org.onap.portalsdk.analytics.xmlobj.DataSourceType;
+import org.onap.portalsdk.analytics.xmlobj.FormatList;
+import org.onap.portalsdk.analytics.xmlobj.FormatType;
+import org.onap.portalsdk.analytics.xmlobj.SemaphoreList;
+import org.onap.portalsdk.analytics.xmlobj.SemaphoreType;
import org.owasp.esapi.ESAPI;
import org.owasp.esapi.Encoder;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
+
@RunWith(PowerMockRunner.class)
-@PrepareForTest({Globals.class, DbUtils.class, ESAPI.class, IAppUtils.class, AppUtils.class})
+@PrepareForTest({Globals.class, DbUtils.class, ESAPI.class, IAppUtils.class, AppUtils.class, ConnectionUtils.class})
public class ReportHandlerTest {
private ReportHandler reportHandler;
@@ -144,6 +162,18 @@ public class ReportHandlerTest {
@Mock
File file;
+ @Mock
+ Connection connection;
+
+ @Mock
+ Statement statement;
+
+ @Mock
+ ResultSet resultSet;
+
+ @Mock
+ ResultSetMetaData resultSetMetaData;
+
private String REPORT_ID = "1000";
@Before
@@ -154,6 +184,7 @@ public class ReportHandlerTest {
PowerMockito.mockStatic(IAppUtils.class);
PowerMockito.mockStatic(ESAPI.class);
PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(ConnectionUtils.class);
PowerMockito.whenNew(File.class).withAnyArguments().thenReturn(file);
Mockito.when(file.createNewFile()).thenReturn(true);
@@ -246,6 +277,140 @@ public class ReportHandlerTest {
Mockito.verify(reportHandler, Mockito.times(1)).saveAsExcelFile(httpServletRequest, reportData, null, "Report 1", "Report 1 Desc");
}
+
+
+
+
+
+ @Test
+ public void testSaveAsExcelFile_case2() throws Exception {
+ String saveOutput = "";
+ ReportData reportData = prepareReportData();
+ DataSourceList dataSourceList = new DataSourceList();
+
+ List<DataSourceType> listDataSourceType = dataSourceList.getDataSource();
+
+ DataSourceType dataSourceType1 = new DataSourceType();
+
+ DataColumnList dataColumnList1 = new DataColumnList();
+ List<DataColumnType> listDataColumnType1 = dataColumnList1.getDataColumn();
+
+ DataColumnType dataColumnType1 = new DataColumnType();
+ dataColumnType1.setSemaphoreId("Id1");
+ listDataColumnType1.add(dataColumnType1);
+
+ dataSourceType1.setDataColumnList(dataColumnList1);
+
+ listDataSourceType.add(dataSourceType1);
+
+
+ reportData.setReportDataList(prepareDataRowList());
+
+ PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports");
+ PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true);
+ PowerMockito.when(Globals.getShowDescrAtRuntime()).thenReturn(true);
+ PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true);
+ PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true);
+ PowerMockito.when(Globals.getPrintFooterInDownload()).thenReturn(true);
+ PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true);
+ PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false);
+
+ ArrayList <IdNameValue> paramList = null;
+ paramList = new ArrayList<IdNameValue>();
+ paramList.add(new IdNameValue("Name", "Portal SDK"));
+ paramList.add(new IdNameValue("Org", "ONAP"));
+ paramList.add(new IdNameValue("Status", "Active"));
+
+ Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList);
+
+ String para = "";
+
+ int i=1;
+ while(i<20) {
+ para = para + "<p>This is a paragraph.</p>" + "\n" + "<p>This is another paragraph.</p>" + "\n";
+ i++;
+ }
+
+ Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn(para);
+ Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList);
+ Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3);
+ Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB);
+ Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1");
+ Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report");
+ Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor");
+ Mockito.when(iAppUtils.getTempFolderPath()).thenReturn("");
+ //ReflectionTestUtils.setField(reportData, "reportRowHeaderCols", reportRowHeaderCols);
+
+
+ SemaphoreList semaphoreList = new SemaphoreList();
+ List<SemaphoreType> listSemaphoreType = semaphoreList.getSemaphore();
+
+ SemaphoreType st1 = new SemaphoreType();
+ SemaphoreType st2 = new SemaphoreType();
+ FormatList formatList = new FormatList();
+
+ List<FormatType> listFormatType = formatList.getFormat();
+
+ FormatType formatType1 = new FormatType();
+ FormatType formatType2 = new FormatType();
+
+ listFormatType.add(formatType1);
+
+ formatType2.setBgColor("blue");
+ formatType2.setFontColor("black");
+ formatType2.setBold(true);
+ formatType2.setItalic(true);
+ formatType2.setFontFace("Calibri");
+ formatType2.setItalic(true);
+ formatType2.setUnderline(true);
+ formatType2.setUnderline(true);
+ formatType2.setFontSize("20");
+
+ listFormatType.add(formatType2);
+
+
+ st1.setSemaphoreName("Name1");
+ st1.setSemaphoreId("Id1");
+
+ st1.setFormatList(formatList);
+
+ st2.setSemaphoreName("Name2");
+ st2.setSemaphoreId("Id2");
+
+ st2.setFormatList(formatList);
+ listSemaphoreType.add(st1);
+ listSemaphoreType.add(st2);
+
+ mockHttpAttribute(AppConstants.RI_REPORT_ID, REPORT_ID);
+
+ Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList);
+ Mockito.when(reportRuntime.getSemaphoreList()).thenReturn(semaphoreList);
+ Mockito.when(reportDefinition.addSemaphore(Mockito.anyObject(), Mockito.anyObject())).thenReturn(st1);
+
+
+
+ saveOutput = reportHandler.saveAsExcelFile(httpServletRequest, reportData, null, "Report 1", "Report 1 Desc");
+ //Assert.assertNotNull(saveOutput);
+ Mockito.verify(reportHandler, Mockito.times(1)).saveAsExcelFile(httpServletRequest, reportData, null, "Report 1", "Report 1 Desc");
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
private ArrayList<DataRow> prepareDataRowList(){
ArrayList <DataRow> alDataRow = new ArrayList<DataRow>();
@@ -327,7 +492,6 @@ public class ReportHandlerTest {
DataSourceList dataSourceList = new DataSourceList();
reportData.setReportDataList(prepareDataRowList());
-
PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports");
PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true);
PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true);
@@ -422,8 +586,8 @@ public class ReportHandlerTest {
}
-
-
+
+
@Test
public void testCreateExcel2007FileContent_case1() throws Exception {
@@ -477,11 +641,96 @@ public class ReportHandlerTest {
*/
reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 3);
-
}
+
+
+
@Test
- public void testCreateCSVFileContent_case1() throws Exception {
+ public void testCreateExcel2007FileContent_case2() throws Exception {
+
+
+ ReportData reportData = prepareReportData();
+
+ DataSourceList dataSourceList = new DataSourceList();
+ reportData.setReportDataList(prepareDataRowList());
+
+
+ PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports");
+ PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true);
+ PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true);
+
+ ArrayList <IdNameValue> paramList = null;
+ paramList = new ArrayList<IdNameValue>();
+ paramList.add(new IdNameValue("Name", "Portal SDK"));
+ paramList.add(new IdNameValue("Org", "ONAP"));
+ paramList.add(new IdNameValue("Status", "Active"));
+
+ Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList);
+
+ Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel");
+ Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal");
+ Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc");
+ Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList);
+
+ Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID);
+
+
+ Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3);
+ Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB);
+
+ Mockito.when(httpSession.getAttribute("drilldown_index")).thenReturn("1");
+ Mockito.when(httpSession.getAttribute("TITLE_1")).thenReturn("ONAP Report");
+ Mockito.when(httpSession.getAttribute("SUBTITLE_1")).thenReturn("ONAP Portal SDK Raptor");
+
+ Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn(REPORT_ID);
+
+
+ Map<String, ReportRuntime> mapReportRuntime = new TreeMap<String, ReportRuntime>();
+ Map<String, ReportData> mapReportData = new TreeMap<String, ReportData>();
+
+ mapReportRuntime.put("ReportRuntime#1", reportRuntime);
+ mapReportData.put("ReportData#1", reportData);
+
+ Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(mapReportRuntime);
+
+ Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData);
+
+ Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'");
+ Mockito.when(reportRuntime.getTemplateFile()).thenReturn("");
+
+ Mockito.when(iAppUtils.getTempFolderPath()).thenReturn("");
+
+ Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream);
+
+ PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true);
+
+ /*
+ PowerMockito.when(Globals.getShowDescrAtRuntime()).thenReturn(true);
+ PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true);
+ PowerMockito.when(Globals.getPrintFooterInDownload()).thenReturn(true);
+ PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true);
+ PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false);
+ */
+ reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 3);
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @Test
+ public void testCreateCSVFileContent_WithoutSql_case1() throws Exception {
ReportData reportData = prepareReportData();
Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal");
@@ -525,13 +774,66 @@ public class ReportHandlerTest {
reportHandler.createCSVFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse);
}
+ @Test
+ public void testCreateCSVFileContent_WithSql_case1() throws Exception {
+ ReportData reportData = prepareReportData();
+
+ Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal");
+
+ mockHttpAttribute("pdfAttachmentKey", "PdfKey");
+ mockHttpAttribute("log_id", "Log#1234");
+ mockHttpAttribute("user_id", "demo");
+ mockHttpAttribute("raw", "false");
+
+ Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel");
+ Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal");
+ Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc");
+
+ mockHttpAttribute(AppConstants.RI_REPORT_SQL_WHOLE, "select column1 from table1 where column2='test'");
+
+ PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false);
+ PowerMockito.when(Globals.getFooterFirstLine()).thenReturn("Footer First Line");
+ PowerMockito.when(Globals.getFooterSecondLine()).thenReturn("Footer Second Line");
+ PowerMockito.when(Globals.getPrintParamsInCSVDownload()).thenReturn(true);
+ PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true);
+
+ Mockito.when(ConnectionUtils.getConnection(Mockito.anyString())).thenReturn(connection);
+ Mockito.when(connection.createStatement()).thenReturn(statement);
+
+ Mockito.when(statement.executeQuery(Mockito.anyString())).thenReturn(resultSet);
+ Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
+ Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(1);
+ Mockito.when(resultSet.next()).thenReturn(true).thenReturn(false);
+
+ Mockito.when(resultSetMetaData.getColumnLabel(Mockito.anyInt())).thenReturn("column1");
+ Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("value1");
+
+
+ ArrayList <IdNameValue> paramList = null;
+ paramList = new ArrayList<IdNameValue>();
+ paramList.add(new IdNameValue("Name", "Portal SDK"));
+ paramList.add(new IdNameValue("Org", "ONAP"));
+ paramList.add(new IdNameValue("Status", "Active"));
+
+ Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList);
+ Mockito.when(encoder.canonicalize(Mockito.anyString())).thenReturn("(column1='Y'~column2='N')");
+
+ Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB);
+
+
+
+ Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream);
+
+ reportHandler.createCSVFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse);
+ }
+
private void mockHttpAttribute(String attributeName, String attributeValue) {
Mockito.when(httpServletRequest.getAttribute(attributeName)).thenReturn(attributeValue);
}
@Test
- public void testCreateHTMLFileContent() throws Exception {
+ public void testCreateHTMLFileContent_WithoutSql_case1() throws Exception {
ReportData reportData = prepareReportData();
@@ -577,7 +879,139 @@ public class ReportHandlerTest {
reportHandler.createHTMLFileContent(iowriter, reportData, reportRuntime, "", httpServletRequest, httpServletResponse);
}
+
+ @Test(expected =RaptorException.class)
+ public void testCreateHTMLFileContent_WithSql_case1() throws Exception {
+
+ ReportData reportData = prepareReportData();
+
+ Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal");
+
+ mockHttpAttribute("pdfAttachmentKey", "PdfKey");
+ mockHttpAttribute("log_id", "Log#1234");
+ mockHttpAttribute("user_id", "demo");
+ mockHttpAttribute("raw", "false");
+ Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel");
+ Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal");
+ Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc");
+
+ mockHttpAttribute(AppConstants.RI_REPORT_SQL_WHOLE, "select column1 from table1 where column2='test'");
+
+ PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true);
+ PowerMockito.when(Globals.getFooterFirstLine()).thenReturn("Footer First Line");
+ PowerMockito.when(Globals.getFooterSecondLine()).thenReturn("Footer Second Line");
+ PowerMockito.when(Globals.getPrintParamsInCSVDownload()).thenReturn(true);
+ PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true);
+
+ Mockito.when(ConnectionUtils.getConnection(Mockito.anyString())).thenReturn(connection);
+ Mockito.when(connection.createStatement()).thenReturn(statement);
+
+ Mockito.when(statement.executeQuery(Mockito.anyString())).thenReturn(resultSet);
+ Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
+ Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(1);
+ Mockito.when(resultSet.next()).thenReturn(true).thenReturn(false);
+
+ Mockito.when(resultSetMetaData.getColumnLabel(Mockito.anyInt())).thenReturn("column1");
+ Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("value1");
+
+ ArrayList <IdNameValue> paramList = null;
+ paramList = new ArrayList<IdNameValue>();
+ paramList.add(new IdNameValue("Name", "Portal SDK"));
+ paramList.add(new IdNameValue("Org", "ONAP"));
+ paramList.add(new IdNameValue("Status", "Active"));
+
+ Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList);
+ Mockito.when(encoder.canonicalize(Mockito.anyString())).thenReturn("(column1='Y'~column2='N')");
+
+ Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB);
+
+
+ //Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'");
+
+ Mockito.when(reportRuntime.getWholeSQL()).thenReturn("");
+
+ Mockito.when(httpServletResponse.getWriter()).thenReturn(printWriter);
+
+ Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream);
+
+ reportHandler.createHTMLFileContent(iowriter, reportData, reportRuntime, "select column1 from table1 where column2='test'", httpServletRequest, httpServletResponse);
+ }
+
+
+ @Test
+ public void testCreateFlatFileContent_case1() throws IOException, Exception {
+ ReportData reportData = prepareReportData();
+
+ Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal");
+
+ mockHttpAttribute("pdfAttachmentKey", "PdfKey");
+ mockHttpAttribute("log_id", "Log#1234");
+ mockHttpAttribute("user_id", "demo");
+ mockHttpAttribute("raw", "false");
+
+ Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel");
+ Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal");
+ Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc");
+
+ mockHttpAttribute(AppConstants.RI_REPORT_SQL_WHOLE, "select column1 from table1 where column2='test'");
+
+ PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true);
+ PowerMockito.when(Globals.getFooterFirstLine()).thenReturn("Footer First Line");
+ PowerMockito.when(Globals.getFooterSecondLine()).thenReturn("Footer Second Line");
+ PowerMockito.when(Globals.getPrintParamsInCSVDownload()).thenReturn(true);
+ PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true);
+
+ Mockito.when(ConnectionUtils.getConnection(Mockito.anyString())).thenReturn(connection);
+ Mockito.when(connection.createStatement()).thenReturn(statement);
+
+ Mockito.when(statement.executeQuery(Mockito.anyString())).thenReturn(resultSet);
+ Mockito.when(resultSet.next()).thenReturn(true).thenReturn(false);
+
+
+ ArrayList <IdNameValue> paramList = null;
+ paramList = new ArrayList<IdNameValue>();
+ paramList.add(new IdNameValue("Name", "Portal SDK"));
+ paramList.add(new IdNameValue("Org", "ONAP"));
+ paramList.add(new IdNameValue("Status", "Active"));
+
+
+ Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList);
+ Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB);
+ Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'");
+
+ Mockito.when(reportRuntime.loadReportData(Mockito.anyInt(), Mockito.anyString(), Mockito.anyInt(), Mockito.anyObject(), Mockito.anyBoolean())).thenReturn(reportData);
+
+ Mockito.when(httpServletResponse.getWriter()).thenReturn(printWriter);
+ Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream);
+
+ DataColumnType dataColumnType1 = new DataColumnType();
+
+ dataColumnType1.setTableId("reportaccess");
+ dataColumnType1.setDbColName("REP_ID");
+ dataColumnType1.setColName("REP_ID");
+ dataColumnType1.setDbColType("INTEGER");
+ dataColumnType1.setDisplayName("Report Id");
+
+ DataColumnType dataColumnType2 = new DataColumnType();
+
+ dataColumnType2.setTableId("reportaccess");
+ dataColumnType2.setDbColName("ORDER_NO");
+ dataColumnType2.setColName("ORDER_NO");
+ dataColumnType2.setDbColType("INTEGER");
+ dataColumnType2.setDisplayName("Order No");
+
+ List<DataColumnType> listDataColumnType = new ArrayList<DataColumnType>();
+ listDataColumnType.add(dataColumnType1);
+ listDataColumnType.add(dataColumnType2);
+
+ Mockito.when(reportRuntime.getAllColumns()).thenReturn(listDataColumnType);
+
+
+ reportHandler.createFlatFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "USER#1");
+
+ }
+
/*