summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics/src/test
diff options
context:
space:
mode:
authorLo, WEI-TING(wl849v) <wl849v@att.com>2018-03-19 17:37:22 -0400
committerLo, WEI-TING(wl849v) <wl849v@att.com>2018-03-19 17:37:22 -0400
commita932df953215fa4fe25d0dee962291eaa64d1846 (patch)
tree5106087e4723b93d6d3690ad37f560f6a7257e31 /ecomp-sdk/epsdk-analytics/src/test
parentdcdf1bb1838de59e16c63ab37b29fb913efe2f69 (diff)
Effort to make portal resilient
Issue-ID: PORTAL-210 Includes music library that contatins session management Change-Id: Icacab904e1f948068348fcc19cd77965cb5b446e Signed-off-by: Lo, WEI-TING(wl849v) <wl849v@att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/test')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportLoaderTest.java1165
1 files changed, 1165 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportLoaderTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportLoaderTest.java
new file mode 100644
index 00000000..6c1698dd
--- /dev/null
+++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportLoaderTest.java
@@ -0,0 +1,1165 @@
+/*
+ * ============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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.analytics.model;
+
+import static org.junit.Assert.*;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Vector;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.error.RaptorException;
+import org.onap.portalsdk.analytics.error.ReportSQLException;
+import org.onap.portalsdk.analytics.model.base.ReportWrapper;
+import org.onap.portalsdk.analytics.model.runtime.ReportRuntime;
+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.AppConstants;
+import org.onap.portalsdk.analytics.util.DataSet;
+import org.onap.portalsdk.analytics.util.Utils;
+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, DbUtils.class, Utils.class, AppUtils.class, ESAPI.class, Encoder.class,
+ SecurityCodecUtil.class, Codec.class })
+public class ReportLoaderTest {
+
+ @Mock
+ Connection connection;
+ @Mock
+ PreparedStatement stmt;
+ @Mock
+ ResultSet rs;
+
+ @Mock
+ InputStream inputStream;
+
+ @Mock
+ InputStreamReader in;
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void loadCustomReportXMLTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("testSql");
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isWeblogicServer()).thenReturn(true);
+ reportLoader.loadCustomReportXML("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void loadCustomReportXML1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("testSql");
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isWeblogicServer()).thenReturn(true);
+ Mockito.when(rs.next()).thenReturn(true);
+ java.sql.Clob clob = PowerMockito.mock(java.sql.Clob.class);
+ Mockito.when(rs.getClob(1)).thenReturn(clob);
+ Mockito.when(clob.getAsciiStream()).thenReturn(inputStream);
+ PowerMockito.whenNew(InputStreamReader.class).withArguments(Matchers.any(InputStream.class)).thenReturn(in);
+ reportLoader.loadCustomReportXML("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void loadCustomReportXML2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("testSql");
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isWeblogicServer()).thenReturn(false);
+ Mockito.when(rs.next()).thenReturn(true);
+ java.sql.Clob clob = PowerMockito.mock(java.sql.Clob.class);
+ Mockito.when(rs.getClob(1)).thenReturn(clob);
+ Mockito.when(clob.getAsciiStream()).thenReturn(inputStream);
+ PowerMockito.whenNew(InputStreamReader.class).withArguments(Matchers.any(InputStream.class)).thenReturn(in);
+ Mockito.when(in.read(Matchers.any(char[].class))).thenReturn(1);
+ reportLoader.loadCustomReportXML("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadCustomReportXML3Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("testSql");
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isWeblogicServer()).thenReturn(false);
+ Mockito.when(rs.next()).thenReturn(true);
+ java.sql.Clob clob = PowerMockito.mock(java.sql.Clob.class);
+ Mockito.when(rs.getClob(1)).thenReturn(clob);
+ Mockito.when(clob.getAsciiStream()).thenReturn(inputStream);
+ PowerMockito.whenNew(InputStreamReader.class).withArguments(Matchers.any(InputStream.class)).thenReturn(in);
+ Mockito.when(in.read(Matchers.any(char[].class))).thenReturn(1);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(true);
+ reportLoader.loadCustomReportXML("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadCustomReportXML4Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("testSql");
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isWeblogicServer()).thenReturn(false);
+ Mockito.when(rs.next()).thenReturn(true);
+ java.sql.Clob clob = PowerMockito.mock(java.sql.Clob.class);
+ Mockito.when(rs.getClob(1)).thenReturn(clob);
+ Mockito.when(clob.getAsciiStream()).thenReturn(inputStream);
+ PowerMockito.whenNew(InputStreamReader.class).withArguments(Matchers.any(InputStream.class)).thenReturn(in);
+ Mockito.when(in.read(Matchers.any(char[].class))).thenReturn(1);
+ Mockito.when(Globals.isMySQL()).thenReturn(true);
+ reportLoader.loadCustomReportXML("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void updateCustomReportRecTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getUpdateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(false);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ reportLoader.updateCustomReportRec(connection, rw, "test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateCustomReportRec1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getUpdateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(false);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(true);
+ Mockito.when(rs.next()).thenReturn(true);
+ reportLoader.updateCustomReportRec(connection, rw, "test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void updateCustomReportRec2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getUpdateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(false);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(true);
+ Mockito.when(rs.next()).thenReturn(false);
+ reportLoader.updateCustomReportRec(connection, rw, "test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void updateCustomReportRec3Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getUpdateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(true);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(false);
+ Mockito.when(rs.next()).thenReturn(false);
+ reportLoader.updateCustomReportRec(connection, rw, "test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateCustomReportRec4Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getUpdateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(true);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(false);
+ Mockito.when(rs.next()).thenReturn(true);
+ Mockito.when(rs.getBinaryStream("report_xml")).thenReturn(inputStream);
+ Mockito.when(Globals.getDBUpdateReportXmlMySql()).thenReturn("test");
+ reportLoader.updateCustomReportRec(connection, rw, "test");
+ }
+
+ // @SuppressWarnings("static-access")
+ // @Test
+ // public void isDashboardTypeTest() throws Exception
+ // {
+ // ReportLoader reportLoader = new ReportLoader();
+ // reportLoader.isDashboardType("test");
+ // }
+ @SuppressWarnings("static-access")
+ @Test
+ public void isReportsAlreadyScheduledTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getIsReportAlreadyScheduled()).thenReturn("testSql");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ reportLoader.isReportsAlreadyScheduled("1");
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void isReportsAlreadyScheduled1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getIsReportAlreadyScheduled()).thenReturn("testSql");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.next()).thenReturn(true);
+ reportLoader.isReportsAlreadyScheduled("1");
+
+ }
+
+ @SuppressWarnings({ "static-access", "unchecked" })
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void isReportsAlreadyScheduled2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getIsReportAlreadyScheduled()).thenReturn("testSql");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenThrow(SQLException.class);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.next()).thenReturn(true);
+ reportLoader.isReportsAlreadyScheduled("1");
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void isReportsAlreadyScheduled3Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getIsReportAlreadyScheduled()).thenReturn("testSql");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.next()).thenReturn(true);
+ Mockito.doThrow(SQLException.class).when(rs).close();
+ reportLoader.isReportsAlreadyScheduled("1");
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void createCustomReportRecTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getCreateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(rw.getCreateID()).thenReturn("test");
+ Mockito.when(rw.getFolderId()).thenReturn("1");
+ Mockito.when(rw.getCreateDate()).thenReturn("11/11/2010");
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("test");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(false);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(true);
+ Mockito.when(rs.next()).thenReturn(true);
+ reportLoader.createCustomReportRec(connection, rw, "test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getUserReportNamesTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(Globals.getTheUserReportNames()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getUserReportNames(mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getReportOwnerIDTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheReportOwnerId()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(rs.next()).thenReturn(true);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.getString(1)).thenReturn("test");
+ reportLoader.getReportOwnerID("1");
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void getReportOwnerID1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheReportOwnerId()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenThrow(SQLException.class);
+ Mockito.when(rs.next()).thenReturn(true);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.getString(1)).thenReturn("test");
+ reportLoader.getReportOwnerID("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void getReportOwnerID2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheReportOwnerId()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(rs.next()).thenReturn(true);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.getString(1)).thenReturn("test");
+ Mockito.doThrow(SQLException.class).when(rs).close();
+ reportLoader.getReportOwnerID("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void deleteReportRecordTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(DbUtils.startTransaction()).thenReturn(connection);
+ Mockito.when(Globals.getDeleteReportRecordLog()).thenReturn("test");
+ PowerMockito.mockStatic(ESAPI.class);
+ PowerMockito.mockStatic(SecurityCodecUtil.class);
+ Mockito.when(mockedRequest.getParameter("action")).thenReturn("test");
+ ReportRuntime rr = PowerMockito.mock(ReportRuntime.class);
+ Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr);
+ 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 *");
+ reportLoader.deleteReportRecord("test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void deleteReportRecord1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(DbUtils.startTransaction()).thenReturn(connection);
+ Mockito.when(Globals.getDeleteReportRecordLog()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordUsers()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordSchedule()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordAccess()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordEmail()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordFavorite()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordReport()).thenReturn("test");
+ PowerMockito.mockStatic(ESAPI.class);
+ PowerMockito.mockStatic(SecurityCodecUtil.class);
+ Mockito.when(mockedRequest.getParameter("action")).thenReturn("test");
+ ReportRuntime rr = PowerMockito.mock(ReportRuntime.class);
+ Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr);
+ 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 *");
+ reportLoader.deleteReportRecord("test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadQuickLinksTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadQuickLinks()).thenReturn("testsql");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ reportLoader.loadQuickLinks(mockedRequest, "1", true);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getQuickLinksJSONTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadQuickLinks()).thenReturn("test");
+ PowerMockito.mockStatic(ESAPI.class);
+ PowerMockito.mockStatic(SecurityCodecUtil.class);
+ Mockito.when(mockedRequest.getParameter("action")).thenReturn("test");
+ ReportRuntime rr = PowerMockito.mock(ReportRuntime.class);
+ Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr);
+ 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 *");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ reportLoader.getQuickLinksJSON(mockedRequest, "1", true);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadFolderReportsTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadFolderReports()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsUser()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsPublicSql()).thenReturn("test");
+
+ Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(true);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when( ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadFolderReports(mockedRequest, "1", true, "folderId", true, true);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadFolderReports1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadFolderReports()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsUser()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsPublicSql()).thenReturn("test");
+
+ Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(false);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when( ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadFolderReports(mockedRequest, "1", true, "folderId", false, true);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadFolderReports2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadFolderReports()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsUser()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsPublicSql()).thenReturn("test");
+
+ Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(false);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when( ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadFolderReports(mockedRequest, "1", true, "folderId", false, false);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadQuickDownloadLinksTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getLoadQuickDownloadLinks()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadQuickDownloadLinks("test", mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadQuickDownloadLinks1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getLoadQuickDownloadLinks()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadQuickDownloadLinks("test", mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportsToScheduleTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadReportsToSchedule()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportsToSchedule(mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportsToSchedule1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadReportsToSchedule()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportsToSchedule(mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportsToAddInDashboardTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadReportsToAddInDashboard()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportsToAddInDashboard(mockedRequest);
+ }
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportsToAddInDashboard1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadReportsToAddInDashboard()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportsToAddInDashboard(mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportsToAddInDashboard2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadReportsToAddInDashboard()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportsToAddInDashboard(mockedRequest);
+ }
+
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadMyRecentLinksTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadMyRecentLinks()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadMyRecentLinks("test",mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadMyRecentLinks1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadMyRecentLinks()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadMyRecentLinks("test",mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void createReportLogEntryTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getCreateReportLogEntry()).thenReturn("test");
+ Mockito.when(Globals.getEnableReportLog()).thenReturn(true);
+ reportLoader.createReportLogEntry(connection, "test", "test", "test", "executionTime", "form_fields");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void createReportLogEntry1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getCreateReportLogEntry()).thenReturn("test");
+ Mockito.when(Globals.getEnableReportLog()).thenReturn(true);
+ reportLoader.createReportLogEntry(null, "test", "test", "test", "executionTime", "form_fields");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void createReportLogEntryForExecutionTimeTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getCreateReportLogEntryExecTime()).thenReturn("test");
+ Mockito.when(Globals.getEnableReportLog()).thenReturn(true);
+ reportLoader.createReportLogEntryForExecutionTime(connection, "test", "test", "test", "executionTime", "form_fields");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void createReportLogEntryForExecutionTime1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getCreateReportLogEntryExecTime()).thenReturn("test");
+ Mockito.when(Globals.getEnableReportLog()).thenReturn(true);
+ reportLoader.createReportLogEntryForExecutionTime(null, "test", "test", "test", "executionTime", "form_fields");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void clearReportLogEntriesTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getClearReportLogEntries()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ reportLoader.clearReportLogEntries("1","2");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void clearReportLogEntries1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getClearReportLogEntries()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.doThrow(SQLException.class).when(stmt).close();
+ reportLoader.clearReportLogEntries("1","2");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void clearReportLogEntries2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getClearReportLogEntries()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenThrow(SQLException.class);
+ reportLoader.clearReportLogEntries("1","2");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportLogEntriesTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getLoadReportLogEntries()).thenReturn("test");
+ Mockito.when(AppUtils.getRaptorActionURL()).thenReturn("test");
+ Mockito.when(AppUtils.getImgFolderURL()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportLogEntries("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportLogEntries1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getLoadReportLogEntries()).thenReturn("test");
+ Mockito.when(AppUtils.getRaptorActionURL()).thenReturn("test");
+ Mockito.when(AppUtils.getImgFolderURL()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportLogEntries("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void doesUserCanScheduleReportTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true);
+ reportLoader.doesUserCanScheduleReport(mockedRequest, "1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void doesUserCanScheduleReport1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false);
+ Mockito.when(Globals.getDoesUserCanScheduleReport()).thenReturn("test");
+ Mockito.when(Globals.getScheduleLimit()).thenReturn(1);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(Globals.getDoesUserCanSchedule()).thenReturn("1");
+
+ reportLoader.doesUserCanScheduleReport(mockedRequest, "1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void doesUserCanScheduleReport2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false);
+ Mockito.when(Globals.getDoesUserCanScheduleReport()).thenReturn("test");
+ Mockito.when(Globals.getScheduleLimit()).thenReturn(1);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(Globals.getDoesUserCanSchedule()).thenReturn("1");
+
+ reportLoader.doesUserCanScheduleReport(mockedRequest, "1");
+ }
+ @SuppressWarnings("static-access")
+ @Test
+ public void doesUserCanScheduleReport3Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false);
+ Mockito.when(Globals.getDoesUserCanScheduleReport()).thenReturn("test");
+ Mockito.when(Globals.getScheduleLimit()).thenReturn(1);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(Globals.getDoesUserCanSchedule()).thenReturn("1");
+ reportLoader.doesUserCanScheduleReport(mockedRequest, null);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getSystemDateTimeTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheSystemDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getSystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getSystemDateTime1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheSystemDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getSystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNextDaySystemDateTimeTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextDayDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNextDaySystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNextDaySystemDateTime1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextDayDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNextDaySystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNext15MinutesOfSystemDateTimeTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextFifteenMinDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNext15MinutesOfSystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNext15MinutesOfSystemDateTime1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextFifteenMinDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNext15MinutesOfSystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNext30MinutesOfSystemDateTimeTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextThirtyMinDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNext15MinutesOfSystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNext30MinutesOfSystemDateTime1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextThirtyMinDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNext30MinutesOfSystemDateTime();
+ }
+}