diff options
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.java | 2758 |
1 files changed, 2390 insertions, 368 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 6a21dd10..77950ae7 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 @@ -36,11 +36,8 @@ * */ - package org.onap.portalsdk.analytics.model; - - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -52,6 +49,7 @@ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.Statement; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -83,7 +81,10 @@ import org.onap.portalsdk.analytics.view.DataRow; 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.ReportDataRows; import org.onap.portalsdk.analytics.view.ReportRowHeaderCols; +import org.onap.portalsdk.analytics.view.RowHeader; +import org.onap.portalsdk.analytics.view.RowHeaderCol; import org.onap.portalsdk.analytics.xmlobj.DataColumnList; import org.onap.portalsdk.analytics.xmlobj.DataColumnType; import org.onap.portalsdk.analytics.xmlobj.DataSourceList; @@ -98,43 +99,43 @@ 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, ConnectionUtils.class}) +@PrepareForTest({ Globals.class, DbUtils.class, ESAPI.class, IAppUtils.class, AppUtils.class, ConnectionUtils.class, + ReportLoader.class, HashMap.class }) public class ReportHandlerTest { private ReportHandler reportHandler; - + @Mock HttpServletRequest httpServletRequest; @Mock HttpServletResponse httpServletResponse; - + @Mock ServletOutputStream servletOutputStream; - + @Mock ServletContext servletContext; - + @Mock HttpSession httpSession; @Mock AppUtils appUtils; - + @Mock ReportRuntime reportRuntime; - + @Mock ReportDefinition reportDefinition; @Mock WizardSequence wizardSequence; - + @Mock Encoder encoder; - + @Mock IAppUtils iAppUtils; @@ -143,92 +144,74 @@ public class ReportHandlerTest { @Mock FileOutputStream fileOutputStream; - + @Mock PrintWriter printWriter; - + @Mock DataSourceList dataSourceList; - - @Mock + + @Mock ReportRowHeaderCols reportRowHeaderCols; - + @Mock ReportColumnHeaderRows reportColumnHeaderRows; - + @Mock + ReportDataRows reportDataRows; + @Mock Writer iowriter; - + @Mock File file; @Mock Connection connection; - + @Mock Statement statement; - + @Mock ResultSet resultSet; - + @Mock ResultSetMetaData resultSetMetaData; private String REPORT_ID = "1000"; - + @Before - public void setUp() throws Exception { - + public void setUp() throws Exception { + PowerMockito.mockStatic(DbUtils.class); PowerMockito.mockStatic(Globals.class); 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); - - PowerMockito.whenNew(FileInputStream.class).withArguments(Matchers.anyString()).thenReturn(fileInputStream); - PowerMockito.whenNew(FileOutputStream.class).withArguments(Matchers.anyString()).thenReturn(fileOutputStream); + Mockito.when(file.createNewFile()).thenReturn(true); - /* - PowerMockito.whenNew(FileOutputStream.class).withArguments(Matchers.anyString()).thenAnswer( - - new Answer<FileOutputStream>() { - - @Override - public FileOutputStream answer(InvocationOnMock invocation) throws Throwable { - Object[] args = invocation.getArguments(); - String string = (String)args[0]; - - System.out.println("------------------------------ callled -------------------------=============>>>>>>>>>>>>>>>> " + string); - - return fileOutputStream; - } - - - } - ); - */ + PowerMockito.whenNew(FileInputStream.class).withArguments(Matchers.anyString()).thenReturn(fileInputStream); + PowerMockito.whenNew(FileOutputStream.class).withArguments(Matchers.anyString()).thenReturn(fileOutputStream); Mockito.when(httpServletRequest.getSession()).thenReturn(httpSession); Mockito.when(httpSession.getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition); Mockito.when(httpSession.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(reportRuntime); - + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); - + PowerMockito.when(ESAPI.encoder()).thenReturn(encoder); PowerMockito.when(Globals.getAppUtils()).thenReturn(iAppUtils); - + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); - - //Mockito.when(appUtils.getUserID(httpServletRequest)).thenReturn("USER1"); + + // Mockito.when(appUtils.getUserID(httpServletRequest)).thenReturn("USER1"); reportHandler = Mockito.spy(ReportHandler.class); } - + @Test public void testSaveAsExcelFile_case1() { String saveOutput = ""; @@ -236,7 +219,7 @@ 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.getShowDescrAtRuntime()).thenReturn(true); @@ -246,19 +229,19 @@ public class ReportHandlerTest { PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false); - ArrayList <IdNameValue> paramList = null; + 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"; + + int i = 1; + while (i < 20) { + para = para + "<p>This is a paragraph.</p>" + "\n" + "<p>This is another paragraph.</p>" + "\n"; i++; } @@ -270,42 +253,27 @@ public class ReportHandlerTest { 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); 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"); + 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(); - + 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); @@ -315,19 +283,19 @@ public class ReportHandlerTest { PowerMockito.when(Globals.getShowDisclaimer()).thenReturn(true); PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(false); - ArrayList <IdNameValue> paramList = null; + 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"; + + int i = 1; + while (i < 20) { + para = para + "<p>This is a paragraph.</p>" + "\n" + "<p>This is another paragraph.</p>" + "\n"; i++; } @@ -339,23 +307,21 @@ public class ReportHandlerTest { 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(); + 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); @@ -365,101 +331,80 @@ public class ReportHandlerTest { formatType2.setUnderline(true); formatType2.setUnderline(true); formatType2.setFontSize("20"); - + listFormatType.add(formatType2); - - + st1.setSemaphoreName("Name1"); - st1.setSemaphoreId("Id1"); - - st1.setFormatList(formatList); - + 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); - + 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"); + 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>(); - - - - - - - - - - - - - - - private ArrayList<DataRow> prepareDataRowList(){ - ArrayList <DataRow> alDataRow = new ArrayList<DataRow>(); - DataRow dataRow = new DataRow(); - + dataRow.setRowNum(1); dataRow.setRowFormat(true); - + DataValue dataValue1 = new DataValue(); dataValue1.setColId("REPORT_ID"); dataValue1.setColName("REPORT_ID"); dataValue1.setDisplayName("REPORT ID"); - dataValue1.setVisible(true); - + dataValue1.setVisible(true); + DataValue dataValue2 = new DataValue(); dataValue2.setColId("ORDER_ID"); dataValue2.setColName("ORDER_ID"); dataValue2.setDisplayName("ORDER ID"); dataValue2.setVisible(true); - + dataRow.addDataValue(dataValue1); dataRow.addDataValue(dataValue2); - + alDataRow.add(dataRow); - + return alDataRow; } - + private ReportData prepareReportData() { - + ReportData reportData = new ReportData(1, true); reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); - + DataRow dataRow = new DataRow(); - + dataRow.setRowNum(1); dataRow.setRowFormat(true); - + reportData.addRowNumbers(1, prepareDataRowList()); - + return reportData; } - @Test public void testCreateExcelFileContent_case1() throws Exception { ReportData reportData = prepareReportData(); - + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(false); @@ -478,37 +423,38 @@ public class ReportHandlerTest { Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 2); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); - Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 2); + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - } - + @Test public void testCreateExcelFileContent_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; + 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.getVisibleColumnCount()).thenReturn(3); Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); @@ -518,46 +464,37 @@ public class ReportHandlerTest { 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.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 1); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 1); } - @Test public void testCreateExcelFileContent_case3() 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; + 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.getVisibleColumnCount()).thenReturn(3); Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); @@ -567,54 +504,88 @@ public class ReportHandlerTest { Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); - - + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - /* - 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.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse, "PORTAL_USER", 3); + } + + @Test + public void testCreateExcelFileContent_case4() 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.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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); } - - @Test - public void testCreateExcel2007FileContent_case1() throws Exception { - - + public void testCreateExcelFileContent_case5() 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; + 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.getVisibleColumnCount()).thenReturn(3); Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); @@ -624,57 +595,1122 @@ public class ReportHandlerTest { Mockito.when(httpSession.getAttribute("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); - - + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); - + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); - /* - PowerMockito.when(Globals.getShowDescrAtRuntime()).thenReturn(true); + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test + public void testCreateExcelFileContent_case6() 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.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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + private ReportData prepareReportData1() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + DataValue value1 = new DataValue(); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData2() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setDisplayTotal("SUM("); + value.setBold(true); + DataValue value1 = null; + // value1.setColId("test"); + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData3() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("date"); + value.setColName("date"); + value.setDisplayTotal("SUM("); + value.setBold(true); + DataValue value1 = null; + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData4() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setColName("date"); + value.setDisplayTotal("SUM("); + value.setBold(true); + DataValue value1 = null; + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData5() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setColName("date"); + value.setDisplayTotal("SUM("); + value.setBold(true); + DataValue value1 = new DataValue(); + value1.setColId("test"); + value1.setColName("date"); + value1.setDisplayTotal("SUM("); + value1.setBold(false); + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData6() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setColName("date"); + value.setDisplayTotal("SUM("); + value.setDisplayValue("$Test123"); + value.setBold(true); + DataValue value1 = new DataValue(); + value1.setColId("test"); + value1.setColName("date"); + value1.setDisplayTotal("SUM("); + value1.setColName("test999"); + value1.setBold(false); + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + private ReportData prepareReportData7() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setColName("date"); + value.setDisplayTotal("SUM("); + value.setDisplayValue("$Test123."); + value.setBold(true); + DataValue value1 = new DataValue(); + value1.setColId("test"); + value1.setColName("date"); + value1.setDisplayTotal("SUM("); + value1.setColName("test999"); + value1.setDisplayValue("$Test123."); + value1.setBold(false); + + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + + private ReportData prepareReportData8() { + + ReportData reportData = new ReportData(1, true); + reportData.createColumn("REPORT_ID", "REPORT ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + reportData.createColumn("ORDER_ID", "ORDER ID", "500", "right", true, "Asc", true, 1, 1, 1, true); + + DataRow dataRow = new DataRow(); + + dataRow.setRowNum(1); + dataRow.setRowFormat(true); + + reportData.addRowNumbers(1, prepareDataRowList()); + ReportDataRows reportDataRows = new ReportDataRows(); + DataRow dataRow1 = new DataRow(); + DataValue value = new DataValue(); + value.setColId("test"); + value.setColName(null); + value.setDisplayTotal("SUM("); + value.setDisplayValue("$Test123"); + value.setBold(true); + DataValue value1 = new DataValue(); + value1.setColId("test"); + value1.setColName("date"); + value1.setDisplayTotal("SUM("); + value1.setColName("test999"); + value1.setBold(false); + dataRow1.addDataValue(value); + dataRow1.addDataValue(value1); + reportDataRows.addDataRow(dataRow1); + reportDataRows.add(dataRow1); + reportDataRows.addDataRow(dataRow); + reportDataRows.add(dataRow); + reportData.reportDataTotalRow = reportDataRows; + reportData.reportDataRows = reportDataRows; + + ReportRowHeaderCols reportRowHeaderCols = new ReportRowHeaderCols(); + RowHeaderCol rowHeaderCol = new RowHeaderCol(); + RowHeader rowHeader = new RowHeader(); + rowHeaderCol.add(rowHeader); + RowHeader rowHeader1 = new RowHeader(); + rowHeaderCol.add(rowHeader1); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol); + RowHeaderCol rowHeaderCol1 = new RowHeaderCol(); + RowHeader rowHeader2 = new RowHeader(); + rowHeaderCol1.add(rowHeader2); + RowHeader rowHeader3 = new RowHeader(); + RowHeader rowHeader6 = new RowHeader(); + rowHeaderCol1.add(rowHeader3); + rowHeaderCol1.add(rowHeader6); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol1); + RowHeaderCol rowHeaderCol2 = new RowHeaderCol(); + RowHeader rowHeader5 = new RowHeader(); + RowHeader rowHeader4 = new RowHeader(); + rowHeaderCol2.add(rowHeader5); + rowHeaderCol2.add(rowHeader4); + reportRowHeaderCols.addRowHeaderCol(rowHeaderCol2); + reportData.reportTotalRowHeaderCols = reportRowHeaderCols; + + return reportData; + } + + + @Test + public void testCreateExcelFileContent_case7() throws Exception { + ReportData reportData = prepareReportData1(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); 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); - + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case8() throws Exception { + ReportData reportData = prepareReportData1(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case9() throws Exception { + ReportData reportData = prepareReportData2(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case10() throws Exception { + ReportData reportData = prepareReportData2(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("$test"); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case35() throws Exception { + ReportData reportData = prepareReportData2(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("test."); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + } - + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case36() throws Exception { + ReportData reportData = prepareReportData2(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1,"); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + + + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case11() throws Exception { + ReportData reportData = prepareReportData2(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("$1"); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case12() throws Exception { + ReportData reportData = prepareReportData2(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("$.1"); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test + public void testCreateExcel2007FileContent_case1() 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.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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + @Test 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; + 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.getReportID()).thenReturn(REPORT_ID); Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_CROSSTAB); @@ -684,55 +1720,35 @@ public class ReportHandlerTest { 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_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); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - /* - 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"); mockHttpAttribute("pdfAttachmentKey", "PdfKey"); @@ -743,17 +1759,16 @@ public class ReportHandlerTest { 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, null); - 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); - - ArrayList <IdNameValue> paramList = null; + + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); @@ -761,23 +1776,21 @@ public class ReportHandlerTest { 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.getOutputStream()).thenReturn(servletOutputStream); - - reportHandler.createCSVFileContent(iowriter, reportData, reportRuntime, httpServletRequest, httpServletResponse); + + 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"); @@ -788,15 +1801,15 @@ public class ReportHandlerTest { 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); @@ -807,9 +1820,8 @@ public class ReportHandlerTest { Mockito.when(resultSetMetaData.getColumnLabel(Mockito.anyInt())).thenReturn("column1"); Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("value1"); - - - ArrayList <IdNameValue> paramList = null; + + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); @@ -817,26 +1829,24 @@ public class ReportHandlerTest { 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); + + 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_WithoutSql_case1() throws Exception { - + ReportData reportData = prepareReportData(); - + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); mockHttpAttribute("pdfAttachmentKey", "PdfKey"); @@ -847,17 +1857,16 @@ public class ReportHandlerTest { 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, null); - 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); - - ArrayList <IdNameValue> paramList = null; + + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); @@ -865,26 +1874,24 @@ public class ReportHandlerTest { 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, "", httpServletRequest, httpServletResponse); + + reportHandler.createHTMLFileContent(iowriter, reportData, reportRuntime, "", httpServletRequest, + httpServletResponse); } - - @Test(expected =RaptorException.class) + + @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"); @@ -895,15 +1902,15 @@ public class ReportHandlerTest { 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); @@ -914,8 +1921,8 @@ public class ReportHandlerTest { Mockito.when(resultSetMetaData.getColumnLabel(Mockito.anyInt())).thenReturn("column1"); Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("value1"); - - ArrayList <IdNameValue> paramList = null; + + ArrayList<IdNameValue> paramList = null; paramList = new ArrayList<IdNameValue>(); paramList.add(new IdNameValue("Name", "Portal SDK")); paramList.add(new IdNameValue("Org", "ONAP")); @@ -923,26 +1930,23 @@ public class ReportHandlerTest { 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); + + 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"); @@ -953,134 +1957,1152 @@ public class ReportHandlerTest { 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; + 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(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"); + + Mockito.when(reportRuntime.getAllColumns()).thenReturn(listDataColumnType); + + reportHandler.createFlatFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "USER#1"); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case15() throws Exception { + ReportData reportData = prepareReportData3(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("$test"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case16() throws Exception { + ReportData reportData = prepareReportData4(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011 11:11:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case17() throws Exception { + ReportData reportData = prepareReportData4(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011 11:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case18() throws Exception { + ReportData reportData = prepareReportData4(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/11 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case19() throws Exception { + ReportData reportData = prepareReportData4(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011 11:11:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case25() throws Exception { + ReportData reportData = prepareReportData4(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1/1/2011 1:11:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + } - /* + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case26() throws Exception { + ReportData reportData = prepareReportData4(); - @Test + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1/1/2011 1:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testSaveAsExcelFileHttpServletRequestReportDataArrayListStringStringInt() { - fail("Not yet implemented"); } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case27() throws Exception { + ReportData reportData = prepareReportData4(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1/1/2011"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testCreateExcelFileContent() { - fail("Not yet implemented"); } + + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case28() throws Exception { + ReportData reportData = prepareReportData4(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("2011/1/1"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testCreateFlatFileContent() { - fail("Not yet implemented"); } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case29() throws Exception { + ReportData reportData = prepareReportData4(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("2011-1-1 1:11:11"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testSaveXMLFile() { - fail("Not yet implemented"); } + + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case30() throws Exception { + ReportData reportData = prepareReportData4(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("111 2011"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testLoadReportRuntimeHttpServletRequestString() { - fail("Not yet implemented"); } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case31() throws Exception { + ReportData reportData = prepareReportData4(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1/2011"); + java.util.HashMap dataTypeMap = Mockito.mock(HashMap.class); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withNoArguments().thenReturn(dataTypeMap); + + Mockito.when(dataTypeMap.get("test")).thenReturn("test"); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testLoadReportRuntimeHttpServletRequestStringBoolean() { - fail("Not yet implemented"); } + + + + @Test(expected = java.lang.NullPointerException.class) + public void testCreateExcelFileContent_case20() throws Exception { + ReportData reportData = prepareReportData5(); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(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"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + + 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(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); + + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - @Test - public void testLoadReportRuntimeHttpServletRequestStringBooleanInt() { - fail("Not yet implemented"); } + + @Test(expected = java.lang.NullPointerException.class) + public void testCreateExcelFileContent_case21() throws Exception { + ReportData reportData = prepareReportData6(); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(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"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + + 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(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011 11:11:11"); + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - @Test - public void testCreateReportDefinition() { - fail("Not yet implemented"); } + + @Test(expected = java.lang.NullPointerException.class) + public void testCreateExcelFileContent_case22() throws Exception { + ReportData reportData = prepareReportData6(); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(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"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + + 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(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011 11:11:11"); + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - @Test - public void testLoadReportDefinition() { - fail("Not yet implemented"); } + + @Test(expected = java.lang.NullPointerException.class) + public void testCreateExcelFileContent_case23() throws Exception { + ReportData reportData = prepareReportData7(); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(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"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + + 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(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011"); + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - @Test - public void testSetSheetName() { - fail("Not yet implemented"); } + + @Test(expected = java.lang.NullPointerException.class) + public void testCreateExcelFileContent_case24() throws Exception { + ReportData reportData = prepareReportData8(); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(false); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(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"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + + 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(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 2); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("11/11/2011"); + Mockito.verify(reportHandler, Mockito.times(1)).createExcelFileContent(iowriter, reportData, reportRuntime, + httpServletRequest, httpServletResponse, "PORTAL_USER", 2); - @Test - public void testGetSheetName() { - fail("Not yet implemented"); } + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case37() throws Exception { + ReportData reportData = prepareReportData2(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("1."); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testGetColumnCountForDownloadFile() { - fail("Not yet implemented"); } + + + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void testCreateExcelFileContent_case38() throws Exception { + ReportData reportData = prepareReportData2(); + + 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.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_LINEAR); + Mockito.when(reportRuntime.getDbInfo()).thenReturn("tetDB"); + + 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("SI_DASHBOARD_REP_ID")).thenReturn(REPORT_ID); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)).thenReturn(null); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.customizeFormFieldInfo()).thenReturn(true); + + Mockito.when(reportRuntime.getFormFieldComments(httpServletRequest)).thenReturn("test:|:"); + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.when(ReportLoader.getSystemDateTime()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.when(Globals.getScheduleDatePattern()).thenReturn("MM/dd/yyyy kk:mm:ss"); + PowerMockito.when(Globals.disclaimerPositionedTopInCSVExcel()).thenReturn(true); + PowerMockito.when(reportRuntime.getWholeSQL()).thenReturn("test sql"); + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("test"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(Matchers.anyInt())).thenReturn("test,."); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("test", "test"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); - @Test - public void testCreateHTMLFileContent() { - fail("Not yet implemented"); } - */ } |