summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/BarChartOptionsTest.java79
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ChartWebRuntimeTest.java117
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/CommonChartOptionsTest.java81
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ErrorJSONRuntimeTest.java63
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FlexTimeSeriesChartOptionsTest.java64
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessorTest.java82
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ItemTest.java63
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/LookupDBInfoTest.java67
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RangeAxisJSONTest.java77
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RaptorControllerAsyncTest.java102
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamDateValueParserTest.java67
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/ReportParamValuesForPDFExcelTest.java133
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/TimeSeriesChartOptionsTest.java73
13 files changed, 1067 insertions, 1 deletions
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());
+ }
+
+}