diff options
author | Kotta, Shireesha (sk434m) <sk434m@att.com> | 2018-03-06 09:44:53 -0500 |
---|---|---|
committer | Kotta, Shireesha (sk434m) <sk434m@att.com> | 2018-03-06 17:43:16 -0500 |
commit | cfb69f44f841338e1f208225ec006388e986bd2c (patch) | |
tree | e8b7e982637a5b27f3383a793fcdcee50f7e0057 /ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model | |
parent | 724ff8f8b22d6503ce5070ebc13f6f5fbc48c8cf (diff) |
Added Junits & AAF attributes Support
Issue-ID: PORTAL-136
Includes JUNITS, AAF attributes support
Change-Id: Id4cc9f64268017665d7245d0a10369c9b498ba2f
Signed-off-by: Kotta, Shireesha (sk434m) <sk434m@att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model')
13 files changed, 1411 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnEditJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnEditJSONTest.java new file mode 100644 index 00000000..7aee9e9d --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnEditJSONTest.java @@ -0,0 +1,82 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ColumnEditJSONTest { + + public ColumnEditJSON mockColumnEditJSONTest() { + ColumnEditJSON columnEditJSON = new ColumnEditJSON(); + columnEditJSON.setTabId("tabId"); + columnEditJSON.setTabName("tabName"); + columnEditJSON.setColId("colId"); + columnEditJSON.setColName("colName"); + columnEditJSON.setDisplayAlignment("displayAlignment"); + columnEditJSON.setDisplayHeaderAlignment("displayHeaderAlignment"); + columnEditJSON.setSortable(false); + columnEditJSON.setVisible(false); + columnEditJSON.setDrilldownURL("drilldownURL"); + columnEditJSON.setDrilldownParams("drilldownParams"); + columnEditJSON.setDrilldownType("drilldownType"); + columnEditJSON.setErrorMessage("errorMessage"); + columnEditJSON.setErrorStackTrace("errorStackTrace"); + return columnEditJSON; + } + + @Test + public void columnEditJSONTest() { + ColumnEditJSON columnEditJSON = mockColumnEditJSONTest(); + ColumnEditJSON columnEditJSON1 = mockColumnEditJSONTest(); + assertEquals(columnEditJSON.getTabId(), columnEditJSON1.getTabId()); + assertEquals(columnEditJSON.getTabName(), columnEditJSON1.getTabName()); + assertEquals(columnEditJSON.getColId(), columnEditJSON1.getColId()); + assertEquals(columnEditJSON.getColName(), columnEditJSON1.getColName()); + assertEquals(columnEditJSON.getDisplayAlignment(), columnEditJSON1.getDisplayAlignment()); + assertEquals(columnEditJSON.getDisplayHeaderAlignment(), columnEditJSON1.getDisplayHeaderAlignment()); + assertFalse(columnEditJSON.isSortable()); + assertFalse(columnEditJSON.isVisible()); + assertEquals(columnEditJSON.getDrilldownURL(), columnEditJSON1.getDrilldownURL()); + assertEquals(columnEditJSON.getDrilldownParams(), columnEditJSON1.getDrilldownParams()); + assertEquals(columnEditJSON.getDrilldownType(), columnEditJSON1.getDrilldownType()); + assertEquals(columnEditJSON.getErrorMessage(), columnEditJSON1.getErrorMessage()); + assertEquals(columnEditJSON.getErrorStackTrace(), columnEditJSON1.getErrorStackTrace()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnJSONTest.java new file mode 100644 index 00000000..473ec720 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ColumnJSONTest.java @@ -0,0 +1,53 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ColumnJSONTest { + @Test + public void mockColumnJSONTest() { + ColumnJSON columnJSON = new ColumnJSON(); + columnJSON.setId("id"); + columnJSON.setName("name"); + assertEquals(columnJSON.getId(), "id"); + assertEquals(columnJSON.getName(), "name"); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/DefinitionJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/DefinitionJSONTest.java new file mode 100644 index 00000000..5eb75390 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/DefinitionJSONTest.java @@ -0,0 +1,104 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class DefinitionJSONTest { + + public DefinitionJSON mockDefinitionJSONTest() + { + DefinitionJSON definitionJSON= new DefinitionJSON(); + definitionJSON.setTabName("tabName"); + definitionJSON.setTabId("tabId"); + definitionJSON.setReportId("reportId"); + definitionJSON.setReportName("reportName"); + definitionJSON.setReportDescr("reportDescr"); + definitionJSON.setReportType("reportType"); + definitionJSON.setDbInfo("dbInfo"); + definitionJSON.setFormHelpText("formHelpText"); + definitionJSON.setPageSize(null); + definitionJSON.setDisplayArea(null); + definitionJSON.setHideFormFieldsAfterRun(false); + definitionJSON.setMaxRowsInExcelCSVDownload(1); + definitionJSON.setFrozenColumns(1); + definitionJSON.setDataGridAlign("dataGridAlign"); + definitionJSON.setEmptyMessage("emptyMessage"); + definitionJSON.setDataContainerHeight("dataContainerHeight"); + definitionJSON.setDataContainerWidth("dataContainerWidth"); + definitionJSON.setDisplayOptions(null); + definitionJSON.setRuntimeColSortDisabled(false); + definitionJSON.setNumFormCols(1); + definitionJSON.setReportTitle("title"); + definitionJSON.setReportSubTitle("reportSubTitle"); + return definitionJSON; + } + @Test + public void definitionJSONTest() + { + DefinitionJSON definitionJSON = mockDefinitionJSONTest(); + assertEquals(definitionJSON.getTabName(),"tabName"); + assertEquals(definitionJSON.getTabId(),"tabId"); + assertEquals(definitionJSON.getReportId(),"reportId"); + assertEquals(definitionJSON.getReportName(),"reportName"); + assertEquals(definitionJSON.getReportDescr(),"reportDescr"); + assertEquals(definitionJSON.getReportType(),"reportType"); + assertEquals(definitionJSON.getDbInfo(),"dbInfo"); + assertEquals(definitionJSON.getFormHelpText(),"formHelpText"); + assertNull(definitionJSON.getPageSize()); + assertNull(definitionJSON.getDisplayArea()); + assertFalse(definitionJSON.getHideFormFieldsAfterRun()); + assertTrue(definitionJSON.getMaxRowsInExcelCSVDownload() == 1); + assertTrue(definitionJSON.getFrozenColumns()== 1); + assertEquals(definitionJSON.getDataGridAlign(),"dataGridAlign"); + assertEquals(definitionJSON.getEmptyMessage(),"emptyMessage"); + assertEquals(definitionJSON.getDataContainerHeight(),"dataContainerHeight"); + assertEquals(definitionJSON.getDataContainerWidth(),"dataContainerWidth"); + assertNull(definitionJSON.getDisplayOptions()); + assertFalse(definitionJSON.getRuntimeColSortDisabled()); + assertTrue(definitionJSON.getNumFormCols()== 1); + assertEquals(definitionJSON.getReportTitle(),"title"); + assertEquals(definitionJSON.getReportSubTitle(),"reportSubTitle"); + + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/FormEditJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/FormEditJSONTest.java new file mode 100644 index 00000000..ad003726 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/FormEditJSONTest.java @@ -0,0 +1,84 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class FormEditJSONTest { + + public FormEditJSON mockFormEditJSON() { + FormEditJSON formEditJSON = new FormEditJSON(); + formEditJSON.setTabId("tabId"); + formEditJSON.setTabName("tabName"); + formEditJSON.setFieldId("fieldId"); + formEditJSON.setFieldType("fieldType"); + formEditJSON.setVisible(false); + formEditJSON.setDefaultValue("defaultValue"); + formEditJSON.setFieldDefaultSQL("fieldDefaultSQL"); + formEditJSON.setFieldSQL("fieldSQL"); + formEditJSON.setValidationType("validationType"); + formEditJSON.setPredefinedValueList(null); + formEditJSON.setMessage("message"); + formEditJSON.setErrorMessage("errorMessage"); + formEditJSON.setErrorStackTrace("errorStackTrace"); + formEditJSON.setFieldName("fieldName"); + return formEditJSON; + } + + @Test + public void formEditJSONTest() + { + FormEditJSON formEditJSON = mockFormEditJSON(); + assertEquals(formEditJSON.getTabId(),"tabId"); + assertEquals(formEditJSON.getTabName(),"tabName"); + assertEquals(formEditJSON.getFieldId(),"fieldId"); + assertEquals(formEditJSON.getFieldType(),"fieldType"); + assertFalse(formEditJSON.isVisible()); + assertEquals(formEditJSON.getDefaultValue(),"defaultValue"); + assertEquals(formEditJSON.getFieldDefaultSQL(),"fieldDefaultSQL"); + assertEquals(formEditJSON.getFieldSQL(),"fieldSQL"); + assertEquals(formEditJSON.getValidationType(),"validationType"); + assertNull(formEditJSON.getPredefinedValueList()); + assertEquals(formEditJSON.getMessage(),"message"); + assertEquals(formEditJSON.getErrorMessage(),"errorMessage"); + assertEquals(formEditJSON.getErrorStackTrace(),"errorStackTrace"); + assertEquals(formEditJSON.getFieldName(),"fieldName"); + } +} 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 new file mode 100644 index 00000000..a74e96b7 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/IdNameBooleanJSONTest.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class IdNameBooleanJSONTest { + @Test + public void mockIdNameBooleanJSON() { + IdNameBooleanJSON idNameBooleanJSON = new IdNameBooleanJSON(); + idNameBooleanJSON.setId("id"); + idNameBooleanJSON.setName("name"); + idNameBooleanJSON.setSelected(false); + assertEquals(idNameBooleanJSON.getId(), "id"); + assertEquals(idNameBooleanJSON.getName(), "name"); + assertFalse(idNameBooleanJSON.isSelected()); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ImportJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ImportJSONTest.java new file mode 100644 index 00000000..40a5e44a --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ImportJSONTest.java @@ -0,0 +1,56 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ImportJSONTest { + @Test + public void mockImportJSONTest() { + ImportJSON importJSON = new ImportJSON(); + importJSON.setTabId("tabId"); + importJSON.setTabName("name"); + importJSON.setReportXML(null); + assertEquals(importJSON.getTabId(), "tabId"); + assertEquals(importJSON.getTabName(), "name"); + assertNull(importJSON.getReportXML()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ListJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ListJSONTest.java new file mode 100644 index 00000000..3056ad42 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/ListJSONTest.java @@ -0,0 +1,53 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ListJSONTest { + + @Test + public void mockListJSONTest() { + ListJSON listJSON = new ListJSON(); + listJSON.setElements(null); + assertNull(listJSON.getElements()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/NameBooleanJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/NameBooleanJSONTest.java new file mode 100644 index 00000000..83986087 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/NameBooleanJSONTest.java @@ -0,0 +1,65 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class NameBooleanJSONTest { + + @Test + public void mockNameBooleanJSONTest() + { + NameBooleanJSON nameBooleanJSON = new NameBooleanJSON(); + nameBooleanJSON.setName("name"); + nameBooleanJSON.setSelected(false); + assertEquals(nameBooleanJSON.getName(),"name"); + assertFalse(nameBooleanJSON.isSelected()); + } + + @Test + public void mockMessageJSONTest() + { + MessageJSON messageJSON = new MessageJSON (); + messageJSON.setAnyStacktrace("test"); + assertEquals(messageJSON.getAnyStacktrace(),"test"); + } + + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/QueryJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/QueryJSONTest.java new file mode 100644 index 00000000..3bb8d098 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/QueryJSONTest.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class QueryJSONTest { + + @Test + public void mockQueryJSONTest() { + QueryJSON queryJSON = new QueryJSON(); + queryJSON.setTabId("tabId"); + queryJSON.setTabName("tabName"); + assertEquals(queryJSON.getTabId(), "tabId"); + assertEquals(queryJSON.getTabName(), "tabName"); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/QueryResultJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/QueryResultJSONTest.java new file mode 100644 index 00000000..f28eaf1b --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/QueryResultJSONTest.java @@ -0,0 +1,65 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.Map; + +import org.junit.Test; + +public class QueryResultJSONTest { + + @Test + public void mockQueryResultJSONTest() { + QueryResultJSON queryResultJSON = new QueryResultJSON(); + queryResultJSON.setTotalRows(1); + String str = "test"; + ArrayList<String> list = new ArrayList<>(); + list.add(str); + queryResultJSON.setReportDataColumns(list); + ArrayList<Map<String, String>> rowList = new ArrayList<>(); + queryResultJSON.setReportDataRows(rowList); + queryResultJSON.setQuery("test"); + assertEquals(queryResultJSON.getQuery(), "test"); + assertEquals(queryResultJSON.getTotalRows(), 1); + assertEquals(queryResultJSON.getReportDataColumns().size(), 1); + assertEquals(queryResultJSON.getReportDataRows().size(), 0); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorResponseTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorResponseTest.java new file mode 100644 index 00000000..8a213acc --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/RaptorResponseTest.java @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class RaptorResponseTest { + @Test + public void mockRaptorResponseTest() { + RaptorResponse raptorResponse = new RaptorResponse(); + assertEquals(raptorResponse.getData().getClass(), String.class); + assertEquals(raptorResponse.getError().getClass(), String.class); + assertEquals(raptorResponse.data().getClass(), org.json.JSONObject.class); + assertEquals(raptorResponse.error().getClass(), org.json.JSONObject.class); + + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/SearchFieldJSONTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/SearchFieldJSONTest.java new file mode 100644 index 00000000..9fc0a36a --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/definition/wizard/SearchFieldJSONTest.java @@ -0,0 +1,57 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.definition.wizard; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class SearchFieldJSONTest { + @Test + public void mockSearchFieldJSONTest() + { + SearchFieldJSON searchFieldJSON = new SearchFieldJSON(); + searchFieldJSON.setName("name"); + searchFieldJSON.setId("id"); + assertEquals(searchFieldJSON.getName(),"name"); + assertEquals(searchFieldJSON.getId(),"id"); + + } + + +} 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 new file mode 100644 index 00000000..c28d8bf9 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/runtime/RaptorControllerAsyncTest.java @@ -0,0 +1,628 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.portalsdk.analytics.model.runtime; + +import static org.junit.Assert.assertEquals; + +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.List; +import java.util.Vector; + +import javax.servlet.ServletContext; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.portalsdk.analytics.controller.Action; +import org.onap.portalsdk.analytics.controller.ActionMapping; +import org.onap.portalsdk.analytics.controller.ErrorHandler; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.model.DataCache; +import org.onap.portalsdk.analytics.model.ReportHandler; +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.wizard.ColumnJSON; +import org.onap.portalsdk.analytics.model.definition.wizard.DefinitionJSON; +import org.onap.portalsdk.analytics.model.definition.wizard.ImportJSON; +import org.onap.portalsdk.analytics.model.definition.wizard.MessageJSON; +import org.onap.portalsdk.analytics.model.definition.wizard.QueryJSON; +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.system.fusion.web.RaptorControllerAsync; +import org.onap.portalsdk.analytics.util.AppConstants; +import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.Utils; +import org.onap.portalsdk.analytics.util.XSSFilter; +import org.onap.portalsdk.analytics.view.ReportData; +import org.onap.portalsdk.analytics.xmlobj.ChartAdditionalOptions; +import org.onap.portalsdk.analytics.xmlobj.CustomReportType; +import org.onap.portalsdk.analytics.xmlobj.DataColumnList; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; +import org.onap.portalsdk.analytics.xmlobj.DataSourceList; +import org.onap.portalsdk.analytics.xmlobj.DataSourceType; +import org.onap.portalsdk.analytics.xmlobj.FormFieldList; +import org.onap.portalsdk.analytics.xmlobj.FormFieldType; +import org.onap.portalsdk.analytics.xmlobj.MockRunTimeReport; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.onap.portalsdk.core.domain.User; +import org.onap.portalsdk.core.service.DataAccessService; +import org.onap.portalsdk.core.util.SecurityCodecUtil; +import org.onap.portalsdk.core.web.support.UserUtils; +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; +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}) +public class RaptorControllerAsyncTest { + + @InjectMocks + RaptorControllerAsync raptorControllerAsync = new RaptorControllerAsync(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Mock + DataAccessService dataAccessService; + + @Mock + AppConstants appConstants; + + @Mock + Globals globals; + @Mock + Action action = new Action("test", "RaptorControllerAsync", "test", "test"); + @Mock + ActionMapping actionMapping = new ActionMapping(); + @Mock + ReportDefinition reportDefinition ; + + @Mock + ReportHandler reportHandler = new ReportHandler(); + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + NullPointerException nullPointerException = new NullPointerException(); + + MockRunTimeReport mockRunTimeReport = new MockRunTimeReport(); + + @Test + public void RaptorSearchToDownloadexcel2007Test() throws Exception { + Mockito.when(mockedRequest.getParameter(AppConstants.RI_ACTION)) + .thenReturn("report.download.excel2007.session"); + Mockito.when(mockedRequest.getParameter("action")).thenReturn("report.download.excel2007.session"); + User user = new User(); + user.setOrgUserId("test12"); + Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); + ServletContext servletContext = PowerMockito.mock(ServletContext.class); + Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext); + Mockito.when(mockedRequest.getParameter("parent")).thenReturn("parent_test"); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(AppUtils.class); + Mockito.when(Globals.isSystemInitialized()).thenReturn(true); + Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test12"); + ReportRuntime reportRuntime = mockRunTimeReport.mockReportRuntime(); + ReportData reportData = PowerMockito.mock(ReportData.class); + Mockito.when(mockedRequest.getSession().getAttribute("parent_test" + "_rr")).thenReturn(reportRuntime); + Mockito.when(mockedRequest.getSession().getAttribute("parent_test" + "_rd")).thenReturn(reportData); + OutputStreamWriter outputStreamWriter = PowerMockito.mock(OutputStreamWriter.class); + ServletOutputStream ServletOutputStream = PowerMockito.mock(ServletOutputStream.class); + Mockito.when(mockedResponse.getOutputStream()).thenReturn(ServletOutputStream); + Mockito.doNothing().when(reportHandler).createExcel2007FileContent(Matchers.any(OutputStreamWriter.class), Matchers.any(ReportData.class), + Matchers.any(ReportRuntime.class), Matchers.any(HttpServletRequest.class), Matchers.any(HttpServletResponse.class), Matchers.any(String.class), Matchers.anyInt()); + + reportRuntime = PowerMockito.mock(ReportRuntime.class); + Mockito.when(reportRuntime.getReportDataSQL("test12", 500, mockedRequest)).thenReturn("test"); + StringWriter sw = new StringWriter(); + PrintWriter writer = new PrintWriter(sw); + Mockito.when(mockedResponse.getWriter()).thenReturn(writer); + Mockito.when(Globals.getGenerateSubsetSql()).thenReturn("test"); + Mockito.when(Globals.getReportSqlOnlyFirstPart()).thenReturn("test"); + raptorControllerAsync.RaptorSearch(mockedRequest, mockedResponse); + } + + @Test(expected = java.lang.NullPointerException.class) + public void RaptorSearchNullActionKeyTest() throws Exception { + User user = new User(); + user.setOrgUserId("test12"); + Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); + ServletContext servletContext = PowerMockito.mock(ServletContext.class); + Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.isSystemInitialized()).thenReturn(true); + Mockito.when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + Action action1 = new Action("test", + "org.onap.portalsdk.analytics.system.fusion.service.RaptorControllerAsyncTest", "test", "test"); + Mockito.when(actionMapping.getAction(Matchers.anyString())).thenReturn(action1); + StringWriter sw = new StringWriter(); + PrintWriter writer = new PrintWriter(sw); + Mockito.when(mockedResponse.getWriter()).thenReturn(writer); + raptorControllerAsync.RaptorSearch(mockedRequest, mockedResponse); + } + + public String test(HttpServletRequest request, String str) { + return "test"; + } + + @Test(expected = java.lang.NullPointerException.class) + public void RaptorSearchClassNotFoundExceptionTest() throws Exception { + User user = new User(); + user.setOrgUserId("test12"); + Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); + ServletContext servletContext = PowerMockito.mock(ServletContext.class); + Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.isSystemInitialized()).thenReturn(true); + Mockito.when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + Action action1 = new Action("test", "RaptorControllerAsyncTest", "test", "test"); + Mockito.when(actionMapping.getAction(Matchers.anyString())).thenReturn(action1); + StringWriter sw = new StringWriter(); + PrintWriter writer = new PrintWriter(sw); + Mockito.when(mockedResponse.getWriter()).thenReturn(writer); + raptorControllerAsync.RaptorSearch(mockedRequest, mockedResponse); + } + + @Test(expected = java.lang.NullPointerException.class) + public void RaptorSearchMethodNotFoundExceptionTest() throws Exception { + User user = new User(); + user.setOrgUserId("test12"); + Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); + ServletContext servletContext = PowerMockito.mock(ServletContext.class); + Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.isSystemInitialized()).thenReturn(true); + Mockito.when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + Action action1 = new Action("test", + "org.onap.portalsdk.analytics.system.fusion.service.RaptorControllerAsyncTest", "newtest", "test"); + Mockito.when(actionMapping.getAction(Matchers.anyString())).thenReturn(action1); + StringWriter sw = new StringWriter(); + PrintWriter writer = new PrintWriter(sw); + Mockito.when(mockedResponse.getWriter()).thenReturn(writer); + raptorControllerAsync.RaptorSearch(mockedRequest, mockedResponse); + } + + public void test1(HttpServletRequest request, String str) { + throw new MethodInvocationException("test"); + } + + @Test(expected = java.lang.NullPointerException.class) + public void RaptorSearchMethodInvocationFoundExceptionTest() throws Exception { + User user = new User(); + user.setOrgUserId("test12"); + Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); + ServletContext servletContext = PowerMockito.mock(ServletContext.class); + Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.isSystemInitialized()).thenReturn(true); + Mockito.when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + Action action1 = new Action("test", + "org.onap.portalsdk.analytics.system.fusion.service.RaptorControllerAsyncTest", "test1", null); + Mockito.when(actionMapping.getAction(Matchers.anyString())).thenReturn(action1); + StringWriter sw = new StringWriter(); + PrintWriter writer = new PrintWriter(sw); + Mockito.when(mockedResponse.getWriter()).thenReturn(writer); + raptorControllerAsync.RaptorSearch(mockedRequest, mockedResponse); + } + + @Test(expected = java.lang.NullPointerException.class) + public void RaptorSearchRaptorExceptionTest() throws Exception { + User user = new User(); + user.setOrgUserId("test12"); + Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); + ServletContext servletContext = PowerMockito.mock(ServletContext.class); + Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.isSystemInitialized()).thenReturn(true); + Mockito.when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + Mockito.when(actionMapping.getAction(Matchers.anyString())).thenReturn(null); + StringWriter sw = new StringWriter(); + PrintWriter writer = new PrintWriter(sw); + Mockito.when(mockedResponse.getWriter()).thenReturn(writer); + raptorControllerAsync.RaptorSearch(mockedRequest, mockedResponse); + } + + @Test + public void RaptorSearchNoUserTest() throws Exception { + + Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(null); + ServletContext servletContext = PowerMockito.mock(ServletContext.class); + Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.isSystemInitialized()).thenReturn(true); + Mockito.when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + Action action1 = new Action("test", + "org.onap.portalsdk.analytics.system.fusion.service.RaptorControllerAsyncTest", "test1", null); + Mockito.when(actionMapping.getAction(Matchers.anyString())).thenReturn(action1); + StringWriter sw = new StringWriter(); + PrintWriter writer = new PrintWriter(sw); + Mockito.when(mockedResponse.getWriter()).thenReturn(writer); + raptorControllerAsync.RaptorSearch(mockedRequest, mockedResponse); + } + + @Test(expected = java.lang.NullPointerException.class) + public void RaptorSearchGlobalyTest() throws Exception { + User user = new User(); + user.setOrgUserId("test12"); + Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); + ServletContext servletContext = PowerMockito.mock(ServletContext.class); + Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext); + PowerMockito.mockStatic(Globals.class); + Mockito.when(Globals.isSystemInitialized()).thenReturn(false); + Mockito.when(Globals.getRaptorActionMapping()).thenReturn(actionMapping); + Action action1 = new Action("test", + "org.onap.portalsdk.analytics.system.fusion.service.RaptorControllerAsyncTest", "test", "test"); + Mockito.when(actionMapping.getAction(Matchers.anyString())).thenReturn(action1); + StringWriter sw = new StringWriter(); + PrintWriter writer = new PrintWriter(sw); + Mockito.when(mockedResponse.getWriter()).thenReturn(writer); + ErrorHandler errorHandler = PowerMockito.mock(ErrorHandler.class); + Mockito.when(errorHandler.processFatalErrorJSON(Matchers.any(HttpServletRequest.class), Matchers.any(RaptorException.class))).thenReturn("test"); + + + raptorControllerAsync.setViewName("test"); + raptorControllerAsync.RaptorSearch(mockedRequest, mockedResponse); + } + + @Test + public void listColumnsTest() throws Exception { + List<DataColumnType> reportColumnList = new ArrayList<>(); + DataColumnType dataColumnType = new DataColumnType(); + dataColumnType.setColId("test"); + dataColumnType.setColName("testname"); + reportColumnList.add(dataColumnType); + ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class); + reportDefinition.setReportName("test"); + Mockito.when(reportDefinition.getAllColumns()).thenReturn(reportColumnList); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)) + .thenReturn(reportDefinition); + ArrayList<ColumnJSON> listJSON = new ArrayList<ColumnJSON>(); + ColumnJSON columnJSON = new ColumnJSON(); + columnJSON.setId("test"); + columnJSON.setName("testname"); + listJSON.add(columnJSON); + assertEquals(listJSON.get(0).getId(), + raptorControllerAsync.listColumns(mockedRequest, mockedResponse).get(0).getId()); + } + + @Test + public void list_drilldown_reports() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + + Mockito.when(Globals.getReportUserAccess()).thenReturn("test"); + ResultSet rs = PowerMockito.mock(ResultSet.class); + ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class); + Mockito.when(rsmd.getColumnCount()).thenReturn(1); + Mockito.when(rs.getMetaData()).thenReturn(rsmd); + DataSet datset = PowerMockito.mock(DataSet.class); + Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); + Mockito.when(Globals.getNewScheduleData()).thenReturn("test"); + CustomReportType customReportType = new CustomReportType(); + customReportType.setReportType("test"); + ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", + "1", true); + ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class); + Mockito.doNothing().when(reportDefinition).generateWizardSequence(null); + reportDefinition = new ReportDefinition(reportWrapper, mockedRequest); + PowerMockito.mockStatic(DataCache.class); + PowerMockito.mockStatic(AppUtils.class); + Vector<IdNameValue> reportnames = new Vector<>(); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("1"); + reportnames.add(idNameValue); + Mockito.when(DataCache.getPublicReportIdNames()).thenReturn(reportnames); + reportDefinition.setReportName("test"); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)) + .thenReturn(reportDefinition); + Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test12"); + Vector userRoles = new Vector<>(); + userRoles.add(idNameValue); + Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(userRoles); + + Vector groupReportIdNames = new Vector<>(); + groupReportIdNames.add(idNameValue); + Mockito.when(DataCache.getGroupAccessibleReportIdNames("test12", userRoles)).thenReturn(groupReportIdNames); + Mockito.when(DataCache.getPrivateAccessibleReportIdNames("test12", userRoles)).thenReturn(groupReportIdNames); + ServletContext servletContext = PowerMockito.mock(ServletContext.class); + Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext); + Mockito.when(Globals.isSystemInitialized()).thenReturn(true); + assertEquals(3, raptorControllerAsync.list_drilldown_reports(mockedRequest, mockedResponse).size()); + } + + @Test + public void list_drilldown_reportsNull() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + + Mockito.when(Globals.getReportUserAccess()).thenReturn("test"); + ResultSet rs = PowerMockito.mock(ResultSet.class); + ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class); + Mockito.when(rsmd.getColumnCount()).thenReturn(1); + Mockito.when(rs.getMetaData()).thenReturn(rsmd); + DataSet datset = PowerMockito.mock(DataSet.class); + // datset = new DataSet(rs); + Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); + Mockito.when(Globals.getNewScheduleData()).thenReturn("test"); + CustomReportType customReportType = new CustomReportType(); + customReportType.setReportType("test"); + ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", + "1", true); + ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class); + Mockito.doNothing().when(reportDefinition).generateWizardSequence(null); + reportDefinition = new ReportDefinition(reportWrapper, mockedRequest); + PowerMockito.mockStatic(DataCache.class); + PowerMockito.mockStatic(AppUtils.class); + Vector<IdNameValue> reportnames = new Vector<>(); + IdNameValue idNameValue = new IdNameValue(); + idNameValue.setId("-1"); + reportnames.add(idNameValue); + Mockito.when(DataCache.getPublicReportIdNames()).thenReturn(reportnames); + reportDefinition.setReportName("test"); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)) + .thenReturn(reportDefinition); + Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test12"); + Vector userRoles = new Vector<>(); + userRoles.add(idNameValue); + Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(userRoles); + + Vector groupReportIdNames = new Vector<>(); + groupReportIdNames.add(idNameValue); + Mockito.when(DataCache.getGroupAccessibleReportIdNames("test12", userRoles)).thenReturn(groupReportIdNames); + Mockito.when(DataCache.getPrivateAccessibleReportIdNames("test12", userRoles)).thenReturn(groupReportIdNames); + ServletContext servletContext = PowerMockito.mock(ServletContext.class); + Mockito.when(mockedRequest.getSession().getServletContext()).thenReturn(servletContext); + Mockito.when(Globals.isSystemInitialized()).thenReturn(true); + assertEquals(0, raptorControllerAsync.list_drilldown_reports(mockedRequest, mockedResponse).size()); + } + + @Test + public void listFormFields() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + + Mockito.when(Globals.getReportUserAccess()).thenReturn("test"); + ResultSet rs = PowerMockito.mock(ResultSet.class); + ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class); + Mockito.when(rsmd.getColumnCount()).thenReturn(1); + Mockito.when(rs.getMetaData()).thenReturn(rsmd); + DataSet datset = PowerMockito.mock(DataSet.class); + // datset = new DataSet(rs); + Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); + Mockito.when(Globals.getNewScheduleData()).thenReturn("test"); + CustomReportType customReportType = new CustomReportType(); + customReportType.setReportType("test"); + FormFieldList formFieldList= new FormFieldList(); + formFieldList.setComment("test"); + customReportType.setFormFieldList(formFieldList); + ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", + "1", true); + ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class); + Mockito.doNothing().when(reportDefinition).generateWizardSequence(null); + reportDefinition = new ReportDefinition(reportWrapper, mockedRequest); + + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition); + + assertEquals(raptorControllerAsync.listFormFields(mockedRequest, mockedResponse).size(), 0); + } + + @Test + public void listFormFieldsTest() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + + Mockito.when(Globals.getReportUserAccess()).thenReturn("test"); + ResultSet rs = PowerMockito.mock(ResultSet.class); + ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class); + Mockito.when(rsmd.getColumnCount()).thenReturn(1); + Mockito.when(rs.getMetaData()).thenReturn(rsmd); + DataSet datset = PowerMockito.mock(DataSet.class); + // datset = new DataSet(rs); + Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); + Mockito.when(Globals.getNewScheduleData()).thenReturn("test"); + CustomReportType customReportType = new CustomReportType(); + customReportType.setReportType("test"); + FormFieldList formFieldList= PowerMockito.mock(FormFieldList.class); + formFieldList.setComment("test"); + customReportType.setFormFieldList(formFieldList); + ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", + "1", true); + ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class); + Mockito.doNothing().when(reportDefinition).generateWizardSequence(null); + reportDefinition = new ReportDefinition(reportWrapper, mockedRequest); + List<FormFieldType> formField = new ArrayList<>(); + FormFieldType formFieldType = new FormFieldType(); + formFieldType.setFieldId("id"); + formField.add(formFieldType); + Mockito.when(formFieldList.getFormField()).thenReturn(formField); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition); + assertEquals(raptorControllerAsync.listFormFields(mockedRequest, mockedResponse).size(), 1); + } + + @Test + public void listFormFieldsNullTest() throws Exception + { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + + Mockito.when(Globals.getReportUserAccess()).thenReturn("test"); + ResultSet rs = PowerMockito.mock(ResultSet.class); + ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class); + Mockito.when(rsmd.getColumnCount()).thenReturn(1); + Mockito.when(rs.getMetaData()).thenReturn(rsmd); + DataSet datset = PowerMockito.mock(DataSet.class); + // datset = new DataSet(rs); + Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); + Mockito.when(Globals.getNewScheduleData()).thenReturn("test"); + CustomReportType customReportType = new CustomReportType(); + customReportType.setReportType("test"); + ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", + "1", true); + ReportDefinition reportDefinition = PowerMockito.mock(ReportDefinition.class); + Mockito.doNothing().when(reportDefinition).generateWizardSequence(null); + reportDefinition = new ReportDefinition(reportWrapper, mockedRequest); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_DEFINITION)).thenReturn(reportDefinition); + assertEquals(raptorControllerAsync.listFormFields(mockedRequest, mockedResponse).size(),0); + } + + @Test(expected = java.lang.NullPointerException.class) + public void saveDefTabWiseDataIfIdInSessionTest() throws Exception + { + DefinitionJSON definitionJSON = new DefinitionJSON(); + definitionJSON.setTabId("1"); + PowerMockito.mockStatic(ReportLoader.class); + Mockito.when(ReportLoader.loadCustomReportXML("1")).thenReturn("test"); + ReportRuntime rr = PowerMockito.mock(ReportRuntime.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + + Mockito.when(Globals.getReportUserAccess()).thenReturn("test"); + ResultSet rs = PowerMockito.mock(ResultSet.class); + ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class); + Mockito.when(rsmd.getColumnCount()).thenReturn(1); + Mockito.when(rs.getMetaData()).thenReturn(rsmd); + DataSet datset = PowerMockito.mock(DataSet.class); + Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); + Mockito.when(Globals.getNewScheduleData()).thenReturn("test"); + CustomReportType customReportType = new CustomReportType(); + customReportType.setReportType("test"); + DataSourceList list = new DataSourceList(); + customReportType.setDataSourceList(list); + ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", + "1", true); + rr = new ReportRuntime(reportWrapper); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(null); + Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + raptorControllerAsync.saveDefTabWiseData("test", definitionJSON, mockedRequest, mockedResponse); + } + + + @Test + public void reportChartReceiveTest() throws Exception + { + + PowerMockito.mockStatic(ReportLoader.class); + Mockito.when(ReportLoader.loadCustomReportXML("1")).thenReturn("test"); + ReportRuntime rr = mockRunTimeReport.mockReportRuntime(); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getReportUserAccess()).thenReturn("test"); + ResultSet rs = PowerMockito.mock(ResultSet.class); + ResultSetMetaData rsmd = PowerMockito.mock(ResultSetMetaData.class); + Mockito.when(rsmd.getColumnCount()).thenReturn(1); + Mockito.when(rs.getMetaData()).thenReturn(rsmd); + DataSet datset = PowerMockito.mock(DataSet.class); + Mockito.when(datset.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn(null); + Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(datset); + Mockito.when(Globals.getNewScheduleData()).thenReturn("test"); + CustomReportType customReportType = new CustomReportType(); + customReportType.setReportType("test"); + DataSourceList list = new DataSourceList(); + customReportType.setDataSourceList(list); + ReportWrapper reportWrapper = new ReportWrapper(customReportType, "-1", "test", "testId", "test", "test", "1", + "1", true); + Mockito.when( mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr); + ChartJSON chartJSON = mockChartJSON(); + raptorControllerAsync.reportChartReceive(chartJSON, mockedRequest, mockedResponse); + + } + + + public ChartJSON mockChartJSON() + { + ChartJSON chartJSON = new ChartJSON(); + chartJSON.setAnimation(false); + chartJSON.setWidth("width"); + chartJSON.setHeight("height"); + chartJSON.setShowTitle(true); + BarChartOptions barChartOptions= new BarChartOptions(); + chartJSON.setBarChartOptions(barChartOptions); + DomainAxisJSON domainAxisJSON= new DomainAxisJSON(); + domainAxisJSON.setValue("test"); + chartJSON.setDomainAxisJSON(domainAxisJSON); + ArrayList<RangeAxisJSON> rangeAxisJSONList = new ArrayList<>(); + RangeAxisJSON rangeAxisJSON = new RangeAxisJSON(); + rangeAxisJSONList.add(rangeAxisJSON); + chartJSON.setRangeAxisRemoveList(rangeAxisJSONList); + ChartTypeJSON chartTypeJSON = new ChartTypeJSON(); + chartTypeJSON.setValue("BarChart3D"); + chartJSON.setChartTypeJSON(chartTypeJSON); + chartJSON.setRangeAxisList(rangeAxisJSONList); + CommonChartOptions commonChartOptions = new CommonChartOptions(); + commonChartOptions.setLegendLabelAngle("test"); + commonChartOptions.setLegendPosition("legendPosition"); + commonChartOptions.setHideLegend(false); + chartJSON.setCommonChartOptions(commonChartOptions); + return chartJSON; + } + +} |