summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics/src
diff options
context:
space:
mode:
authorKishore Reddy, Gujja (kg811t) <kg811t@research.att.com>2018-03-20 11:50:44 -0400
committerKishore Reddy, Gujja (kg811t) <kg811t@research.att.com>2018-03-20 11:50:44 -0400
commit996036b832bca89a197fe496c666057835ce043c (patch)
tree525804169287b7bc177e6d2be0060a1695282dcf /ecomp-sdk/epsdk-analytics/src
parent50125440c5371ae710674fec2b8d8f817aa1b4e4 (diff)
Added Junits
Issue-ID: PORTAL-136 Includes JUNITS Change-Id: I1a0109649d32c3031ce441a873dbfdda2d6cc011 Change-Id: I1a0109649d32c3031ce441a873dbfdda2d6cc011 Signed-off-by: Kishore Reddy, Gujja (kg811t) <kg811t@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ActionHandlerTest.java (renamed from ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionHandlerTest.java)113
1 files changed, 95 insertions, 18 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionHandlerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ActionHandlerTest.java
index 2c9a30b0..dae5a90d 100644
--- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/controller/ActionHandlerTest.java
+++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/xmlobj/ActionHandlerTest.java
@@ -35,7 +35,7 @@
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.onap.portalsdk.analytics.controller;
+package org.onap.portalsdk.analytics.xmlobj;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
@@ -58,6 +58,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -65,26 +66,20 @@ import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.onap.portalsdk.analytics.controller.ActionHandler;
import org.onap.portalsdk.analytics.model.ReportLoader;
import org.onap.portalsdk.analytics.model.SearchHandler;
import org.onap.portalsdk.analytics.model.base.ReportWrapper;
import org.onap.portalsdk.analytics.model.definition.ReportDefinition;
import org.onap.portalsdk.analytics.model.runtime.ChartWebRuntime;
+import org.onap.portalsdk.analytics.model.runtime.FormField;
+import org.onap.portalsdk.analytics.model.runtime.ReportFormFields;
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.xmlobj.ChartAdditionalOptions;
-import org.onap.portalsdk.analytics.xmlobj.CustomReportType;
-import org.onap.portalsdk.analytics.xmlobj.DashboardReports;
-import org.onap.portalsdk.analytics.xmlobj.DataColumnList;
-import org.onap.portalsdk.analytics.xmlobj.DataColumnType;
-import org.onap.portalsdk.analytics.xmlobj.DataSourceList;
-import org.onap.portalsdk.analytics.xmlobj.DataSourceType;
-import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite;
-import org.onap.portalsdk.analytics.xmlobj.Reports;
import org.onap.portalsdk.core.logging.format.AlarmSeverityEnum;
import org.onap.portalsdk.core.util.SecurityCodecUtil;
import org.onap.portalsdk.core.web.support.UserUtils;
@@ -123,6 +118,7 @@ public class ActionHandlerTest {
HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
@Test
public void reportRunExceptionTest() {
when(mockedRequest.getParameter("action")).thenReturn("test");
@@ -131,6 +127,7 @@ public class ActionHandlerTest {
assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class);
}
+ @SuppressWarnings("unchecked")
@Test
public void reportRunRaptorReportExceptionTest() throws Exception {
PowerMockito.mockStatic(Globals.class);
@@ -138,14 +135,17 @@ public class ActionHandlerTest {
PowerMockito.mockStatic(ReportLoader.class);
PowerMockito.mockStatic(ReportWrapper.class);
PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mock(AppConstants.class);
PowerMockito.mockStatic(ReportDefinition.class);
PowerMockito.mockStatic(ESAPI.class);
PowerMockito.mockStatic(SecurityCodecUtil.class);
when(mockedRequest.getParameter("action")).thenReturn("test");
when(AppUtils.getRequestFlag(mockedRequest, "fromDashboard")).thenReturn(false);
- when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test");
+ when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("testxyz");
ReportRuntime rr = PowerMockito.mock(ReportRuntime.class);
when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr);
+ when(mockedRequest.getSession().getAttribute("FirstDashReport")).thenReturn(rr);
+ when(mockedRequest.getParameter(AppConstants.RI_ACTION)).thenReturn("report.download");
Encoder encoder = PowerMockito.mock(Encoder.class);
when(ESAPI.encoder()).thenReturn(encoder);
Codec codec = PowerMockito.mock(Codec.class);
@@ -167,9 +167,7 @@ public class ActionHandlerTest {
when(rs.next()).thenReturn(true);
when(clob.getAsciiStream()).thenReturn(in);
when(in.read(Matchers.any())).thenReturn(1);
- when(AppUtils.getRequestNvlValue(mockedRequest, "pdfAttachmentKey")).thenReturn("test");
when(AppUtils.nvl(rr.getLegendLabelAngle())).thenReturn("standard");
- when(AppUtils.getRequestNvlValue(Matchers.any(), Matchers.anyString())).thenReturn("test");
when(AppUtils.nvl("Y")).thenReturn("Y");
when(AppUtils.nvl("bottom")).thenReturn("Y");
when(AppUtils.nvl("test")).thenReturn("test|");
@@ -187,15 +185,90 @@ public class ActionHandlerTest {
when(Globals.getReportUserAccess()).thenReturn("[reportID]");
when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(set);
when(set.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
- whenNew(ReportRuntime.class).withArguments(Matchers.any(CustomReportType.class), Matchers.anyString(),
- Matchers.any(HttpServletRequest.class), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyBoolean()).thenReturn(rr);
when(ReportLoader.loadCustomReportXML("test2")).thenReturn(str);
+ 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);
+ List formFieldTypeList = new ArrayList<>();
+ formFieldTypeList.add(formFieldType);
+ FormFieldList formFieldList = PowerMockito.mock(FormFieldList.class);
+ when(formFieldList.getFormField()).thenReturn(formFieldTypeList);
+ Mockito.when(crType.getFormFieldList()).thenReturn(formFieldList);
+ when(Globals.getRequestParams()).thenReturn("test,case");
+ when( Globals.getSessionParams()).thenReturn("test,abc");
+ when(Globals.getSessionParamsForScheduling()).thenReturn("test");
+
+ DataSourceList dataSourceList = new DataSourceList();
+ List<DataSourceType> list = new ArrayList<>();
+ DataSourceType dataSourceType = new DataSourceType();
+ dataSourceType.setTableName("test");
+ dataSourceType.setRefTableId("1");
+ dataSourceType.setTableId("1");
+ List<DataColumnType> dataColumnTypeList = new ArrayList<>();
+ DataColumnType dataColumnType = new DataColumnType();
+ dataColumnType.setChartGroup("test");
+ dataColumnType.setYAxis("test");
+ dataColumnType.setColName("[test");
+ dataColumnType.setColOnChart("LEGEND");
+ dataColumnType.setDisplayName("chart_total");
+ dataColumnType.setColId("1");
+ dataColumnType.setTableId("1");
+ dataColumnType.setColType("DATE");
+ dataColumnType.setCrossTabValue("ROW");
+ dataColumnType.setPdfDisplayWidthInPxls("0.0");
+ dataColumnType.setVisible(true);
+ dataColumnType.setCalculated(true);
+ dataColumnTypeList.add(dataColumnType);
+ DataColumnType dataColumnType1 = new DataColumnType();
+ dataColumnType1.setCrossTabValue("COLUMN");
+ dataColumnType1.setColId("1");
+ dataColumnType1.setVisible(true);
+ dataColumnType1.setPdfDisplayWidthInPxls("1.0");
+ dataColumnTypeList.add(dataColumnType1);
+
+ DataColumnList dataColumnList = new DataColumnList();
+ dataColumnList.dataColumn = dataColumnTypeList;
+ dataSourceType.setDataColumnList(dataColumnList);
+ list.add(dataSourceType);
+ dataSourceList.dataSource = list;
+ when(crType.getDataSourceList()).thenReturn(dataSourceList);
+ when(rr.getReportType()).thenReturn(AppConstants.RT_DASHBOARD);
+ List predefinedValues = new ArrayList<>();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ ReportFormFields reportFormFields = new ReportFormFields(rw, mockedRequest);
+ FormField formField = new FormField("test", "fieldDisplayName", FormField.FFT_COMBO_BOX, "validationType", false,
+ "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL",
+ "rangeEndDateSQL", "multiSelectListSize");
+ FormField formField1 = new FormField("test", "fieldDisplayName", FormField.FFT_LIST_MULTI, "validationType", false,
+ "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL",
+ "rangeEndDateSQL", "multiSelectListSize");
+ FormField formField2 = new FormField("test", "fieldDisplayName", FormField.FFT_BLANK, "validationType", false,
+ "defaultValue", "helpText", predefinedValues, false, "dependsOn", null, null, "rangeStartDateSQL",
+ "rangeEndDateSQL", "multiSelectListSize");
+
+ reportFormFields.add(formField);
+ reportFormFields.add(formField1);
+ reportFormFields.add(formField2);
+ rr.setReportFormFields(null);
+ rr.setReportFormFields(reportFormFields);
+ when(rr.getReportFormFields()).thenReturn(reportFormFields);
+ when(mockedRequest.getSession().getAttribute("remoteDB")).thenReturn("test");
+ Enumeration<String> enums;
+ Vector<String> attrs = new Vector<String>();
+ attrs.add("ff_test");
+ enums = attrs.elements();
+ when(rr.getParamKeys()).thenReturn(enums);
assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class);
}
+
@Test
public void reportRunForCSVDownloadTest() throws Exception {
when(mockedRequest.getParameter("action")).thenReturn("test");
@@ -278,6 +351,7 @@ public class ActionHandlerTest {
return rr;
}
+
@Test
public void reportRunTestCase1() throws Exception {
when(mockedRequest.getParameter("action")).thenReturn("test");
@@ -307,6 +381,7 @@ public class ActionHandlerTest {
assertEquals(actionHandler.reportRun(mockedRequest, "test").getClass(), String.class);
}
+
@Test
public void reportDeleteTest() throws Exception {
PowerMockito.mockStatic(ESAPI.class);
@@ -335,7 +410,8 @@ public class ActionHandlerTest {
when(session.getAttribute(Matchers.anyString())).thenReturn(rd);
assertEquals(actionHandler.reportDelete(mockedRequest, "10").getClass(), String.class);
}
-
+
+
@Test
public void reportSearchTest() throws Exception {
PowerMockito.mockStatic(ESAPI.class);
@@ -382,6 +458,7 @@ public class ActionHandlerTest {
actionHandler.reportSearch(mockedRequest, "10");
}
+
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test(expected = NullPointerException.class)
public void reportChartRunTest() throws Exception {