diff options
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition')
12 files changed, 1138 insertions, 30 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DBColumnInfoTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DBColumnInfoTest.java new file mode 100644 index 00000000..c4e9d7f4 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DBColumnInfoTest.java @@ -0,0 +1,73 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class DBColumnInfoTest { + + DBColumnInfo dbColumnInfo; + + private String TABLE_NAME = "tableName"; + private String COL_NAME = "colName"; + private String COL_TYPE = "colType"; + private String LABEL = "label"; + + @Before + public void init() { + dbColumnInfo = new DBColumnInfo(TABLE_NAME, COL_NAME, COL_TYPE, LABEL); + } + + @Test + public void testNotNull() { + assertNotNull(dbColumnInfo); + } + + @Test + public void testDBColumnInfoProperties() { + assertEquals(TABLE_NAME, dbColumnInfo.getTableName()); + assertEquals(COL_NAME, dbColumnInfo.getColName()); + assertEquals(COL_TYPE, dbColumnInfo.getColType()); + assertEquals(LABEL, dbColumnInfo.getLabel()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DrillDownParamDefTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DrillDownParamDefTest.java new file mode 100644 index 00000000..df1d5693 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/DrillDownParamDefTest.java @@ -0,0 +1,62 @@ +/* + * ============LICENxSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class DrillDownParamDefTest { + + DrillDownParamDef drillDownParamDef; + String DRILL_DOWN_PARAM_DEF_STR = "fieldName=[valColId!valFieldId]"; + + @Before + public void init() { + drillDownParamDef = new DrillDownParamDef(DRILL_DOWN_PARAM_DEF_STR); + } + + @Test + public void testDrillDownParamDefProperties() { + assertEquals("fieldName", drillDownParamDef.getFieldName()); + assertEquals("valColId", drillDownParamDef.getValColId()); + assertEquals("valFieldId", drillDownParamDef.getValFieldId()); + assertEquals("4", drillDownParamDef.getValType()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/MarkerTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/MarkerTest.java new file mode 100644 index 00000000..3aa5d24e --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/MarkerTest.java @@ -0,0 +1,79 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class MarkerTest { + + Marker marker; + + private String MARKER_COLOR = "markerColor"; + private String ADDRESS_COLUMN = "addressColumn"; + private String DATA_COLUMN = "dataColumn"; + private String ADDRESS = "address"; + private String DATA = "data"; + private String COLOR = "color"; + + @Before + public void init() { + marker = new Marker(MARKER_COLOR, ADDRESS_COLUMN, DATA_COLUMN); + marker.setAddress(ADDRESS); + marker.setData(DATA); + marker.setColor(COLOR); + } + + @Test + public void testNotNull() { + assertNotNull(marker); + } + + @Test + public void testMarkerProperties() { + assertEquals(MARKER_COLOR, marker.getMarkerColor()); + assertEquals(ADDRESS_COLUMN, marker.getAddressColumn()); + assertEquals(DATA_COLUMN, marker.getDataColumn()); + assertEquals(DATA, marker.getData()); + assertEquals(COLOR, marker.getColor()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportLogEntryTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportLogEntryTest.java new file mode 100644 index 00000000..d92f2565 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportLogEntryTest.java @@ -0,0 +1,75 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class ReportLogEntryTest { + + ReportLogEntry reportlogEntry; + + private String LOGTIME = "logTime"; + private String USERNAME = "userName"; + private String ACTION = "action"; + private String TIME_TAKEN = "timeTaken"; + private String RUN_ICON = "runIcon"; + + @Before + public void init() { + reportlogEntry = new ReportLogEntry(LOGTIME, USERNAME, ACTION, TIME_TAKEN, RUN_ICON); + } + + @Test + public void testNotNull() { + assertNotNull(reportlogEntry); + } + + @Test + public void testReportLogEntryProperties() { + assertEquals(LOGTIME, reportlogEntry.getLogTime()); + assertEquals(USERNAME, reportlogEntry.getUserName()); + assertEquals(ACTION, reportlogEntry.getAction()); + assertEquals(TIME_TAKEN, reportlogEntry.getTimeTaken()); + assertEquals(RUN_ICON, reportlogEntry.getRunIcon()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportMapTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportMapTest.java new file mode 100644 index 00000000..fcbae7bc --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportMapTest.java @@ -0,0 +1,75 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class ReportMapTest { + + ReportMap reportMap; + + private String MARKER_COLOR = "markerColor"; + private String ADDRESS_COLUMN = "addressColumn"; + private String DATA_COLUMN = "dataColumn"; + private String IS_MAP_ALLOWED_YN = "isMapAllowedYN"; + private String ADD_ADDRESS_IN_DATA_YN = "addAddressInDataYN"; + + @Before + public void init() { + reportMap = new ReportMap(MARKER_COLOR, ADDRESS_COLUMN, DATA_COLUMN, IS_MAP_ALLOWED_YN, ADD_ADDRESS_IN_DATA_YN); + } + + @Test + public void testNotNull() { + assertNotNull(reportMap); + } + + @Test + public void testReportMapProperties() { + assertEquals(MARKER_COLOR, reportMap.getMarkerColor()); + assertEquals(ADDRESS_COLUMN, reportMap.getAddressColumn()); + assertEquals(DATA_COLUMN, reportMap.getDataColumn()); + assertEquals(IS_MAP_ALLOWED_YN, reportMap.getIsMapAllowedYN()); + assertEquals(ADD_ADDRESS_IN_DATA_YN, reportMap.getAddAddressInDataYN()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java index 40ab05de..3ba80d9f 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/ReportScheduleTest.java @@ -37,36 +37,56 @@ */ package org.onap.portalsdk.analytics.model.definition; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.FileInputStream; import java.io.InputStream; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.portalsdk.analytics.error.RaptorException; import org.onap.portalsdk.analytics.error.ReportSQLException; +import org.onap.portalsdk.analytics.model.base.IdNameValue; +import org.onap.portalsdk.analytics.model.runtime.FormField; +import org.onap.portalsdk.analytics.model.runtime.ReportParamValues; import org.onap.portalsdk.analytics.model.runtime.ReportRuntime; import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.ConnectionUtils; import org.onap.portalsdk.analytics.system.DbUtils; import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.AppConstants; import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; +import org.onap.portalsdk.analytics.xmlobj.DataSourceType; +import org.onap.portalsdk.analytics.xmlobj.FormFieldList; +import org.onap.portalsdk.analytics.xmlobj.FormFieldType; import org.owasp.esapi.ESAPI; import org.owasp.esapi.Encoder; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import com.mchange.v2.debug.ThreadNameStackTraceRecorder; + @RunWith(PowerMockRunner.class) -@PrepareForTest({ AppUtils.class, Globals.class, DbUtils.class, AppUtils.class, ESAPI.class}) +@PrepareForTest({ AppUtils.class, Globals.class, DbUtils.class, AppUtils.class, ESAPI.class, ConnectionUtils.class, ReportSchedule.class}) public class ReportScheduleTest { @@ -116,7 +136,8 @@ public class ReportScheduleTest { PowerMockito.mockStatic(DbUtils.class); PowerMockito.mockStatic(AppUtils.class); PowerMockito.mockStatic(ESAPI.class); - + PowerMockito.mockStatic(ConnectionUtils.class); + MockitoAnnotations.initMocks(this); Mockito.when(httpSession.getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(reportRuntime); @@ -166,7 +187,13 @@ public class ReportScheduleTest { Mockito.when(dataSet1.getString(Mockito.anyInt(), Mockito.anyString())).thenReturn("Some Value2"); reportSchedule = new ReportSchedule(REPORT_ID, USER_ID, true, httpServletRequest); - + reportSchedule.setEncryptMode("test"); + reportSchedule.setEndAMPM("AM"); + reportSchedule.setEndHour("10"); + reportSchedule.setEndMin("00"); + reportSchedule.addZero("0"); + + /* Mockito.when(dataSet1.getString(Mockito.anyInt(), Mockito.anyObject())).thenAnswer(new Answer<String>() { @@ -345,6 +372,353 @@ public class ReportScheduleTest { reportSchedule.persistScheduleData(connection, httpServletRequest); } + @Test + public void testPersistScheduleData_FormFieldList_case1() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("test"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn(""); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE AND [test] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case2() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("test"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("DAYTONA"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [test] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case3() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldType.setValidationType(FormField.VT_TIMESTAMP_MIN); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("report_id"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("DAYTONA"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [report_id] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case4() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldType.setValidationType(FormField.VT_TIMESTAMP_MIN); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("report_id"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("DAYTONA"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [report_id] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + @Test + public void testPersistScheduleData_FormFieldList_case5() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + + FormFieldList formFieldList = new FormFieldList(); + formFieldList.setComment("test"); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("test"); + formFieldType.setColId("1"); + formFieldType.setFieldName("test"); + formFieldType.setFieldType("type"); + formFieldType.setValidationType("validation"); + formFieldType.setMandatory("Y"); + formFieldType.setDefaultValue("test"); + formFieldType.setGroupFormField(true); + formFieldType.setValidationType(FormField.VT_TIMESTAMP_SEC); + formFieldList.getFormField().add(formFieldType); + Mockito.when(reportRuntime.getFormFieldList()).thenReturn(formFieldList); + Mockito.when(reportRuntime.getFormFieldDisplayName(Mockito.any(FormFieldType.class))).thenReturn("report_id"); + ReportParamValues paramValues = PowerMockito.mock(ReportParamValues.class); + Mockito.when(paramValues.isParameterMultiValue(Matchers.anyString())).thenReturn(false); + Mockito.when(paramValues.isParameterTextAreaValueAndModified(Mockito.any(String.class))).thenReturn(true); + Mockito.when(paramValues.getParamValue(Mockito.any(String.class))).thenReturn("select test"); + Mockito.when(reportRuntime.getReportParamValues()).thenReturn(paramValues); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.any(String.class))).thenReturn("TESTDB"); + Mockito.when(reportRuntime.formatListValue(Mockito.any(String.class), Mockito.any(String.class), Mockito.any(DataColumnType.class), + Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(DataSourceType.class), Mockito.any(String.class))).thenReturn("test"); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(resultSet.next()).thenReturn(true); + + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setConditionSQL("SELECT WHEN FROM TABLE WHERE [test] ORDER BY"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + + + @Test + public void testPersistScheduleData_WithRaptorException() throws Exception { + String execute_update = "DELETE FROM cr_report_schedule_users WHERE rep_id = [reportID] and schedule_id = [getScheduleID()]"; + String execute_update_users = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], [emailToUsers.get(i)).getId()], NULL, [(i + 1)])"; + String execute_update_roles = "INSERT INTO cr_report_schedule_users (schedule_id, rep_id, user_id, role_id, order_no) VALUES([getScheduleID()], [reportID], NULL, [emailToRoles.get(i)).getId()], [((emailToUsers.size() + i + 1)])"; + String execute_update_activity = "INSERT into cr_schedule_activity_log (schedule_id, notes, run_time) values ([getScheduleID()],'Submitted:Schedule',TO_DATE('[getRunDate()] [getRunHour()]:[getRunMin()] [getRunAMPM()]', 'MM/DD/YYYY HH:MI AM'))"; + String persist_cond_sql_update = "update cr_report_schedule set condition_large_sql = '' where schedule_id = [scheduleId]"; + String new_schedule_data = "select coalesce(max(schedule_id),0)+1 AS sequence from cr_report_schedule"; + String persist_cond_sql_set = "update cr_report_schedule set condition_sql = ? where schedule_id = [scheduleId]"; + + PowerMockito.when(DbUtils.executeQuery(Mockito.anyObject(), Mockito.anyString())).thenReturn(dataSet1); + PowerMockito.when(Globals.getExecuteUpdate()).thenReturn(execute_update); + PowerMockito.when(Globals.getExecuteUpdateUsers()).thenReturn(execute_update_users); + PowerMockito.when(Globals.getExecuteUpdateRoles()).thenReturn(execute_update_roles); + PowerMockito.when(Globals.getExecuteUpdateActivity()).thenReturn(execute_update_activity); + PowerMockito.when(Globals.getPersistCondSqlUpdate()).thenReturn(persist_cond_sql_update); + PowerMockito.when(Globals.isPostgreSQL()).thenReturn(true); + PowerMockito.when(Globals.getPersistCondSqlSet()).thenReturn(persist_cond_sql_update); + + PowerMockito.when(Globals.getRequestParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParams()).thenReturn("1, 2, 3"); + PowerMockito.when(Globals.getSessionParamsForScheduling()).thenReturn("login_id"); + PowerMockito.when(Globals.getNewScheduleData()).thenReturn(new_schedule_data); + Mockito.when(reportRuntime.getDBInfo()).thenReturn(AppConstants.DB_DEV); + + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeUpdate()).thenReturn(1); + Mockito.when(resultSet.next()).thenReturn(false); + Mockito.when(dataSet1.getRowCount()).thenReturn(0); + + + reportSchedule.setSchedEnabled("N"); + reportSchedule.setStartDate("10/10/2018"); + reportSchedule.setEndDate("10/10/2019"); + reportSchedule.setRunDate("10/10/2019"); + reportSchedule.setRecurrence("Y"); + reportSchedule.addEmailToUser("UserID1", "UserName1"); + reportSchedule.addEmailToRole("roleId1", "roleName1"); + reportSchedule.setConditionSQL("SELECT coalesce(cr.owner_id, cr.create_id) owner_id, cr.create_id, DATE_FORMAT(cr.create_date, '[Globals.getTimeFormat()]') create_date, maint_id, DATE_FORMAT(cr.maint_date, '[Globals.getTimeFormat()]') update_date, cr.menu_id, cr.menu_approved_yn FROM cr_report cr WHERE cr.rep_id= [reportID]"); + + reportSchedule.persistScheduleData(connection, httpServletRequest); + } + @Test public void testDeleteScheduleData_case1() throws RaptorException { @@ -416,10 +790,9 @@ public class ReportScheduleTest { ReportSchedule.loadConditionalSQL("scheduleId#123"); } - /* - @Test - public void testLoadConditionalSQL_Error_case2() throws Exception { + @Test(expected=RaptorException.class) + public void testLoadConditionalSQL_Error_case2() throws Exception { String load_cond_sql = "SELECT condition_large_sql FROM cr_report_schedule WHERE schedule_id=?"; Mockito.when(DbUtils.getConnection()).thenReturn(connection); Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); @@ -433,50 +806,73 @@ public class ReportScheduleTest { PowerMockito.when(Globals.getLoadCondSql()).thenReturn(load_cond_sql); ReportSchedule.loadConditionalSQL("scheduleId#123"); - }*/ - + } - /* + @Test + public void testLoadConditionalSQL_Error_case3() throws Exception { + String load_cond_sql = "SELECT condition_large_sql FROM cr_report_schedule WHERE schedule_id=?"; + Mockito.when(DbUtils.getConnection()).thenReturn(connection); + Mockito.when(connection.prepareStatement(Mockito.anyString())).thenReturn(preparedStatement); + Mockito.when(preparedStatement.executeQuery()).thenReturn(resultSet); + Mockito.when(Globals.isWeblogicServer()).thenReturn(false); + Mockito.when(Globals.isPostgreSQL()).thenReturn(false); + Mockito.when(Globals.isMySQL()).thenReturn(true); + + Mockito.when(resultSet.next()).thenReturn(true); + Mockito.when(resultSet.getString(1)).thenThrow(new SQLException()); + PowerMockito.when(Globals.getLoadCondSql()).thenReturn(load_cond_sql); + + ReportSchedule.loadConditionalSQL("scheduleId#123"); + } + @Test public void testAddEmailArrayToUser() { - fail("Not yet implemented"); + ArrayList<IdNameValue> allSelectedUsers= new ArrayList<>(); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("1"); + idNameValue.setName("test"); + idNameValue.setReadOnly(true); + idNameValue.setDefaultValue(true); + allSelectedUsers.add(idNameValue); + reportSchedule.addEmailArrayToUser(allSelectedUsers); + assertEquals("1",((IdNameValue)reportSchedule.getEmailToUsers().get(0)).getId()); } @Test public void testRemoveEmailToUser() { - fail("Not yet implemented"); + reportSchedule.removeEmailToUser("1"); } - @Test - public void testAddEmailToRole() { - fail("Not yet implemented"); - } @Test public void testAddEmailArrayToRole() { - fail("Not yet implemented"); + ArrayList<IdNameValue> allSelectedUsers= new ArrayList<>(); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("roleID1"); + idNameValue.setName("roleName1"); + idNameValue.setReadOnly(true); + idNameValue.setDefaultValue(true); + allSelectedUsers.add(idNameValue); + reportSchedule.addEmailArrayToRole(allSelectedUsers); + assertEquals("roleID1",((IdNameValue)reportSchedule.getEmailToRoles().get(0)).getId()); } - + @Test public void testRemoveEmailToRole() { - fail("Not yet implemented"); + reportSchedule.removeEmailToRole("roleID1"); } @Test - public void testPersistScheduleData() { - fail("Not yet implemented"); + public void testIsAttachmentMode() { + reportSchedule.setAttachmentMode("Y"); + assertTrue(reportSchedule.isAttachmentMode()); } @Test - public void testDeleteScheduleData() { - fail("Not yet implemented"); + public void testSetConditional() { + reportSchedule.setConditional("Y"); + assertEquals("Y",reportSchedule.getConditional()); } - - @Test - public void testLoadConditionalSQL() { - fail("Not yet implemented"); - } - */ - + } diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/SecurityEntryTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/SecurityEntryTest.java new file mode 100644 index 00000000..156a2adf --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/SecurityEntryTest.java @@ -0,0 +1,71 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class SecurityEntryTest { + + SecurityEntry securityEntry; + + private String ID = "testID"; + private String NAME = "testName"; + private boolean READ_ONLY = true; + + @Before + public void init() { + securityEntry = new SecurityEntry(ID, NAME, READ_ONLY); + } + + @Test + public void testNotNull() { + assertNotNull(securityEntry); + } + + @Test + public void testTableJoinProperties() { + assertEquals(ID, securityEntry.getId()); + assertEquals(NAME, securityEntry.getName()); + assertEquals(READ_ONLY, securityEntry.isReadOnly()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableJoinTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableJoinTest.java new file mode 100644 index 00000000..d7912415 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableJoinTest.java @@ -0,0 +1,71 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class TableJoinTest { + + TableJoin tableJoin; + + private String SRC_TABLE_NAME = "srcTableName"; + private String DEST_TABLE_NAME = "destTableName"; + private String JOIN_EXPR = "joinExpr"; + + @Before + public void init() { + tableJoin = new TableJoin(SRC_TABLE_NAME, DEST_TABLE_NAME, JOIN_EXPR); + } + + @Test + public void testNotNull() { + assertNotNull(tableJoin); + } + + @Test + public void testTableJoinProperties() { + assertEquals(SRC_TABLE_NAME, tableJoin.getSrcTableName()); + assertEquals(DEST_TABLE_NAME, tableJoin.getDestTableName()); + assertEquals(JOIN_EXPR, tableJoin.getJoinExpr()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableSourceTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableSourceTest.java new file mode 100644 index 00000000..c6554c12 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/TableSourceTest.java @@ -0,0 +1,76 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.model.definition; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class TableSourceTest { + + TableSource tableSource; + + private String TABLE_NAME = "tableName"; + private String DISPLAY_NAME = "displayName"; + private String PK_FIELDS = "pkFields"; + private String VIEW_ACTION = "viewAction"; + private String IS_LARGE_DATA = "isLargeData"; + private String FILTER_SQL = "filterSql"; + + @Before + public void init() { + tableSource = new TableSource(TABLE_NAME, DISPLAY_NAME, PK_FIELDS, VIEW_ACTION, IS_LARGE_DATA, FILTER_SQL); + } + + @Test + public void testNotNull() { + assertNotNull(tableSource); + } + + @Test + public void testTableSourceProperties() { + assertEquals(TABLE_NAME, tableSource.getTableName()); + assertEquals(DISPLAY_NAME, tableSource.getDisplayName()); + assertEquals(PK_FIELDS, tableSource.getPkFields()); + assertEquals(VIEW_ACTION, tableSource.getViewAction()); + assertEquals(IS_LARGE_DATA, tableSource.getIsLargeData()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java index 3bdb5bc1..e1f99ec0 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START========================================== * ONAP Portal SDK * =================================================================== - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/MessageJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/MessageJSONTest.java new file mode 100644 index 00000000..da99f464 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/MessageJSONTest.java @@ -0,0 +1,63 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class MessageJSONTest { + + MessageJSON messageJSON; + private String MESSAGE = "testMessage"; + private String ANY_STACKTRACE = "testStacktrace"; + + @Before + public void init() { + messageJSON = new MessageJSON(); + messageJSON.setMessage(MESSAGE); + messageJSON.setAnyStacktrace(ANY_STACKTRACE); + } + + @Test + public void testNotNull() { + assertEquals(MESSAGE, messageJSON.getMessage()); + assertEquals(ANY_STACKTRACE, messageJSON.getAnyStacktrace()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorErrorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorErrorTest.java new file mode 100644 index 00000000..271e2d5a --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorErrorTest.java @@ -0,0 +1,67 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class RaptorErrorTest { + + RaptorError raptorError1; + RaptorError raptorError2; + private String MESSAGE = "theMessage"; + private Throwable THROWABLE = new Throwable(MESSAGE); + + @Before + public void init() { + raptorError1 = new RaptorError(MESSAGE); + raptorError2 = new RaptorError(MESSAGE, THROWABLE); + } + + @Test + public void testRaptorErrorMessage() { + assertEquals(MESSAGE, raptorError1.error().get("message")); + } + + @Test + public void testRaptorErrorThrowable() { + assertEquals(THROWABLE.toString(), raptorError2.error().get("exception")); + } +} |