diff options
author | Kishore Reddy, Gujja (kg811t) <kg811t@research.att.com> | 2018-07-09 13:41:00 -0400 |
---|---|---|
committer | Kishore Reddy, Gujja (kg811t) <kg811t@research.att.com> | 2018-07-11 13:20:28 -0400 |
commit | a96a3e49cd472aa902c22143358b87562603d47c (patch) | |
tree | 7e97578788de44f6704252cf982af09adcc05e8d /ecomp-sdk/epsdk-analytics | |
parent | 9ac542482e4710e5566d147ca7a7a42500628ba2 (diff) |
Adding User Auth and permission aaf services
Issue-ID: PORTAL-334
Change-Id: I2826f2a06f7d818d918ae5f45b500a8da78cec42
Signed-off-by: Kishore Reddy, Gujja (kg811t) <kg811t@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics')
5 files changed, 1331 insertions, 2 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceTest.java index 76842d05..c2cac38a 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/WizardSequenceTest.java @@ -38,9 +38,13 @@ package org.onap.portalsdk.analytics.controller; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.model.definition.ReportDefinition; import org.onap.portalsdk.analytics.util.AppConstants; public class WizardSequenceTest { @@ -75,4 +79,42 @@ public class WizardSequenceTest { wizardSequence.performGoToStep(AppConstants.WS_DEFINITION); assertEquals("", wizardSequence.getCurrentSubStep()); } + + @Test + public void testPerformActionWithWANextActionWithReportDefinition() { + ReportDefinition rdef = Mockito.mock(ReportDefinition.class); + Mockito.when(rdef.getReportDefType()).thenReturn("test"); + wizardSequence.performAction(AppConstants.WA_NEXT, rdef); + assertEquals("", wizardSequence.getCurrentSubStep()); + } + + @Test + public void testIsInitialStep() { + assertTrue(wizardSequence.isInitialStep()); + } + + @Test + public void testIsFinalStep() { + assertFalse(wizardSequence.isFinalStep()); + } + + @Test + public void testGetCurrentStep() { + assertEquals("Definition",wizardSequence.getCurrentStep()); + } + + @Test + public void testResetNext() { + wizardSequence.resetNext(); + } + + @Test + public void testHasNext() { + wizardSequence.hasNext(); + } + + @Test + public void testGetNext() { + wizardSequence.getNext(); + } } 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 77950ae7..e7a2b6e0 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 @@ -47,12 +47,14 @@ import java.io.Writer; import java.sql.Connection; import java.sql.ResultSet; import java.sql.ResultSetMetaData; +import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.Vector; import javax.servlet.ServletContext; import javax.servlet.ServletOutputStream; @@ -66,6 +68,7 @@ import org.junit.runner.RunWith; import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; +import org.mockito.stubbing.OngoingStubbing; import org.onap.portalsdk.analytics.controller.WizardSequence; import org.onap.portalsdk.analytics.error.RaptorException; import org.onap.portalsdk.analytics.model.base.IdNameValue; @@ -79,6 +82,7 @@ import org.onap.portalsdk.analytics.system.IAppUtils; import org.onap.portalsdk.analytics.util.AppConstants; import org.onap.portalsdk.analytics.view.DataRow; import org.onap.portalsdk.analytics.view.DataValue; +import org.onap.portalsdk.analytics.view.HtmlFormatter; import org.onap.portalsdk.analytics.view.ReportColumnHeaderRows; import org.onap.portalsdk.analytics.view.ReportData; import org.onap.portalsdk.analytics.view.ReportDataRows; @@ -101,7 +105,7 @@ import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) @PrepareForTest({ Globals.class, DbUtils.class, ESAPI.class, IAppUtils.class, AppUtils.class, ConnectionUtils.class, - ReportLoader.class, HashMap.class }) + ReportLoader.class, HashMap.class, ReportLoader.class, ReportRuntime.class}) public class ReportHandlerTest { private ReportHandler reportHandler; @@ -3105,4 +3109,1140 @@ public class ReportHandlerTest { httpServletResponse, "PORTAL_USER", 3); } + + @Test + public void testCreateExcelFileContent_case14() 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(new TreeMap() {{put("1", reportRuntime);}}); + + 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"); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn("test"); + Mockito.when(reportRuntime.getReportID()).thenReturn("test"); + Mockito.when(httpServletRequest.getSession()).thenReturn(httpSession); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(new TreeMap() {{put("1", reportData);}}); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test + public void testCreateExcelFileContent_case39() 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(new TreeMap() {{put("1", reportRuntime);}}); + + 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"); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn("test"); + Mockito.when(reportRuntime.getReportID()).thenReturn("test"); + Mockito.when(httpServletRequest.getSession()).thenReturn(httpSession); + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(new TreeMap() {{put("1", reportData);}}); + HashMap map = Mockito.mock(HashMap.class); + Mockito.when(map.get(Mockito.anyObject())).thenReturn("NUMBER"); + PowerMockito.whenNew(HashMap.class).withNoArguments().thenReturn(map); + reportHandler.createExcelFileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test + public void testLoadReportRuntime() throws RaptorException { + PowerMockito.mockStatic(ReportLoader.class); + PowerMockito.mockStatic(ReportRuntime.class); + Mockito.when(ReportLoader.loadCustomReportXML(Mockito.anyString())).thenReturn("test"); + Mockito.when(ReportRuntime.unmarshal(Mockito.anyString(), Mockito.anyString(), Mockito.eq(httpServletRequest))).thenReturn(reportRuntime); + Mockito.when(AppUtils.getRequestNvlValue( Mockito.eq(httpServletRequest), Mockito.anyString())).thenReturn("test"); + reportHandler.loadReportRuntime(httpServletRequest, "test1"); + } + + + @Test + public void testCreateCell() throws IOException { + Writer writer = Mockito.mock(Writer.class); + ReportHandler.SpreadsheetWriter sw = new ReportHandler.SpreadsheetWriter(writer); + sw.createCell(10, 10.5d); + } + + + @Test(expected=NullPointerException.class) + public void testCreateExcel2007FileContent_case10() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_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(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn(REPORT_ID); + + Map<String, ReportRuntime> mapReportRuntime = new TreeMap<String, ReportRuntime>(); + Map<String, ReportData> mapReportData = new TreeMap<String, ReportData>(); + + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'"); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + + 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(Globals.getShowDisclaimer()).thenReturn(true); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected=NullPointerException.class) + public void testCreateExcel2007FileContent_case11() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_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(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>(); + ReportDataRows vc1 = new ReportDataRows(); + vc1.add(mockedDataRow()); + reportData.reportDataRows=vc1; + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'"); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + List<String> list = new ArrayList<>(); + list.add("$.test"); + ResultSet resultSet = mockResultSet(list); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("$.test"); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("colId"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(Globals.getShowDisclaimer()).thenReturn(true); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("colId", "NUMBER"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected=NullPointerException.class) + public void testCreateExcel2007FileContent_case12() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_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(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>(); + ReportDataRows vc1 = new ReportDataRows(); + vc1.add(mockedDataRow()); + reportData.reportDataRows=vc1; + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'"); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + List<String> list = new ArrayList<>(); + list.add("test"); + ResultSet resultSet = mockResultSet(list); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("test"); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("colId"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(Globals.getShowDisclaimer()).thenReturn(true); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("colId", "NUMBER"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected=NullPointerException.class) + public void testCreateExcel2007FileContent_case13() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_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(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>(); + + + ReportDataRows vc1 = new ReportDataRows(); + vc1.add(mockedDataRow()); + reportData.reportDataRows=vc1; + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'"); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + List<String> list = new ArrayList<>(); + list.add("$test,"); + ResultSet resultSet = mockResultSet(list); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("$test,"); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("colId"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(Globals.getShowDisclaimer()).thenReturn(true); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("colId", "NUMBER"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected=NullPointerException.class) + public void testCreateExcel2007FileContent_case14() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_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(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>(); + + DataRow dataRow = mockedDataRow(); + dataRow.getDataValue(0).setDisplayName("date"); + ReportDataRows vc1 = new ReportDataRows(); + vc1.add(dataRow); + reportData.reportDataRows=vc1; + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'"); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + List<String> list = new ArrayList<>(); + list.add("test"); + ResultSet resultSet = mockResultSet(list); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("$test"); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("colId"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(Globals.getShowDisclaimer()).thenReturn(true); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("colId", "NUMBER"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected=NullPointerException.class) + public void testCreateExcel2007FileContent_case15() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_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(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>(); + ReportDataRows vc1 = new ReportDataRows(); + vc1.add(mockedDataRow()); + reportData.reportDataRows=vc1; + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn("select column1 from table1 where column2='test'"); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + List<String> list = new ArrayList<>(); + list.add(".test"); + ResultSet resultSet = mockResultSet(list); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn(".test"); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("colId"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(Globals.getShowDisclaimer()).thenReturn(true); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("colId", "NUMBER"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + + @Test + public void testCreateExcel2007FileContent_case16() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_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(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REP_ID)).thenReturn(REPORT_ID); + + Map<String, ReportRuntime> mapReportRuntime = new TreeMap<String, ReportRuntime>(); + Map<String, ReportData> mapReportData = new TreeMap<String, ReportData>(); + + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn(""); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + + 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(Globals.getShowDisclaimer()).thenReturn(true); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test + public void testCreateExcel2007FileContent_case17() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_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(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>(); + ReportDataRows vc1 = new ReportDataRows(); + DataRow dataRow = mockedDataRow(); + dataRow.getDataValue(0).setDisplayValue("$.test"); + vc1.add(dataRow); + reportData.reportDataRows=vc1; + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn(""); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + List<String> list = new ArrayList<>(); + list.add("$.test"); + ResultSet resultSet = mockResultSet(list); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("$.test"); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("colId"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(Globals.getShowDisclaimer()).thenReturn(true); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("colId", "NUMBER"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test + public void testCreateExcel2007FileContent_case18() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_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(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>(); + ReportDataRows vc1 = new ReportDataRows(); + DataRow dataRow = mockedDataRow(); + dataRow.getDataValue(0).setDisplayValue("test"); + vc1.add(dataRow); + reportData.reportDataRows=vc1; + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn(""); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + List<String> list = new ArrayList<>(); + list.add("test"); + ResultSet resultSet = mockResultSet(list); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("test"); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("colId"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(Globals.getShowDisclaimer()).thenReturn(true); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("colId", "NUMBER"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test + public void testCreateExcel2007FileContent_case19() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_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(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>(); + + + ReportDataRows vc1 = new ReportDataRows(); + DataRow dataRow = mockedDataRow(); + dataRow.getDataValue(0).setDisplayValue("$test,"); + vc1.add(dataRow); + reportData.reportDataRows=vc1; + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn(""); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + List<String> list = new ArrayList<>(); + list.add("$test,"); + ResultSet resultSet = mockResultSet(list); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("$test,"); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("colId"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(Globals.getShowDisclaimer()).thenReturn(true); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("colId", "NUMBER"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test + public void testCreateExcel2007FileContent_case20() throws Exception { + + ReportData reportData = prepareReportData(); + + DataSourceList dataSourceList = new DataSourceList(); + reportData.setReportDataList(prepareDataRowList()); + + PowerMockito.when(Globals.getSheetName()).thenReturn("Raptor Reports"); + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + PowerMockito.when(Globals.getPrintParamsInDownload()).thenReturn(true); + + ArrayList<IdNameValue> paramList = null; + paramList = new ArrayList<IdNameValue>(); + paramList.add(new IdNameValue("Name", "Portal SDK")); + paramList.add(new IdNameValue("Org", "ONAP")); + paramList.add(new IdNameValue("Status", "Active")); + + Mockito.when(reportRuntime.getParamNameValuePairsforPDFExcel(httpServletRequest, 1)).thenReturn(paramList); + + Mockito.when(reportRuntime.getReportTitle()).thenReturn("Raptor Reports Excel"); + Mockito.when(reportRuntime.getReportName()).thenReturn("Report for ONAP Portal"); + Mockito.when(reportRuntime.getReportDescr()).thenReturn("Report for ONAP Portal Desc"); + Mockito.when(reportRuntime.getDataSourceList()).thenReturn(dataSourceList); + + Mockito.when(reportRuntime.getReportID()).thenReturn(REPORT_ID); + + Mockito.when(reportRuntime.getVisibleColumnCount()).thenReturn(3); + Mockito.when(reportRuntime.getReportType()).thenReturn(AppConstants.RT_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(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>(); + + DataRow dataRow = mockedDataRow(); + dataRow.getDataValue(0).setDisplayName("date"); + ReportDataRows vc1 = new ReportDataRows(); + vc1.add(dataRow); + reportData.reportDataRows=vc1; + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn(""); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + List<String> list = new ArrayList<>(); + list.add("test"); + ResultSet resultSet = mockResultSet(list); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn("$test"); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("colId"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(Globals.getShowDisclaimer()).thenReturn(true); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("colId", "NUMBER"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + @Test(expected=NullPointerException.class) + public void testCreateExcel2007FileContent_case21() 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.getReportID()).thenReturn(REPORT_ID); + + 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(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>(); + ReportDataRows vc1 = new ReportDataRows(); + DataRow dataRow = mockedDataRow(); + dataRow.getDataValue(0).setDisplayValue(".test"); + vc1.add(dataRow); + reportData.reportDataRows=vc1; + mapReportRuntime.put("ReportRuntime#1", reportRuntime); + mapReportData.put("ReportData#1", reportData); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTRUNTIME_MAP)) + .thenReturn(mapReportRuntime); + + Mockito.when(httpSession.getAttribute(AppConstants.SI_DASHBOARD_REPORTDATA_MAP)).thenReturn(mapReportData); + + Mockito.when(reportRuntime.getWholeSQL()).thenReturn(""); + Mockito.when(reportRuntime.getTemplateFile()).thenReturn(""); + + Mockito.when(iAppUtils.getTempFolderPath()).thenReturn(""); + + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(servletOutputStream); + + PowerMockito.when(Globals.getPrintTitleInDownload()).thenReturn(true); + + Mockito.when(ConnectionUtils.getConnection(Matchers.anyString())).thenReturn(connection); + Mockito.when(connection.createStatement()).thenReturn(statement); + List<String> list = new ArrayList<>(); + list.add(".test"); + ResultSet resultSet = mockResultSet(list); + Mockito.when(statement.executeQuery(Matchers.anyString())).thenReturn(resultSet); + Mockito.when(resultSet.getMetaData()).thenReturn(resultSetMetaData); + Mockito.when(resultSet.getString(Mockito.anyInt())).thenReturn(".test"); + Mockito.when(resultSetMetaData.getColumnCount()).thenReturn(2); + Mockito.when(resultSetMetaData.getColumnLabel(Matchers.anyInt())).thenReturn("colId"); + Mockito.when(httpSession.getAttribute("FOOTER_" + 1)).thenReturn("footer"); + Mockito.when(Globals.getShowDisclaimer()).thenReturn(true); + java.util.HashMap dataTypeMap = new java.util.HashMap(); + dataTypeMap.put("colId", "NUMBER"); + PowerMockito.whenNew(java.util.HashMap.class).withAnyArguments().thenReturn(dataTypeMap); + reportHandler.createExcel2007FileContent(iowriter, reportData, reportRuntime, httpServletRequest, + httpServletResponse, "PORTAL_USER", 3); + + } + + private DataRow mockedDataRow() { + DataRow dataRow = new DataRow(); + + DataValue dataValue = new DataValue(); + dataValue.setDisplayTotal("SUM("); + dataValue.setDisplayName("displayName"); + dataValue.setDisplayCalculatedValue("displayCalculatedValue"); + dataValue.setDrillDownURL("drillDownURL"); + dataValue.setDrillDowninPoPUp(false); + dataValue.setIndentation("indentation"); + dataValue.setAlignment("alignment"); + dataValue.setVisible(true); + dataValue.setHidden(false); + HtmlFormatter formatter = new HtmlFormatter(); + dataValue.setCellFormatter(formatter); + dataValue.setBold(false); + dataValue.setRowFormatter(formatter); + dataValue.setFormatId("formatId"); + dataValue.setCellFormat(false); + dataValue.setColId("colId"); + dataValue.setDisplayName("displayName"); + dataValue.setNowrap("nowrap"); + dataValue.setHyperlinkURL("hyperlinkURL"); + dataValue.setDisplayType("displayType"); + dataValue.setActionImg("actionImg"); + dataRow.setRowFormat(false); + HtmlFormatter formatter1 = new HtmlFormatter(); + dataRow.setRowFormatter(formatter1); + dataRow.setRowNum(1); + Vector vc = new Vector(); + vc.add(dataRow); + dataRow.setRowValues(vc); + dataRow.setFormatId("test"); + dataRow.addDataValue(dataValue); + return dataRow; + } + + private ResultSet mockResultSet(List<String> rows) throws SQLException { + ResultSet rs = Mockito.mock(ResultSet.class); + + OngoingStubbing rsNextStub = Mockito.when(rs.next()); + for (String str : rows) { + // We must reassign! + rsNextStub = rsNextStub.thenReturn(true); + } + rsNextStub.thenReturn(false); + + OngoingStubbing rsGetStringStub = Mockito.when(rs.getString(1)); + for (String str : rows) { + // We must reassign! + rsGetStringStub = rsGetStringStub.thenReturn(str); + } + + return rs; + } } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessorTest.java index d89074cd..7de4c1e2 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessorTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessorTest.java @@ -39,8 +39,14 @@ package org.onap.portalsdk.analytics.model.runtime; import static org.junit.Assert.assertNotNull; +import java.util.Vector; + import org.junit.Before; import org.junit.Test; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.onap.portalsdk.analytics.view.DataRow; +import org.onap.portalsdk.analytics.view.DataValue; +import org.onap.portalsdk.analytics.view.HtmlFormatter; import org.onap.portalsdk.analytics.xmlobj.FormatList; import org.onap.portalsdk.analytics.xmlobj.FormatType; import org.onap.portalsdk.analytics.xmlobj.SemaphoreType; @@ -58,7 +64,7 @@ public class FormatProcessorTest { FormatList formatList = new FormatList(); FormatType formatType = new FormatType(); formatType.setLessThanValue("lessThanValue"); - formatType.setExpression("expression"); + formatType.setExpression("<"); formatType.setBold(false); formatType.setItalic(false); formatType.setUnderline(false); @@ -72,6 +78,8 @@ public class FormatProcessorTest { formatList.getFormat().add(formatType); semaphoreType.setFormatList(formatList); semaphoreType.setSemaphoreId("semaphoreId"); + formatProcessor = new FormatProcessor(semaphoreType, AppConstants.CT_DATE, "test", true); + formatProcessor = new FormatProcessor(semaphoreType, AppConstants.CT_NUMBER, "test", true); formatProcessor = new FormatProcessor(semaphoreType, "test", "test", true); } @@ -79,4 +87,20 @@ public class FormatProcessorTest { public void testNotNull(){ assertNotNull(formatProcessor); } + + @Test + public void test() { + DataRow dataRow = new DataRow(); + DataValue dataValue = new DataValue(); + dataRow.setRowFormat(false); + HtmlFormatter formatter = new HtmlFormatter(); + dataRow.setRowFormatter(formatter); + dataRow.setRowNum(1); + Vector vc = new Vector<>(); + vc.add(dataRow); + dataRow.setRowValues(vc); + dataRow.setFormatId("test"); + dataValue.setDisplayValue("test"); + formatProcessor.setHtmlFormatters(dataValue, dataRow, true); + } } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/util/DataSetTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/util/DataSetTest.java new file mode 100644 index 00000000..09908379 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/util/DataSetTest.java @@ -0,0 +1,121 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.util; + +import static org.junit.Assert.assertEquals; + +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +public class DataSetTest { +DataSet dataSet; + + @Before + public void setUp() throws SQLException{ + ResultSet rs= Mockito.mock(ResultSet.class); + ResultSetMetaData rsmd= Mockito.mock(ResultSetMetaData.class); + Mockito.when(rs.getMetaData()).thenReturn(rsmd); + Mockito.when(rsmd.getColumnCount()).thenReturn(1); + Mockito.when(rsmd.getColumnLabel(1)).thenReturn("test"); + Mockito.when(rsmd.getColumnTypeName(1)).thenReturn("date"); + Mockito.when(rs.next()).thenReturn(true); + Mockito.when(rs.getString(1)).thenReturn("test"); + dataSet = new DataSet(rs, 1); + dataSet.setString(0,"test","0"); + DataSet dataSet3 = new DataSet(); + } + + @Test + public void testInsertRow() { + dataSet.insertRow(1); + } + + @Test + public void testInsertColumn() { + dataSet.insertColumn(1, "test"); + } + + @Test + public void testGetColumnName() { + dataSet.getColumnName(0); + } + + @Test + public void testGetColumnType() { + dataSet.getColumnType(0); + } + + @Test + public void testGetColumnTypeWithColumnName() { + dataSet.getColumnType("test"); + } + + @Test + public void testGetItem() { + dataSet.getItem(0,0); + } + + @Test + public void testGetItemWithColumnName() { + dataSet.getItem(0, "test"); + } + + @Test + public void testSetString() { + dataSet.setString(0,0,"0"); + } + + @Test + public void testSetStringWithColumnName() { + dataSet.setString(0,"test","0"); + } + + @Test + public void testGetInt() { + assertEquals(0,dataSet.getInt(0,0)); + } + + @Test + public void testGetIntWithColumnName() { + assertEquals(0,dataSet.getInt(0,"test")); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/PdfReportHandlerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/PdfReportHandlerTest.java index 76dd83ed..0022f584 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/PdfReportHandlerTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/PdfReportHandlerTest.java @@ -1178,7 +1178,9 @@ public class PdfReportHandlerTest { reportDataRows.add(dataRow2); reportDataRows.addDataRow(dataRow); reportDataRows.add(dataRow); + rd.reportDataRows = reportDataRows; + ReportColumnHeaderRows reportColumnHeaderRows = new ReportColumnHeaderRows(); ColumnHeaderRow columnHeaderRow = new ColumnHeaderRow(); ColumnHeader columnHeader = new ColumnHeader(); |