diff options
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model')
40 files changed, 6040 insertions, 399 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/DataCacheTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/DataCacheTest.java new file mode 100644 index 00000000..a9b1bac2 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/DataCacheTest.java @@ -0,0 +1,328 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 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.model; + +import java.util.Vector; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.error.ReportSQLException; +import org.onap.portalsdk.analytics.model.pdf.PdfReportHandler; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.DbUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.DataSet; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ Globals.class, DbUtils.class, AppUtils.class }) +public class DataCacheTest { + @InjectMocks + DataCache dataCache = new DataCache(); + + @Before + public void init() throws Exception { + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + + @Mock + DataSet ds; + + @SuppressWarnings("static-access") + @Test + public void getDataViewActionsTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheDataViewActions()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery("test")).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(1, 0)).thenReturn("test"); + dataCache.getDataViewActions(); + } + + @SuppressWarnings("static-access") + @Test + public void getPublicReportIdNamesTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getThePublicReportIdNames()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery("test")).thenReturn(ds); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + dataCache.getPublicReportIdNames(); + } + + @SuppressWarnings("static-access") + @Test + public void getPublicReportIdNamesTest1() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getThePublicReportIdNames()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery("test")).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + dataCache.getPublicReportIdNames(); + } + + @SuppressWarnings("static-access") + @Test + public void getPrivateAccessibleReportIdNamesTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getThePrivateAccessibleNamesA()).thenReturn("test"); + Mockito.when(Globals.getThePrivateAccessibleNamesB()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + dataCache.getPrivateAccessibleReportIdNames("test12", vc); + } + + @SuppressWarnings("static-access") + @Test + public void getPrivateAccessibleReportIdNamesTest1() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getThePrivateAccessibleNamesA()).thenReturn("test"); + Mockito.when(Globals.getThePrivateAccessibleNamesB()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + dataCache.getPrivateAccessibleReportIdNames("test12", vc); + } + + @SuppressWarnings("static-access") + @Test + public void getGroupAccessibleReportIdNamesTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheGroupAccessibleNamesA()).thenReturn("test"); + Mockito.when(Globals.getTheGroupAccessibleNamesB()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + dataCache.getGroupAccessibleReportIdNames("test12", vc); + } + + @SuppressWarnings("static-access") + @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class) + public void getTableSourceTest() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(true); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.grabTheReportTableA()).thenReturn("tablename"); + Mockito.when(Globals.grabTheReportTableIf()).thenReturn("reporttable"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false); + Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(true); + Mockito.when(Globals.grabTheReportTableB()).thenReturn("tableB"); + dataCache.getTableSource("tableName", "dBinfo", vc, "test12", mockedRequest); + } + + @SuppressWarnings("static-access") + @Test + public void getTableSourceTest1() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(true); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.grabTheReportTableA()).thenReturn("tablename"); + Mockito.when(Globals.grabTheReportTableIf()).thenReturn("reporttable"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false); + Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(false); + Mockito.when(Globals.grabTheReportTableB()).thenReturn("tableB"); + Mockito.when(Globals.grabTheReportTableC()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + dataCache.getTableSource("tableName", "dBinfo", vc, "test12", mockedRequest); + } + + @SuppressWarnings("static-access") + @Test + public void getTableSourceTest2() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(true); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.grabTheReportTableA()).thenReturn("tablename"); + Mockito.when(Globals.grabTheReportTableIf()).thenReturn("reporttable"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false); + Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(false); + Mockito.when(Globals.grabTheReportTableB()).thenReturn("tableB"); + Mockito.when(Globals.grabTheReportTableC()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Mockito.when(Globals.grabTheReportTableElse()).thenReturn("abcd"); + dataCache.getTableSource("tableName", "local", vc, "test12", mockedRequest); + } + + @SuppressWarnings("static-access") + @Test + public void getTableSourceTest3() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(false); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.grabTheReportTableA()).thenReturn("tablename"); + Mockito.when(Globals.grabTheReportTableIf()).thenReturn("reporttable"); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false); + Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(false); + Mockito.when(Globals.grabTheReportTableB()).thenReturn("tableB"); + Mockito.when(Globals.grabTheReportTableC()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Mockito.when(Globals.grabTheReportTableElse()).thenReturn("abcd"); + dataCache.getTableSource("tableName", "local", vc, "test12", mockedRequest); + } + + @SuppressWarnings("static-access") + @Test + public void getReportTableJoinsTest() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheReportTableCrJoin()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + dataCache.getReportTableJoins(); + } + @SuppressWarnings("static-access") + @Test + public void getReportTableJoinsTest1() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheReportTableCrJoin()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(0); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + dataCache.getReportTableJoins(); + } + + + @SuppressWarnings("static-access") + @Test + public void getReportTableJoinsTest2() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheReportTableCrJoin()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(0); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(false); + dataCache.getReportTableJoins(vc); + } + + + @SuppressWarnings("static-access") + @Test + public void getReportTableJoinsTest3() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheReportTableCrJoin()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(0); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(true); + Mockito.when(Globals.getTheReportTableJoins()).thenReturn("test"); + dataCache.getReportTableJoins(vc); + } + + @SuppressWarnings("static-access") + @Test + public void getReportTableJoinsTest4() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getTheReportTableCrJoin()).thenReturn("test"); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test"); + Vector vc = new Vector(); + vc.add("test"); + vc.add("test1"); + Mockito.when(Globals.getRestrictTablesByRole()).thenReturn(true); + Mockito.when(Globals.getTheReportTableJoins()).thenReturn("test"); + dataCache.getReportTableJoins(vc); + } +} 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"); } - */ } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ChartSeqComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ChartSeqComparatorTest.java new file mode 100644 index 00000000..25b70b8b --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ChartSeqComparatorTest.java @@ -0,0 +1,66 @@ +/* + * ============LICENxSE_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.model.base; + +import static org.junit.Assert.assertNotEquals; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; + +public class ChartSeqComparatorTest { + + ChartSeqComparator chartSeqComparator; + + private Integer CHAR_SEQ = 1000; + + @Before + public void init() { + chartSeqComparator = new ChartSeqComparator(); + } + + + @Test + public void testCompare() { + DataColumnType dct1 = new DataColumnType(); + DataColumnType dct2 = new DataColumnType(); + dct1.setChartSeq(CHAR_SEQ); + dct2.setChartSeq(CHAR_SEQ); + assertNotEquals(true, chartSeqComparator.compare(dct1, dct2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameColLookupTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameColLookupTest.java new file mode 100644 index 00000000..9269d240 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameColLookupTest.java @@ -0,0 +1,75 @@ +/* + * ============LICENxSE_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.model.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class IdNameColLookupTest { + + IdNameColLookup idNameColLookup; + + private String COL_ID = "colId"; + private String DB_TABLE_NAME = "dbTableName"; + private String DB_ID_FIELD = "dbIdField"; + private String DB_NAME_FIELD = "dbNameField"; + private String DB_SORT_BY_FIELD = "dbSortByField"; + + @Before + public void init() { + idNameColLookup = new IdNameColLookup(COL_ID, DB_TABLE_NAME, DB_ID_FIELD, DB_NAME_FIELD, DB_SORT_BY_FIELD); + } + + @Test + public void testNotNull() { + assertNotNull(idNameColLookup); + } + + @Test + public void testIdNameColLookupProperties() { + assertEquals(COL_ID, idNameColLookup.getColId()); + assertEquals(DB_TABLE_NAME, idNameColLookup.getDbTableName()); + assertEquals(DB_ID_FIELD, idNameColLookup.getDbIdField()); + assertEquals(DB_NAME_FIELD, idNameColLookup.getDbNameField()); + assertEquals(DB_SORT_BY_FIELD, idNameColLookup.getDbSortByField()); + } +} + diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameListTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameListTest.java new file mode 100644 index 00000000..cff2eb83 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameListTest.java @@ -0,0 +1,82 @@ +/* + * ============LICENxSE_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.model.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portalsdk.analytics.system.Globals; +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}) +public class IdNameListTest { + + IdNameList idNameList; + + private String ID = "testID"; + private String NAME = "test"; + private boolean DEFAULT_VALUE = true; + private boolean READ_ONLY = true; + + @Before + public void init() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(Globals.getFormFieldsListSize()).thenReturn(100); + idNameList = new IdNameList(); + idNameList.addValue(ID, NAME, DEFAULT_VALUE, READ_ONLY); + } + + @Test + public void testGetIdByName() { + assertEquals(ID, idNameList.getIdByName(NAME)); + } + + @Test + public void testGetNameById() { + assertEquals(NAME, idNameList.getNameById(ID)); + } + + + + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameLookupTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameLookupTest.java new file mode 100644 index 00000000..725d179d --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameLookupTest.java @@ -0,0 +1,76 @@ +/* + * ============LICENxSE_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.model.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class IdNameLookupTest { + + IdNameLookup idNameLookup; + + private String DB_TABLE_NAME = "dbTableName"; + private String DB_ID_FIELD = "dbIdField"; + private String DB_NAME_FIELD = "dbNameField"; + private String DB_SORT_BY_FIELD = "dbSortByField"; + private String DEFAULT_SQL = "defaultSQL"; + private boolean TEXT_FIELD = true; + + @Before + public void init() { + idNameLookup = new IdNameLookup(DB_TABLE_NAME, DB_ID_FIELD, DB_NAME_FIELD, DB_SORT_BY_FIELD, DEFAULT_SQL, TEXT_FIELD); + } + + @Test + public void testNotNull() { + assertNotNull(idNameLookup); + } + + @Test + public void testIdNameLookupProperties() { + assertEquals(DB_TABLE_NAME, idNameLookup.getDbTableName()); + assertEquals(DB_ID_FIELD, idNameLookup.getDbIdField()); + assertEquals(DB_NAME_FIELD, idNameLookup.getDbNameField()); + assertEquals(DB_SORT_BY_FIELD, idNameLookup.getDbSortByField()); + assertEquals(DEFAULT_SQL, idNameLookup.getDefaultSQL()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameSqlTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameSqlTest.java new file mode 100644 index 00000000..78e8dffa --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameSqlTest.java @@ -0,0 +1,80 @@ +/* + * ============LICENxSE_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.model.base; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.system.ConnectionUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; +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, IdNameSql.class, ConnectionUtils.class}) +public class IdNameSqlTest { + + IdNameSql idNameSql; + + @Before + public void init() { + idNameSql = new IdNameSql("select * from test", "select * from test"); + } + + @Test + public void testLoadData() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(ConnectionUtils.class); + Mockito.when(Globals.getDBType()).thenReturn("test"); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.anyString())).thenReturn("test"); + Mockito.when(Globals.getReportSqlForFormfield()).thenReturn("test"); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.anyString(), Mockito.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + idNameSql.loadData("select", 10, "testDB"); + } +} + diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameValueTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameValueTest.java new file mode 100644 index 00000000..0c798684 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameValueTest.java @@ -0,0 +1,69 @@ +/* + * ============LICENxSE_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.model.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class IdNameValueTest { + + IdNameValue idNameValue; + + private String ID = "id"; + private String NMAE = "name"; + + @Before + public void init() { + idNameValue = new IdNameValue(ID, NMAE); + } + + @Test + public void testNotNull() { + assertNotNull(idNameValue); + } + + @Test + public void testIdNameValueProperties() { + assertEquals(ID, idNameValue.getId()); + assertEquals(NMAE, idNameValue.getName()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/NameComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/NameComparatorTest.java new file mode 100644 index 00000000..8d9c3385 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/NameComparatorTest.java @@ -0,0 +1,64 @@ +/* + * ============LICENxSE_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.model.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class NameComparatorTest { + + NameComparator nameComparator; + private String NAME = "name"; + + @Before + public void init() { + nameComparator = new NameComparator(); + } + + @Test + public void testCompare() { + IdNameValue idNameValue1 = new IdNameValue(); + idNameValue1.setName(NAME); + IdNameValue idNameValue2 = new IdNameValue(); + idNameValue2.setName(NAME); + + assertEquals(0, nameComparator.compare(idNameValue1, idNameValue2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderBySeqComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderBySeqComparatorTest.java new file mode 100644 index 00000000..cd403e7c --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderBySeqComparatorTest.java @@ -0,0 +1,65 @@ +/* + * ============LICENxSE_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.model.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; + +public class OrderBySeqComparatorTest { + + OrderBySeqComparator orderBySeqComparator; + private Integer CHAR_SEQ = 100; + + @Before + public void init() { + orderBySeqComparator = new OrderBySeqComparator(); + } + + @Test + public void testCompare() { + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setOrderBySeq(CHAR_SEQ); + DataColumnType dataColumnType2 = new DataColumnType(); + dataColumnType2.setOrderBySeq(CHAR_SEQ); + + assertEquals(0, orderBySeqComparator.compare(dataColumnType1, dataColumnType2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderSeqComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderSeqComparatorTest.java new file mode 100644 index 00000000..dd6c7050 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderSeqComparatorTest.java @@ -0,0 +1,64 @@ +/* + * ============LICENxSE_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.model.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; + +public class OrderSeqComparatorTest { + OrderSeqComparator orderSeqComparator; + private Integer CHAR_SEQ = 100; + + @Before + public void init() { + orderSeqComparator = new OrderSeqComparator(); + } + + @Test + public void testCompare() { + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setOrderSeq(CHAR_SEQ); + DataColumnType dataColumnType2 = new DataColumnType(); + dataColumnType2.setOrderSeq(CHAR_SEQ); + + assertEquals(0, orderSeqComparator.compare(dataColumnType1, dataColumnType2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportSecurityTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportSecurityTest.java new file mode 100644 index 00000000..c8a2a97e --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportSecurityTest.java @@ -0,0 +1,105 @@ +/* + * ============LICENxSE_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.model.base; + +import java.util.Vector; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.DbUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({AppUtils.class, Globals.class, DbUtils.class}) +public class ReportSecurityTest { + + ReportSecurity reportSecurity; + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + + @Before + public void setUp() throws RaptorException { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getReportSecurity()).thenReturn("select * from test"); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(DbUtils.executeQuery(Mockito.anyString())).thenReturn(ds); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(Globals.getReportUserAccess()).thenReturn("select * test"); + reportSecurity = new ReportSecurity("test"); + Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("USERID"); + Vector userRoles = new Vector(); + userRoles.add("test"); + Mockito.when(AppUtils.getUserRoles(Mockito.anyString())).thenReturn(userRoles); + Mockito.when(AppUtils.getUserName(Mockito.anyString())).thenReturn("test"); + Mockito.when(AppUtils.getAdminRoleIDs()).thenReturn(userRoles); + Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(userRoles); + Mockito.when(Globals.getDeleteOnlyByOwner()).thenReturn(false); + } + + @Test + public void testCheckUserReadAccess() throws RaptorException { + reportSecurity.checkUserReadAccess(mockedRequest, null); + } + + @Test + public void testCheckUserWriteAccess() throws RaptorException { + reportSecurity.checkUserWriteAccess(mockedRequest); + } + + @Test + public void testCheckUserDeleteAccess() throws RaptorException { + reportSecurity.checkUserWriteAccess(mockedRequest); + } + + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportUserRoleTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportUserRoleTest.java new file mode 100644 index 00000000..19d1eddc --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportUserRoleTest.java @@ -0,0 +1,74 @@ +/* + * ============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.model.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class ReportUserRoleTest { + + ReportUserRole reportUserRole; + private Long REP_ID = 1L; + private Long ORDER_NO = 2L; + private Long ROLE_ID = 3L; + private Long USER_ID = 4L; + private String READ_ONLY_YN = "Y"; + + @Before + public void init() { + reportUserRole = new ReportUserRole(REP_ID, ORDER_NO, ROLE_ID, USER_ID, READ_ONLY_YN); + } + + @Test + public void testNotNull() { + assertNotNull(reportUserRole); + } + + @Test + public void testReportUserRoleProperties() { + assertEquals(REP_ID, reportUserRole.getRepId()); + assertEquals(ORDER_NO, reportUserRole.getOrderNo()); + assertEquals(ROLE_ID, reportUserRole.getRoleId()); + assertEquals(USER_ID, reportUserRole.getUserId()); + assertEquals(READ_ONLY_YN, reportUserRole.getReadOnlyYn()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DBColumnInfoTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DBColumnInfoTest.java new file mode 100644 index 00000000..c4e9d7f4 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DBColumnInfoTest.java @@ -0,0 +1,73 @@ +/* + * ============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.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class DBColumnInfoTest { + + DBColumnInfo dbColumnInfo; + + private String TABLE_NAME = "tableName"; + private String COL_NAME = "colName"; + private String COL_TYPE = "colType"; + private String LABEL = "label"; + + @Before + public void init() { + dbColumnInfo = new DBColumnInfo(TABLE_NAME, COL_NAME, COL_TYPE, LABEL); + } + + @Test + public void testNotNull() { + assertNotNull(dbColumnInfo); + } + + @Test + public void testDBColumnInfoProperties() { + assertEquals(TABLE_NAME, dbColumnInfo.getTableName()); + assertEquals(COL_NAME, dbColumnInfo.getColName()); + assertEquals(COL_TYPE, dbColumnInfo.getColType()); + assertEquals(LABEL, dbColumnInfo.getLabel()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DrillDownParamDefTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DrillDownParamDefTest.java new file mode 100644 index 00000000..df1d5693 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DrillDownParamDefTest.java @@ -0,0 +1,62 @@ +/* + * ============LICENxSE_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.model.definition; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class DrillDownParamDefTest { + + DrillDownParamDef drillDownParamDef; + String DRILL_DOWN_PARAM_DEF_STR = "fieldName=[valColId!valFieldId]"; + + @Before + public void init() { + drillDownParamDef = new DrillDownParamDef(DRILL_DOWN_PARAM_DEF_STR); + } + + @Test + public void testDrillDownParamDefProperties() { + assertEquals("fieldName", drillDownParamDef.getFieldName()); + assertEquals("valColId", drillDownParamDef.getValColId()); + assertEquals("valFieldId", drillDownParamDef.getValFieldId()); + assertEquals("4", drillDownParamDef.getValType()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/MarkerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/MarkerTest.java new file mode 100644 index 00000000..3aa5d24e --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/MarkerTest.java @@ -0,0 +1,79 @@ +/* + * ============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.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class MarkerTest { + + Marker marker; + + private String MARKER_COLOR = "markerColor"; + private String ADDRESS_COLUMN = "addressColumn"; + private String DATA_COLUMN = "dataColumn"; + private String ADDRESS = "address"; + private String DATA = "data"; + private String COLOR = "color"; + + @Before + public void init() { + marker = new Marker(MARKER_COLOR, ADDRESS_COLUMN, DATA_COLUMN); + marker.setAddress(ADDRESS); + marker.setData(DATA); + marker.setColor(COLOR); + } + + @Test + public void testNotNull() { + assertNotNull(marker); + } + + @Test + public void testMarkerProperties() { + assertEquals(MARKER_COLOR, marker.getMarkerColor()); + assertEquals(ADDRESS_COLUMN, marker.getAddressColumn()); + assertEquals(DATA_COLUMN, marker.getDataColumn()); + assertEquals(DATA, marker.getData()); + assertEquals(COLOR, marker.getColor()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportLogEntryTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportLogEntryTest.java new file mode 100644 index 00000000..d92f2565 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportLogEntryTest.java @@ -0,0 +1,75 @@ +/* + * ============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.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class ReportLogEntryTest { + + ReportLogEntry reportlogEntry; + + private String LOGTIME = "logTime"; + private String USERNAME = "userName"; + private String ACTION = "action"; + private String TIME_TAKEN = "timeTaken"; + private String RUN_ICON = "runIcon"; + + @Before + public void init() { + reportlogEntry = new ReportLogEntry(LOGTIME, USERNAME, ACTION, TIME_TAKEN, RUN_ICON); + } + + @Test + public void testNotNull() { + assertNotNull(reportlogEntry); + } + + @Test + public void testReportLogEntryProperties() { + assertEquals(LOGTIME, reportlogEntry.getLogTime()); + assertEquals(USERNAME, reportlogEntry.getUserName()); + assertEquals(ACTION, reportlogEntry.getAction()); + assertEquals(TIME_TAKEN, reportlogEntry.getTimeTaken()); + assertEquals(RUN_ICON, reportlogEntry.getRunIcon()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportMapTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportMapTest.java new file mode 100644 index 00000000..fcbae7bc --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportMapTest.java @@ -0,0 +1,75 @@ +/* + * ============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.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class ReportMapTest { + + ReportMap reportMap; + + private String MARKER_COLOR = "markerColor"; + private String ADDRESS_COLUMN = "addressColumn"; + private String DATA_COLUMN = "dataColumn"; + private String IS_MAP_ALLOWED_YN = "isMapAllowedYN"; + private String ADD_ADDRESS_IN_DATA_YN = "addAddressInDataYN"; + + @Before + public void init() { + reportMap = new ReportMap(MARKER_COLOR, ADDRESS_COLUMN, DATA_COLUMN, IS_MAP_ALLOWED_YN, ADD_ADDRESS_IN_DATA_YN); + } + + @Test + public void testNotNull() { + assertNotNull(reportMap); + } + + @Test + public void testReportMapProperties() { + assertEquals(MARKER_COLOR, reportMap.getMarkerColor()); + assertEquals(ADDRESS_COLUMN, reportMap.getAddressColumn()); + assertEquals(DATA_COLUMN, reportMap.getDataColumn()); + assertEquals(IS_MAP_ALLOWED_YN, reportMap.getIsMapAllowedYN()); + assertEquals(ADD_ADDRESS_IN_DATA_YN, reportMap.getAddAddressInDataYN()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java index 40ab05de..3ba80d9f 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java @@ -37,36 +37,56 @@ */ package org.onap.portalsdk.analytics.model.definition; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.FileInputStream; import java.io.InputStream; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.portalsdk.analytics.error.RaptorException; import org.onap.portalsdk.analytics.error.ReportSQLException; +import org.onap.portalsdk.analytics.model.base.IdNameValue; +import org.onap.portalsdk.analytics.model.runtime.FormField; +import org.onap.portalsdk.analytics.model.runtime.ReportParamValues; import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.ConnectionUtils; import org.onap.portalsdk.analytics.system.DbUtils; import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.AppConstants; import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; +import org.onap.portalsdk.analytics.xmlobj.DataSourceType; +import org.onap.portalsdk.analytics.xmlobj.FormFieldList; +import org.onap.portalsdk.analytics.xmlobj.FormFieldType; import org.owasp.esapi.ESAPI; import org.owasp.esapi.Encoder; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import com.mchange.v2.debug.ThreadNameStackTraceRecorder; + @RunWith(PowerMockRunner.class) -@PrepareForTest({ AppUtils.class, Globals.class, DbUtils.class, AppUtils.class, ESAPI.class}) +@PrepareForTest({ AppUtils.class, Globals.class, DbUtils.class, AppUtils.class, ESAPI.class, ConnectionUtils.class, ReportSchedule.class}) public class ReportScheduleTest { @@ -116,7 +136,8 @@ public class ReportScheduleTest { PowerMockito.mockStatic(DbUtils.class); PowerMockito.mockStatic(AppUtils.class); PowerMockito.mockStatic(ESAPI.class); - + PowerMockito.mockStatic(ConnectionUtils.class); + MockitoAnnotations.initMocks(this); Mockito.when(httpSession.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(reportRuntime); @@ -166,7 +187,13 @@ public class ReportScheduleTest { Mockito.when(dataSet1.getString(Mockito.anyInt(), Mockito.anyString())).thenReturn("Some Value2"); reportSchedule = new ReportSchedule(REPORT_ID, USER_ID, true, httpServletRequest); - + reportSchedule.setEncryptMode("test"); + reportSchedule.setEndAMPM("AM"); + reportSchedule.setEndHour("10"); + reportSchedule.setEndMin("00"); + reportSchedule.addZero("0"); + + /* Mockito.when(dataSet1.getString(Mockito.anyInt(), Mockito.anyObject())).thenAnswer(new Answer<String>() { @@ -345,6 +372,353 @@ public class ReportScheduleTest { reportSchedule.persistScheduleData(connection, httpServletRequest); } + @Test + public void testPersistScheduleData_FormFieldList_case1() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("test"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn(""); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE AND [test] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case2() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("test"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("DAYTONA"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [test] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case3() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldType.setValidationType(FormField.VT_TIMESTAMP_MIN); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("report_id"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("DAYTONA"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [report_id] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case4() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldType.setValidationType(FormField.VT_TIMESTAMP_MIN); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("report_id"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("DAYTONA"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [report_id] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case5() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldType.setValidationType(FormField.VT_TIMESTAMP_SEC); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("report_id"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("TESTDB"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [test] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + + @Test + public void testPersistScheduleData_WithRaptorException() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + String new_schedule_data = "select coalesce(max(schedule_id),0)+1 AS sequence from cr_report_schedule"; + String persist_cond_sql_set = "update cr_report_schedule set condition_sql = ? where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getPersistCondSqlSet()).thenReturn(persist_cond_sql_update); + + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + PowerMockito.when(Globals.getNewScheduleData()).thenReturn(new_schedule_data); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeUpdate()).thenReturn(1); + Mockito.when(resultSet.next()).thenReturn(false); + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setStartDate("10/10/2018"); + reportSchedule.setEndDate("10/10/2019"); + reportSchedule.setRunDate("10/10/2019"); + reportSchedule.setRecurrence("Y"); + reportSchedule.addEmailToUser("UserID1", "UserName1"); + reportSchedule.addEmailToRole("roleId1", "roleName1"); + reportSchedule.setConditionSQL("SELECT coalesce(cr.owner_id, cr.create_id) owner_id, cr.create_id, DATE_FORMAT(cr.create_date, '[Globals.getTimeFormat()]') create_date, maint_id, DATE_FORMAT(cr.maint_date, '[Globals.getTimeFormat()]') update_date, cr.menu_id, cr.menu_approved_yn FROM cr_report cr WHERE cr.rep_id= [reportID]"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + @Test public void testDeleteScheduleData_case1() throws RaptorException { @@ -416,10 +790,9 @@ public class ReportScheduleTest { ReportSchedule.loadConditionalSQL("scheduleId#123"); } - /* - @Test - public void testLoadConditionalSQL_Error_case2() throws Exception { + @Test(expected=RaptorException.class) + public void testLoadConditionalSQL_Error_case2() throws Exception { String load_cond_sql = "SELECT condition_large_sql FROM cr_report_schedule WHERE schedule_id=?"; Mockito.when(DbUtils.getConnection()).thenReturn(connection); Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); @@ -433,50 +806,73 @@ public class ReportScheduleTest { PowerMockito.when(Globals.getLoadCondSql()).thenReturn(load_cond_sql); ReportSchedule.loadConditionalSQL("scheduleId#123"); - }*/ - + } - /* + @Test + public void testLoadConditionalSQL_Error_case3() throws Exception { + String load_cond_sql = "SELECT condition_large_sql FROM cr_report_schedule WHERE schedule_id=?"; + Mockito.when(DbUtils.getConnection()).thenReturn(connection); + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(Globals.isWeblogicServer()).thenReturn(false); + Mockito.when(Globals.isPostgreSQL()).thenReturn(false); + Mockito.when(Globals.isMySQL()).thenReturn(true); + + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(1)).thenThrow(new SQLException()); + PowerMockito.when(Globals.getLoadCondSql()).thenReturn(load_cond_sql); + + ReportSchedule.loadConditionalSQL("scheduleId#123"); + } + @Test public void testAddEmailArrayToUser() { - fail("Not yet implemented"); + ArrayList<IdNameValue> allSelectedUsers= new ArrayList<>(); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("1"); + idNameValue.setName("test"); + idNameValue.setReadOnly(true); + idNameValue.setDefaultValue(true); + allSelectedUsers.add(idNameValue); + reportSchedule.addEmailArrayToUser(allSelectedUsers); + assertEquals("1",((IdNameValue)reportSchedule.getEmailToUsers().get(0)).getId()); } @Test public void testRemoveEmailToUser() { - fail("Not yet implemented"); + reportSchedule.removeEmailToUser("1"); } - @Test - public void testAddEmailToRole() { - fail("Not yet implemented"); - } @Test public void testAddEmailArrayToRole() { - fail("Not yet implemented"); + ArrayList<IdNameValue> allSelectedUsers= new ArrayList<>(); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("roleID1"); + idNameValue.setName("roleName1"); + idNameValue.setReadOnly(true); + idNameValue.setDefaultValue(true); + allSelectedUsers.add(idNameValue); + reportSchedule.addEmailArrayToRole(allSelectedUsers); + assertEquals("roleID1",((IdNameValue)reportSchedule.getEmailToRoles().get(0)).getId()); } - + @Test public void testRemoveEmailToRole() { - fail("Not yet implemented"); + reportSchedule.removeEmailToRole("roleID1"); } @Test - public void testPersistScheduleData() { - fail("Not yet implemented"); + public void testIsAttachmentMode() { + reportSchedule.setAttachmentMode("Y"); + assertTrue(reportSchedule.isAttachmentMode()); } @Test - public void testDeleteScheduleData() { - fail("Not yet implemented"); + public void testSetConditional() { + reportSchedule.setConditional("Y"); + assertEquals("Y",reportSchedule.getConditional()); } - - @Test - public void testLoadConditionalSQL() { - fail("Not yet implemented"); - } - */ - + } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/SecurityEntryTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/SecurityEntryTest.java new file mode 100644 index 00000000..156a2adf --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/SecurityEntryTest.java @@ -0,0 +1,71 @@ +/* + * ============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.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class SecurityEntryTest { + + SecurityEntry securityEntry; + + private String ID = "testID"; + private String NAME = "testName"; + private boolean READ_ONLY = true; + + @Before + public void init() { + securityEntry = new SecurityEntry(ID, NAME, READ_ONLY); + } + + @Test + public void testNotNull() { + assertNotNull(securityEntry); + } + + @Test + public void testTableJoinProperties() { + assertEquals(ID, securityEntry.getId()); + assertEquals(NAME, securityEntry.getName()); + assertEquals(READ_ONLY, securityEntry.isReadOnly()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableJoinTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableJoinTest.java new file mode 100644 index 00000000..d7912415 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableJoinTest.java @@ -0,0 +1,71 @@ +/* + * ============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.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class TableJoinTest { + + TableJoin tableJoin; + + private String SRC_TABLE_NAME = "srcTableName"; + private String DEST_TABLE_NAME = "destTableName"; + private String JOIN_EXPR = "joinExpr"; + + @Before + public void init() { + tableJoin = new TableJoin(SRC_TABLE_NAME, DEST_TABLE_NAME, JOIN_EXPR); + } + + @Test + public void testNotNull() { + assertNotNull(tableJoin); + } + + @Test + public void testTableJoinProperties() { + assertEquals(SRC_TABLE_NAME, tableJoin.getSrcTableName()); + assertEquals(DEST_TABLE_NAME, tableJoin.getDestTableName()); + assertEquals(JOIN_EXPR, tableJoin.getJoinExpr()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableSourceTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableSourceTest.java new file mode 100644 index 00000000..c6554c12 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableSourceTest.java @@ -0,0 +1,76 @@ +/* + * ============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.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class TableSourceTest { + + TableSource tableSource; + + private String TABLE_NAME = "tableName"; + private String DISPLAY_NAME = "displayName"; + private String PK_FIELDS = "pkFields"; + private String VIEW_ACTION = "viewAction"; + private String IS_LARGE_DATA = "isLargeData"; + private String FILTER_SQL = "filterSql"; + + @Before + public void init() { + tableSource = new TableSource(TABLE_NAME, DISPLAY_NAME, PK_FIELDS, VIEW_ACTION, IS_LARGE_DATA, FILTER_SQL); + } + + @Test + public void testNotNull() { + assertNotNull(tableSource); + } + + @Test + public void testTableSourceProperties() { + assertEquals(TABLE_NAME, tableSource.getTableName()); + assertEquals(DISPLAY_NAME, tableSource.getDisplayName()); + assertEquals(PK_FIELDS, tableSource.getPkFields()); + assertEquals(VIEW_ACTION, tableSource.getViewAction()); + assertEquals(IS_LARGE_DATA, tableSource.getIsLargeData()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java index 3bdb5bc1..e1f99ec0 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START========================================== * ONAP Portal SDK * =================================================================== - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/MessageJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/MessageJSONTest.java new file mode 100644 index 00000000..da99f464 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/MessageJSONTest.java @@ -0,0 +1,63 @@ +/* + * ============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.model.definition.wizard; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class MessageJSONTest { + + MessageJSON messageJSON; + private String MESSAGE = "testMessage"; + private String ANY_STACKTRACE = "testStacktrace"; + + @Before + public void init() { + messageJSON = new MessageJSON(); + messageJSON.setMessage(MESSAGE); + messageJSON.setAnyStacktrace(ANY_STACKTRACE); + } + + @Test + public void testNotNull() { + assertEquals(MESSAGE, messageJSON.getMessage()); + assertEquals(ANY_STACKTRACE, messageJSON.getAnyStacktrace()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorErrorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorErrorTest.java new file mode 100644 index 00000000..271e2d5a --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorErrorTest.java @@ -0,0 +1,67 @@ +/* + * ============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.model.definition.wizard; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class RaptorErrorTest { + + RaptorError raptorError1; + RaptorError raptorError2; + private String MESSAGE = "theMessage"; + private Throwable THROWABLE = new Throwable(MESSAGE); + + @Before + public void init() { + raptorError1 = new RaptorError(MESSAGE); + raptorError2 = new RaptorError(MESSAGE, THROWABLE); + } + + @Test + public void testRaptorErrorMessage() { + assertEquals(MESSAGE, raptorError1.error().get("message")); + } + + @Test + public void testRaptorErrorThrowable() { + assertEquals(THROWABLE.toString(), raptorError2.error().get("exception")); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PageEventTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PageEventTest.java new file mode 100644 index 00000000..4b94657d --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PageEventTest.java @@ -0,0 +1,184 @@ +/* + * ============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.model.pdf; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.lowagie.text.Document; +import com.lowagie.text.Font; +import com.lowagie.text.Rectangle; +import com.lowagie.text.pdf.PdfContentByte; +import com.lowagie.text.pdf.PdfWriter; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ Globals.class, AppUtils.class, PdfReportHandler.class }) +public class PageEventTest { + + PdfBean pb = Mockito.mock(PdfBean.class); + PageEvent pageEvent = new PageEvent(pb); + @Mock + Document document; + @Mock + PdfWriter writer; + @Mock + Font font; + @Mock + PdfContentByte pdfContentByte; + + Rectangle rectangle = new Rectangle(1, 1, 1, 1); + + @Test + public void onStartPageTest() { + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.getFooterFontFamily()).thenReturn("test"); + Mockito.when(Globals.getFooterFontSize()).thenReturn((float) 1.1); + Mockito.when(pb.getLogo1Url()).thenReturn("<no logo>"); + Mockito.when(pb.getLogo2Url()).thenReturn("<no logo>"); + pageEvent.onStartPage(writer, document); + } + + @Test(expected = java.lang.RuntimeException.class) + public void onStartPage1Test() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(Globals.getFooterFontFamily()).thenReturn("test"); + Mockito.when(Globals.getFooterFontSize()).thenReturn((float) 1.1); + Mockito.when(pb.getLogo1Url()).thenReturn("test"); + Mockito.when(pb.getLogo2Url()).thenReturn("test"); + Mockito.when(AppUtils.getImgFolderURL()).thenReturn("test"); + Mockito.when(pb.getFullWebContextPath()).thenReturn("testpath"); + Mockito.when(AppUtils.isNotEmpty(Matchers.anyString())).thenReturn(true); + Mockito.when(document.getPageSize()).thenReturn(rectangle); + Mockito.when(document.leftMargin()).thenReturn((float) 1.0); + Mockito.when(document.rightMargin()).thenReturn((float) 0.1); + Mockito.when(writer.getDirectContent()).thenReturn(pdfContentByte); + pageEvent.onStartPage(writer, document); + } + + @Test(expected = java.lang.RuntimeException.class) + public void onStartPage2Test() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(Globals.getFooterFontFamily()).thenReturn("test"); + Mockito.when(Globals.getFooterFontSize()).thenReturn((float) 1.1); + + Mockito.when(pb.getLogo1Url()).thenReturn("<no logo>"); + Mockito.when(pb.getLogo2Url()).thenReturn("test"); + Mockito.when(AppUtils.getImgFolderURL()).thenReturn("test"); + Mockito.when(pb.getFullWebContextPath()).thenReturn("testpath"); + Mockito.when(AppUtils.isNotEmpty(Matchers.anyString())).thenReturn(true); + Mockito.when(document.getPageSize()).thenReturn(rectangle); + Mockito.when(document.leftMargin()).thenReturn((float) 1.0); + Mockito.when(document.rightMargin()).thenReturn((float) 0.1); + Mockito.when(writer.getDirectContent()).thenReturn(pdfContentByte); + pageEvent.onStartPage(writer, document); + } + + @Test(expected = java.lang.Exception.class) + public void onEndPageTest() { + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.getFooterFontFamily()).thenReturn("test"); + Mockito.when(Globals.getFooterFontSize()).thenReturn((float) 1.1); + Mockito.when(pb.getLogo1Url()).thenReturn("<no logo>"); + Mockito.when(pb.getLogo2Url()).thenReturn("<no logo>"); + pageEvent.onEndPage(writer, document); + } + + @Test(expected = java.lang.Exception.class) + public void onEndPage1Test() { + Rectangle rectangle1 = Mockito.mock(Rectangle.class); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.getFooterFontFamily()).thenReturn("test"); + Mockito.when(Globals.getFooterFontSize()).thenReturn((float) 1.1); + Mockito.when(pb.getLogo1Url()).thenReturn("<no logo>"); + Mockito.when(pb.getLogo2Url()).thenReturn("<no logo>"); + Mockito.when(pb.getTimestampPattern()).thenReturn("11/11/2011 11:11:11"); + PowerMockito.mockStatic(PdfReportHandler.class); + Mockito.when(PdfReportHandler.currentTime(Matchers.anyString())).thenReturn("test"); + Mockito.when(document.getPageSize()).thenReturn(rectangle1); + Mockito.when(rectangle1.width()).thenReturn((float) 20); + Mockito.when(document.leftMargin()).thenReturn((float) 11.0); + Mockito.when(document.rightMargin()).thenReturn((float) 0.1); + Mockito.when(writer.getDirectContent()).thenReturn(pdfContentByte); + pageEvent.onEndPage(writer, document); + } + + @SuppressWarnings("static-access") + @Test + public void getPageHeightTest() { + Rectangle rectangle1 = Mockito.mock(Rectangle.class); + Mockito.when(document.getPageSize()).thenReturn(rectangle1); + Mockito.when(rectangle1.width()).thenReturn((float) 20); + Mockito.when(document.leftMargin()).thenReturn((float) 11.0); + Mockito.when(document.rightMargin()).thenReturn((float) 0.1); + pageEvent.getPageHeight(document); + } + + @Test + public void pdfbeanTest() { + PdfBean pb = new PdfBean(); + pb.setLeftFooter("leftFooter"); + assertEquals(pb.getLeftFooter(), "leftFooter"); + pb.setTitle("title"); + assertEquals(pb.getTitle(), "title"); + pb.setCurrentPage(1); + assertEquals(pb.getCurrentPage(), 1); + assertEquals(pb.getTimestampPattern(), null); + assertEquals(pb.getWhereToShowPageNumber(), 0); + assertTrue(pb.isPageNumberAtHeader()); + assertFalse(pb.isPageNumberAtFooter()); + assertEquals(pb.getLogo1Url(), null); + assertEquals(pb.getLogo2Url(), null); + assertEquals(pb.getLogo1Size(), null); + assertEquals(pb.getLogo2Size(), null); + assertEquals(pb.getFullWebContextPath(), null); + assertEquals(pb.toString(), "title 1 null null 0 false false"); + pb.setAttachmentOfEmail(false); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PdfBeanTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PdfBeanTest.java new file mode 100644 index 00000000..a1db0d82 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/pdf/PdfBeanTest.java @@ -0,0 +1,113 @@ +/* + * ============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.model.pdf; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class PdfBeanTest { + PdfBean pdfBean; + + public static final int NUMBER_IN_HEADER = 0; + public static final int NUMBER_IN_FOOTER = 1; + public static final int NUMBER_IN_BOTH = 2; + + private boolean ALTERNATE_COLOR = true; + private boolean IS_PORTRAIT = true; + private boolean IS_COVER_PAGE_INCLUDED = true; + private boolean IS_DISPLAY_CHART = true; + private int CURRENT_PAGE = 1; + private int WHERE_TO_SHOW_PAGE_NUMBER = 2; + private String USER_ID = "userID"; + private String TIMESTAMP_PATTERN = "timestampPattern"; + private String TITLE = "title"; + private String LEFT_FOOTER = "leftFooter"; + private String PAGE_SIZE = "pageSize"; + private boolean IS_ATTACHMENT_OF_EMAIL = true; + private String LOGO1_URL = "logo1Url"; + private Integer LOGO1_SIZE = 100; + private String LOGO2_URL= "logo2Url"; + private Integer LOGO2_SIZE = 200; + private String FULL_WEB_CONTEXT_PATH = "fullWebContextPath"; + + + @Before + public void init() { + pdfBean = new PdfBean(); + pdfBean.setAlternateColor(ALTERNATE_COLOR); + pdfBean.setPortrait(IS_PORTRAIT); + pdfBean.setCoverPageIncluded(IS_COVER_PAGE_INCLUDED); + pdfBean.setDisplayChart(IS_DISPLAY_CHART); + pdfBean.setCurrentPage(CURRENT_PAGE); + pdfBean.setWhereToShowPageNumber(WHERE_TO_SHOW_PAGE_NUMBER); + pdfBean.setUserId(USER_ID); + pdfBean.setTimestampPattern(TIMESTAMP_PATTERN); + pdfBean.setTitle(TITLE); + pdfBean.setLeftFooter(LEFT_FOOTER); + pdfBean.setPagesize(PAGE_SIZE); + pdfBean.setAttachmentOfEmail(IS_ATTACHMENT_OF_EMAIL); + pdfBean.setLogo1Url(LOGO1_URL); + pdfBean.setLogo1Size(LOGO1_SIZE); + pdfBean.setLogo2Url(LOGO2_URL); + pdfBean.setLogo2Size(LOGO2_SIZE); + pdfBean.setFullWebContextPath(FULL_WEB_CONTEXT_PATH); + } + + @Test + public void testPdfBeanProperties() { + assertEquals(ALTERNATE_COLOR, pdfBean.isAlternateColor()); + assertEquals(IS_PORTRAIT, pdfBean.isPortrait()); + assertEquals(IS_COVER_PAGE_INCLUDED, pdfBean.isCoverPageIncluded()); + assertEquals(IS_DISPLAY_CHART, pdfBean.isDisplayChart()); + assertEquals(CURRENT_PAGE, pdfBean.getCurrentPage()); + assertEquals(2, pdfBean.getWhereToShowPageNumber()); + assertEquals(USER_ID, pdfBean.getUserId()); + assertEquals(TIMESTAMP_PATTERN, pdfBean.getTimestampPattern()); + assertEquals(TITLE, pdfBean.getTitle()); + assertEquals(LEFT_FOOTER, pdfBean.getLeftFooter()); + assertEquals(PAGE_SIZE, pdfBean.getPagesize()); + assertEquals(IS_ATTACHMENT_OF_EMAIL, pdfBean.isAttachmentOfEmail()); + assertEquals(LOGO1_URL, pdfBean.getLogo1Url()); + assertEquals(LOGO1_SIZE, pdfBean.getLogo1Size()); + assertEquals(LOGO2_URL, pdfBean.getLogo2Url()); + assertEquals(LOGO2_SIZE, pdfBean.getLogo2Size()); + assertEquals(FULL_WEB_CONTEXT_PATH, pdfBean.getFullWebContextPath()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/BarChartOptionsTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/BarChartOptionsTest.java new file mode 100644 index 00000000..d7422e94 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/BarChartOptionsTest.java @@ -0,0 +1,79 @@ +/* + * ============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.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class BarChartOptionsTest { + BarChartOptions barChartOptions; + + private boolean VERTICAL_ORIENTATION = true; + private boolean STACKED_CHART = true; + private boolean DISPLAY_BAR_CONTROLS = true; + private boolean X_AXIS_DATE_TYPE = true; + private boolean MINIMIZE_X_AXIS_TICKERS = true; + private boolean TIME_AXIS = true; + private boolean Y_AXIS_LOG_SCALE = true; + + @Before + public void init() { + barChartOptions = new BarChartOptions(); + barChartOptions.setVerticalOrientation(VERTICAL_ORIENTATION); + barChartOptions.setStackedChart(STACKED_CHART); + barChartOptions.setDisplayBarControls(DISPLAY_BAR_CONTROLS); + barChartOptions.setxAxisDateType(X_AXIS_DATE_TYPE); + barChartOptions.setMinimizeXAxisTickers(MINIMIZE_X_AXIS_TICKERS); + barChartOptions.setTimeAxis(TIME_AXIS); + barChartOptions.setyAxisLogScale(Y_AXIS_LOG_SCALE); + } + + @Test + public void testBarChartOptionsProperties() { + assertEquals(VERTICAL_ORIENTATION, barChartOptions.isVerticalOrientation()); + assertEquals(STACKED_CHART, barChartOptions.isStackedChart()); + assertEquals(DISPLAY_BAR_CONTROLS, barChartOptions.isDisplayBarControls()); + assertEquals(X_AXIS_DATE_TYPE, barChartOptions.isxAxisDateType()); + assertEquals(MINIMIZE_X_AXIS_TICKERS, barChartOptions.isMinimizeXAxisTickers()); + assertEquals(TIME_AXIS, barChartOptions.isTimeAxis()); + assertEquals(Y_AXIS_LOG_SCALE, barChartOptions.isyAxisLogScale()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntimeTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntimeTest.java new file mode 100644 index 00000000..2dce46c0 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntimeTest.java @@ -0,0 +1,117 @@ +/* + * ============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.model.runtime; + +import java.util.ArrayList; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.model.base.ReportWrapper; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.onap.portalsdk.core.web.support.UserUtils; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ UserUtils.class, AppUtils.class}) +public class ChartWebRuntimeTest { + ChartWebRuntime chartWebRuntime; + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + + @Before + public void init() { + chartWebRuntime = new ChartWebRuntime(); + ArrayList chartList = new ArrayList<>(); + chartList.add("test"); + ArrayList infoList = new ArrayList<>(); + infoList.add("test"); + chartWebRuntime.setChartList(chartList); + chartWebRuntime.setInfoList(infoList); + chartWebRuntime.setTotalSql("select * from test"); + } + + @Test + public void testBarChartOptionsProperties() throws RaptorException { + PowerMockito.mockStatic(UserUtils.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(mockedRequest.getParameter("action")).thenReturn("test"); + Mockito.when(UserUtils.getUserId(mockedRequest)).thenReturn(10); + Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true); + Mockito.when(AppUtils.nvl(Mockito.anyString())).thenReturn("test"); + Mockito.when(mockedRequest.getParameter("refresh")).thenReturn("N"); + Mockito.when(AppUtils.getRequestValue(mockedRequest, AppConstants.RI_REPORT_ID)).thenReturn("1"); + Mockito.when(AppUtils.getRequestNvlValue(Mockito.any(HttpServletRequest.class), Mockito.anyString())).thenReturn("test"); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + Mockito.when(rr.getReportID()).thenReturn("1"); + Mockito.when(rr.getReportType()).thenReturn("Hive"); + Mockito.when(rr.getReportSQL()).thenReturn("select * from test"); + Mockito.when(rr.getLegendLabelAngle()).thenReturn("standard"); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); + FormField formField = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", new ArrayList(), true, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField1 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", new ArrayList(), false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField2 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", new ArrayList(), false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + + reportFormFields.add(formField); + reportFormFields.add(formField1); + reportFormFields.add(formField2); + Mockito.when(rr.getReportFormFields()).thenReturn(reportFormFields); + Mockito.when(rr.getReportDefType()).thenReturn(AppConstants.RD_SQL_BASED); + Mockito.when(rr.getReportTitle()).thenReturn("test"); + Mockito.when(mockedRequest.getParameterValues(Matchers.anyString())).thenReturn(new String[] { "test" }); + chartWebRuntime.generateChart(mockedRequest); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/CommonChartOptionsTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/CommonChartOptionsTest.java new file mode 100644 index 00000000..c8bee8ec --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/CommonChartOptionsTest.java @@ -0,0 +1,81 @@ +/* + * ============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.model.runtime; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +public class CommonChartOptionsTest { + CommonChartOptions commonChartOptions; + + private String LEGEND_POSITION = "top"; + private String LEGEND_LABEL_ANGLE = "up45"; + private boolean HIDE_LEGEND = false; + private boolean ANIMATE_ANIMATED_CHART = true; + private int TOP_MARGIN = 30; + private int BOTTOM_MARGIN = 50; + private int LEFT_MARGIN = 100; + private int RIGHT_MARGIN = 60; + + @Before + public void init(){ + commonChartOptions = new CommonChartOptions(); + commonChartOptions.setLegendPosition(LEGEND_POSITION); + commonChartOptions.setLegendLabelAngle(LEGEND_LABEL_ANGLE); + commonChartOptions.setHideLegend(HIDE_LEGEND); + commonChartOptions.setAnimateAnimatedChart(ANIMATE_ANIMATED_CHART); + commonChartOptions.setTopMargin(TOP_MARGIN); + commonChartOptions.setBottomMargin(BOTTOM_MARGIN); + commonChartOptions.setLeftMargin(LEFT_MARGIN); + commonChartOptions.setRightMargin(RIGHT_MARGIN); + } + + @Test + public void testCommonChartOptionsProperties(){ + assertEquals(LEGEND_POSITION, commonChartOptions.getLegendPosition()); + assertEquals(LEGEND_LABEL_ANGLE, commonChartOptions.getLegendLabelAngle()); + assertEquals(HIDE_LEGEND, commonChartOptions.isHideLegend()); + assertEquals(ANIMATE_ANIMATED_CHART, commonChartOptions.isAnimateAnimatedChart()); + assertEquals(TOP_MARGIN, commonChartOptions.getTopMargin()); + assertEquals(BOTTOM_MARGIN, commonChartOptions.getBottomMargin()); + assertEquals(LEFT_MARGIN, commonChartOptions.getLeftMargin()); + assertEquals(RIGHT_MARGIN, commonChartOptions.getRightMargin()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ErrorJSONRuntimeTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ErrorJSONRuntimeTest.java new file mode 100644 index 00000000..c5b42989 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ErrorJSONRuntimeTest.java @@ -0,0 +1,63 @@ +/* + * ============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.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class ErrorJSONRuntimeTest { + ErrorJSONRuntime errorJSONRuntime; + + private String ERROR_MESSAGE = "testMesage"; + private String STACKTRACE = "testStacktrace"; + + @Before + public void init(){ + errorJSONRuntime = new ErrorJSONRuntime(); + errorJSONRuntime.setErrormessage(ERROR_MESSAGE); + errorJSONRuntime.setStacktrace(STACKTRACE); + } + + @Test + public void testErrorJSONRuntimeProperties(){ + assertEquals(ERROR_MESSAGE, errorJSONRuntime.getErrormessage()); + assertEquals(STACKTRACE, errorJSONRuntime.getStacktrace()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptionsTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptionsTest.java new file mode 100644 index 00000000..85fede3e --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptionsTest.java @@ -0,0 +1,64 @@ +/* + * ============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.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class FlexTimeSeriesChartOptionsTest { + FlexTimeSeriesChartOptions flexTimeSeriesChartOptions; + + private int ZOOM_IN = 25; + private String TIME_AXIS_TYPE = ""; + + @Before + public void init(){ + flexTimeSeriesChartOptions = new FlexTimeSeriesChartOptions(); + flexTimeSeriesChartOptions.setZoomIn(ZOOM_IN); + flexTimeSeriesChartOptions.setTimeAxisType(TIME_AXIS_TYPE); + } + + @Test + public void testFlexTimeSeriesChartOptionsProperties(){ + assertEquals(ZOOM_IN, flexTimeSeriesChartOptions.getZoomIn()); + assertEquals(TIME_AXIS_TYPE, flexTimeSeriesChartOptions.getTimeAxisType()); + } + +} 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 new file mode 100644 index 00000000..d89074cd --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessorTest.java @@ -0,0 +1,82 @@ +/* + * ============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.model.runtime; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.xmlobj.FormatList; +import org.onap.portalsdk.analytics.xmlobj.FormatType; +import org.onap.portalsdk.analytics.xmlobj.SemaphoreType; + +public class FormatProcessorTest { + FormatProcessor formatProcessor; + + @Before + public void init(){ + SemaphoreType semaphoreType = new SemaphoreType(); + semaphoreType.setSemaphoreName("semaphoreName"); + semaphoreType.setSemaphoreType("semaphoreType"); + semaphoreType.setComment("comment"); + semaphoreType.setTarget("target"); + FormatList formatList = new FormatList(); + FormatType formatType = new FormatType(); + formatType.setLessThanValue("lessThanValue"); + formatType.setExpression("expression"); + formatType.setBold(false); + formatType.setItalic(false); + formatType.setUnderline(false); + formatType.setBgColor("bgColor"); + formatType.setFontColor("fontColor"); + formatType.setFontFace("fontFace"); + formatType.setFontSize("fontSize"); + formatType.setAlignment("alignment"); + formatType.setComment("comment"); + formatType.setFormatId("formatId"); + formatList.getFormat().add(formatType); + semaphoreType.setFormatList(formatList); + semaphoreType.setSemaphoreId("semaphoreId"); + formatProcessor = new FormatProcessor(semaphoreType, "test", "test", true); + } + + @Test + public void testNotNull(){ + assertNotNull(formatProcessor); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ItemTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ItemTest.java new file mode 100644 index 00000000..086b9d9d --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ItemTest.java @@ -0,0 +1,63 @@ +/* + * ============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.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class ItemTest { + Item item; + + private String ID = "testID"; + private String NAME = "name"; + + @Before + public void init(){ + item = new Item(); + item.setId(ID); + item.setName(NAME); + } + + @Test + public void testItemProperties(){ + assertEquals(ID, item.getId()); + assertEquals(NAME, item.getName()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/LookupDBInfoTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/LookupDBInfoTest.java new file mode 100644 index 00000000..71ad8c28 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/LookupDBInfoTest.java @@ -0,0 +1,67 @@ +/* + * ============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.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class LookupDBInfoTest { + LookupDBInfo lookupDBInfo; + + private String TABLE_NAME = "tableName"; + private String FIELD_NAME = "fieldName"; + private String LOOKUP_TABLE = "lookupTable"; + private String LOOKUP_ID_FIELD = "lookupIdField"; + private String LOOKUP_NAME_FIELD = "lookupNameField"; + + @Before + public void init(){ + lookupDBInfo = new LookupDBInfo(TABLE_NAME, FIELD_NAME, LOOKUP_TABLE, LOOKUP_ID_FIELD, LOOKUP_NAME_FIELD); + } + + @Test + public void testItemProperties(){ + assertEquals(TABLE_NAME, lookupDBInfo.getTableName()); + assertEquals(FIELD_NAME, lookupDBInfo.getFieldName()); + assertEquals(LOOKUP_TABLE, lookupDBInfo.getLookupTable()); + assertEquals(LOOKUP_ID_FIELD, lookupDBInfo.getLookupIdField()); + assertEquals(LOOKUP_NAME_FIELD, lookupDBInfo.getLookupNameField()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RangeAxisJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RangeAxisJSONTest.java new file mode 100644 index 00000000..e0a9b371 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RangeAxisJSONTest.java @@ -0,0 +1,77 @@ +/* + * ============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.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class RangeAxisJSONTest { + RangeAxisJSON rangeAxisJSON; + + private RangeAxisLabelJSON rangeAxisLabelJSON; + private RangeColorJSON rangeColorJSON; + private RangeLineTypeJSON rangeLineTypeJSON; + private String RANGE_CHART_GROUP = "rangeChartGroup"; + private String RANGE_Y_AXIS = "rangeYAxis"; + private boolean SHOW_AS_AREA = true; + + @Before + public void init(){ + rangeAxisLabelJSON = new RangeAxisLabelJSON(); + rangeColorJSON = new RangeColorJSON(); + rangeLineTypeJSON = new RangeLineTypeJSON(); + rangeAxisJSON = new RangeAxisJSON(); + rangeAxisJSON.setRangeAxisLabelJSON(rangeAxisLabelJSON); + rangeAxisJSON.setRangeColorJSON(rangeColorJSON); + rangeAxisJSON.setRangeLineTypeJSON(rangeLineTypeJSON); + rangeAxisJSON.setRangeChartGroup(RANGE_CHART_GROUP); + rangeAxisJSON.setRangeYAxis(RANGE_Y_AXIS); + rangeAxisJSON.setShowAsArea(SHOW_AS_AREA); + } + + @Test + public void testItemProperties(){ + assertEquals(rangeAxisLabelJSON, rangeAxisJSON.getRangeAxisLabelJSON()); + assertEquals(rangeColorJSON, rangeAxisJSON.getRangeColorJSON()); + assertEquals(rangeLineTypeJSON, rangeAxisJSON.getRangeLineTypeJSON()); + assertEquals(RANGE_Y_AXIS, rangeAxisJSON.getRangeYAxis()); + assertEquals(SHOW_AS_AREA, rangeAxisJSON.isShowAsArea()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RaptorControllerAsyncTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RaptorControllerAsyncTest.java index 07e1745b..c5010c1a 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RaptorControllerAsyncTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RaptorControllerAsyncTest.java @@ -39,13 +39,16 @@ package org.onap.portalsdk.analytics.model.runtime; import static org.junit.Assert.assertEquals; +import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StringWriter; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Vector; import javax.servlet.ServletContext; @@ -71,6 +74,7 @@ import org.onap.portalsdk.analytics.model.ReportLoader; import org.onap.portalsdk.analytics.model.base.IdNameValue; import org.onap.portalsdk.analytics.model.base.ReportWrapper; import org.onap.portalsdk.analytics.model.definition.ReportDefinition; +import org.onap.portalsdk.analytics.model.definition.SecurityEntry; import org.onap.portalsdk.analytics.model.definition.wizard.ColumnJSON; import org.onap.portalsdk.analytics.model.definition.wizard.DefinitionJSON; import org.onap.portalsdk.analytics.system.AppUtils; @@ -104,7 +108,7 @@ import org.powermock.reflect.exceptions.MethodInvocationException; @RunWith(PowerMockRunner.class) @PrepareForTest({ AppConstants.class, Globals.class, AppUtils.class, ReportWrapper.class, DataCache.class, DbUtils.class, DataSet.class , ReportLoader.class ,ReportRuntime.class, Utils.class, ESAPI.class, - Codec.class,SecurityCodecUtil.class , ConnectionUtils.class, XSSFilter.class}) + Codec.class,SecurityCodecUtil.class , ConnectionUtils.class, XSSFilter.class, RaptorControllerAsync.class}) public class RaptorControllerAsyncTest { @InjectMocks @@ -617,4 +621,100 @@ public class RaptorControllerAsyncTest { return chartJSON; } + @Test + public void listChildReportColsTest() throws Exception { + ReportRuntime rr = Mockito.mock(ReportRuntime.class); + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportRuntime(Mockito.any(HttpServletRequest.class), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(rr); + List<DataColumnType> dataColumnTypeList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setColName("test"); + dataColumnType.setColId("1"); + dataColumnTypeList.add(dataColumnType); + Mockito.when(rr.getAllColumns()).thenReturn(dataColumnTypeList); + raptorControllerAsync.listChildReportCols("reportID", mockedRequest, mockedResponse); + } + + @Test + public void listChildReportFormFieldsTest() throws Exception { + ReportRuntime rr = Mockito.mock(ReportRuntime.class); + PowerMockito.whenNew(ReportHandler.class).withNoArguments().thenReturn(reportHandler); + Mockito.when(reportHandler.loadReportRuntime(Mockito.any(HttpServletRequest.class), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(rr); + List predefinedValues = new ArrayList<>(); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest); + FormField formField = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, true, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField1 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + FormField formField2 = new FormField("test", "fieldDisplayName", "TEXTAREA", "validationType", false, + "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL", + "rangeEndDateSQL", "multiSelectListSize"); + + reportFormFields.add(formField); + reportFormFields.add(formField1); + reportFormFields.add(formField2); + Mockito.when(rr.getReportFormFields()).thenReturn(reportFormFields); + raptorControllerAsync.listChildReportFormFields("reportID", mockedRequest, mockedResponse); + } + + @Test + public void getReportSecurityUsersTest() throws Exception { + ReportDefinition rdef = Mockito.mock(ReportDefinition.class); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + Vector vc = new Vector<>(); + vc.add(new SecurityEntry("1", "test", true)); + Mockito.when(rdef.getReportUsers(mockedRequest)).thenReturn(vc); + raptorControllerAsync.getReportSecurityUsers(mockedRequest); + } + + @Test + public void getReportSecurityRolesTest() throws Exception { + ReportDefinition rdef = Mockito.mock(ReportDefinition.class); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + Vector vc = new Vector<>(); + vc.add(new SecurityEntry("1", "test", true)); + Mockito.when(rdef.getReportRoles(mockedRequest)).thenReturn(vc); + raptorControllerAsync.getReportSecurityRoles(mockedRequest); + } + + public ReportDefinition mockReportDefinition() throws RaptorException { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getReportUserAccess()).thenReturn("test"); + DataSet datset = PowerMockito.mock(DataSet.class); + Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); + CustomReportType customReportType = new CustomReportType(); + customReportType.setReportType("test"); + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + customReportType.setFormFieldList(formFieldList); + customReportType.setPublic(true); + customReportType.setReportType("test"); + customReportType.setReportTitle("test"); + ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", + "1", true); + reportWrapper.setReportDefType("SQL-based"); + ReportDefinition reportDefinition = new ReportDefinition(reportWrapper, mockedRequest); + return reportDefinition; + } + @Test + public void retrieveDefTabWiseDataTest() throws Exception { + PowerMockito.mockStatic(AppUtils.class); + ReportDefinition rdef = mockReportDefinition(); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(rdef); + Map<String, String> pathVariables = new HashMap<>(); + pathVariables.put("id", "InSession"); + pathVariables.put("detailId", "test"); + Vector vc = new Vector<>(); + vc.add("test"); + PowerMockito.when(AppUtils.getQuickLinksMenuIDs()).thenReturn(vc); + raptorControllerAsync.retrieveDefTabWiseData(pathVariables, mockedRequest, mockedResponse); + } + + + } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamDateValueParserTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamDateValueParserTest.java new file mode 100644 index 00000000..88bcd6b9 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamDateValueParserTest.java @@ -0,0 +1,67 @@ +/* + * ============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.model.runtime; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class ReportParamDateValueParserTest { + + @Test + public void testIsDateHrParam() { + assertFalse(ReportParamDateValueParser.isDateHrParam("29-MAY-2018")); + } + + @Test + public void testIsDateParam() { + assertTrue(ReportParamDateValueParser.isDateParam("29-MAY-2018")); + } + + @Test + public void testFormatDateParamValue() { + assertNotNull(ReportParamDateValueParser.formatDateParamValue("29-MAY-2018")); + } + + @Test + public void testFormatDateHrParamValue() { + assertNotNull(ReportParamDateValueParser.formatDateHrParamValue("29-MAY-2018")); + } +}
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcelTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcelTest.java new file mode 100644 index 00000000..e9e43a7e --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcelTest.java @@ -0,0 +1,133 @@ +/* + * ============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.model.runtime; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.model.base.ReportWrapper; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.ConnectionUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.onap.portalsdk.core.util.SecurityCodecUtil; +import org.owasp.esapi.ESAPI; +import org.owasp.esapi.Encoder; +import org.owasp.esapi.codecs.Codec; +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, ESAPI.class, AppUtils.class, SecurityCodecUtil.class, ConnectionUtils.class}) +public class ReportParamValuesForPDFExcelTest { + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + + ReportParamValuesForPDFExcel reportParamValuesForPDFExcel; + ReportFormFields reportFormFields; + ReportRuntime rr; + @Before + public void setUp() throws RaptorException { + rr = Mockito.mock(ReportRuntime.class); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ReportWrapper rw = PowerMockito.mock(ReportWrapper.class); + reportFormFields = new ReportFormFields(rw, mockedRequest); + List predefinedValues = new ArrayList(); + FormField formField = Mockito.mock(FormField.class); + Mockito.when(formField.getFieldName()).thenReturn("fftest"); + Mockito.when(formField.getFieldDisplayName()).thenReturn("fieldDisplayName"); + Mockito.when(formField.getBaseSQLForPDFExcel()).thenReturn("select * from test"); + Mockito.when(formField.getFieldDefaultSQL()).thenReturn("select * from test"); + reportFormFields.add(formField); + Mockito.when(rr.getReportFormFields()).thenReturn(reportFormFields); + Mockito.when(rr.getReportType()).thenReturn("test"); + Mockito.when(mockedRequest.getSession().getAttribute("remoteDB")).thenReturn("test"); + PowerMockito.mockStatic(ESAPI.class); + PowerMockito.mockStatic(SecurityCodecUtil.class); + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test"); + Encoder encoder = PowerMockito.mock(Encoder.class); + Mockito.when(ESAPI.encoder()).thenReturn(encoder); + Codec codec = PowerMockito.mock(Codec.class); + Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec); + Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *"); + Mockito.when(Globals.getRequestParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParams()).thenReturn("test"); + Mockito.when(Globals.getSessionParamsForScheduling()).thenReturn("test"); + PowerMockito.mockStatic(ConnectionUtils.class); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(),Mockito.anyInt())).thenReturn("test"); + Mockito.when(ConnectionUtils.getDataSet(Mockito.anyString(),Mockito.anyString())).thenReturn(ds); + } + + @Test + public void testSetParamValues_WithCombo() throws Exception { + Mockito.when(reportFormFields.getFormField(0).getFieldType()).thenReturn(FormField.FFT_COMBO_BOX); + Mockito.when(reportFormFields.getFormField(0).getValidationType()).thenReturn(FormField.VT_TIMESTAMP_HR); + ReportParamValues params = new ReportParamValues(reportFormFields, "test"); + Mockito.when(rr.getParamKeys()).thenReturn(params.keys()); + reportParamValuesForPDFExcel = new ReportParamValuesForPDFExcel(reportFormFields, "test"); + reportParamValuesForPDFExcel.setParamValues(mockedRequest, true); + } + + @Test + public void testSetParamValues_WithCheckBox() throws Exception { + Mockito.when(reportFormFields.getFormField(0).getFieldType()).thenReturn(FormField.FFT_CHECK_BOX); + Mockito.when(reportFormFields.getFormField(0).getValidationType()).thenReturn(FormField.VT_TIMESTAMP_MIN); + ReportParamValues params = new ReportParamValues(reportFormFields, "test"); + Mockito.when(rr.getParamKeys()).thenReturn(params.keys()); + reportParamValuesForPDFExcel = new ReportParamValuesForPDFExcel(reportFormFields, "test"); + reportParamValuesForPDFExcel.setParamValues(mockedRequest, true); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/TimeSeriesChartOptionsTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/TimeSeriesChartOptionsTest.java new file mode 100644 index 00000000..1d555574 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/TimeSeriesChartOptionsTest.java @@ -0,0 +1,73 @@ +/* + * ============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.model.runtime; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class TimeSeriesChartOptionsTest { + TimeSeriesChartOptions timeSeriesChartOptions; + + private String LINE_CHART_RENDERER = "lineChartRenderer"; + private boolean MULTI_SERIES = true; + private boolean NON_TIME_AXIS = true; + private boolean SHOW_X_AXIS_LABEL = true; + private boolean ADD_X_AXIS_TICKER = true; + + @Before + public void init() { + timeSeriesChartOptions = new TimeSeriesChartOptions(); + timeSeriesChartOptions.setLineChartRenderer(LINE_CHART_RENDERER); + timeSeriesChartOptions.setMultiSeries(MULTI_SERIES);; + timeSeriesChartOptions.setNonTimeAxis(NON_TIME_AXIS); + timeSeriesChartOptions.setShowXAxisLabel(SHOW_X_AXIS_LABEL); + timeSeriesChartOptions.setAddXAxisTicker(ADD_X_AXIS_TICKER); + } + + @Test + public void testBarChartOptionsProperties() { + assertEquals(LINE_CHART_RENDERER, timeSeriesChartOptions.getLineChartRenderer()); + assertEquals(MULTI_SERIES, timeSeriesChartOptions.isMultiSeries()); + assertEquals(NON_TIME_AXIS, timeSeriesChartOptions.isNonTimeAxis()); + assertEquals(SHOW_X_AXIS_LABEL, timeSeriesChartOptions.isShowXAxisLabel()); + assertEquals(ADD_X_AXIS_TICKER, timeSeriesChartOptions.isAddXAxisTicker()); + } + +} |