diff options
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base')
11 files changed, 820 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ChartSeqComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ChartSeqComparatorTest.java new file mode 100644 index 00000000..25b70b8b --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ChartSeqComparatorTest.java @@ -0,0 +1,66 @@ +/* + * ============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.base; + +import static org.junit.Assert.assertNotEquals; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; + +public class ChartSeqComparatorTest { + + ChartSeqComparator chartSeqComparator; + + private Integer CHAR_SEQ = 1000; + + @Before + public void init() { + chartSeqComparator = new ChartSeqComparator(); + } + + + @Test + public void testCompare() { + DataColumnType dct1 = new DataColumnType(); + DataColumnType dct2 = new DataColumnType(); + dct1.setChartSeq(CHAR_SEQ); + dct2.setChartSeq(CHAR_SEQ); + assertNotEquals(true, chartSeqComparator.compare(dct1, dct2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameColLookupTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameColLookupTest.java new file mode 100644 index 00000000..9269d240 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameColLookupTest.java @@ -0,0 +1,75 @@ +/* + * ============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.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class IdNameColLookupTest { + + IdNameColLookup idNameColLookup; + + private String COL_ID = "colId"; + private String DB_TABLE_NAME = "dbTableName"; + private String DB_ID_FIELD = "dbIdField"; + private String DB_NAME_FIELD = "dbNameField"; + private String DB_SORT_BY_FIELD = "dbSortByField"; + + @Before + public void init() { + idNameColLookup = new IdNameColLookup(COL_ID, DB_TABLE_NAME, DB_ID_FIELD, DB_NAME_FIELD, DB_SORT_BY_FIELD); + } + + @Test + public void testNotNull() { + assertNotNull(idNameColLookup); + } + + @Test + public void testIdNameColLookupProperties() { + assertEquals(COL_ID, idNameColLookup.getColId()); + assertEquals(DB_TABLE_NAME, idNameColLookup.getDbTableName()); + assertEquals(DB_ID_FIELD, idNameColLookup.getDbIdField()); + assertEquals(DB_NAME_FIELD, idNameColLookup.getDbNameField()); + assertEquals(DB_SORT_BY_FIELD, idNameColLookup.getDbSortByField()); + } +} + diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameListTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameListTest.java new file mode 100644 index 00000000..cff2eb83 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameListTest.java @@ -0,0 +1,82 @@ +/* + * ============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.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.portalsdk.analytics.system.Globals; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class}) +public class IdNameListTest { + + IdNameList idNameList; + + private String ID = "testID"; + private String NAME = "test"; + private boolean DEFAULT_VALUE = true; + private boolean READ_ONLY = true; + + @Before + public void init() { + PowerMockito.mockStatic(Globals.class); + PowerMockito.when(Globals.getFormFieldsListSize()).thenReturn(100); + idNameList = new IdNameList(); + idNameList.addValue(ID, NAME, DEFAULT_VALUE, READ_ONLY); + } + + @Test + public void testGetIdByName() { + assertEquals(ID, idNameList.getIdByName(NAME)); + } + + @Test + public void testGetNameById() { + assertEquals(NAME, idNameList.getNameById(ID)); + } + + + + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameLookupTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameLookupTest.java new file mode 100644 index 00000000..725d179d --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameLookupTest.java @@ -0,0 +1,76 @@ +/* + * ============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.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class IdNameLookupTest { + + IdNameLookup idNameLookup; + + private String DB_TABLE_NAME = "dbTableName"; + private String DB_ID_FIELD = "dbIdField"; + private String DB_NAME_FIELD = "dbNameField"; + private String DB_SORT_BY_FIELD = "dbSortByField"; + private String DEFAULT_SQL = "defaultSQL"; + private boolean TEXT_FIELD = true; + + @Before + public void init() { + idNameLookup = new IdNameLookup(DB_TABLE_NAME, DB_ID_FIELD, DB_NAME_FIELD, DB_SORT_BY_FIELD, DEFAULT_SQL, TEXT_FIELD); + } + + @Test + public void testNotNull() { + assertNotNull(idNameLookup); + } + + @Test + public void testIdNameLookupProperties() { + assertEquals(DB_TABLE_NAME, idNameLookup.getDbTableName()); + assertEquals(DB_ID_FIELD, idNameLookup.getDbIdField()); + assertEquals(DB_NAME_FIELD, idNameLookup.getDbNameField()); + assertEquals(DB_SORT_BY_FIELD, idNameLookup.getDbSortByField()); + assertEquals(DEFAULT_SQL, idNameLookup.getDefaultSQL()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameSqlTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameSqlTest.java new file mode 100644 index 00000000..78e8dffa --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameSqlTest.java @@ -0,0 +1,80 @@ +/* + * ============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.base; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.system.ConnectionUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.util.RemDbInfo; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({Globals.class, IdNameSql.class, ConnectionUtils.class}) +public class IdNameSqlTest { + + IdNameSql idNameSql; + + @Before + public void init() { + idNameSql = new IdNameSql("select * from test", "select * from test"); + } + + @Test + public void testLoadData() throws Exception { + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(ConnectionUtils.class); + Mockito.when(Globals.getDBType()).thenReturn("test"); + RemDbInfo remDbInfo = Mockito.mock(RemDbInfo.class); + PowerMockito.whenNew(RemDbInfo.class).withNoArguments().thenReturn(remDbInfo); + Mockito.when(remDbInfo.getDBType(Mockito.anyString())).thenReturn("test"); + Mockito.when(Globals.getReportSqlForFormfield()).thenReturn("test"); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(ConnectionUtils.getDataSet(Mockito.anyString(), Mockito.anyString())).thenReturn(ds); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + idNameSql.loadData("select", 10, "testDB"); + } +} + diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameValueTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameValueTest.java new file mode 100644 index 00000000..0c798684 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/IdNameValueTest.java @@ -0,0 +1,69 @@ +/* + * ============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.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class IdNameValueTest { + + IdNameValue idNameValue; + + private String ID = "id"; + private String NMAE = "name"; + + @Before + public void init() { + idNameValue = new IdNameValue(ID, NMAE); + } + + @Test + public void testNotNull() { + assertNotNull(idNameValue); + } + + @Test + public void testIdNameValueProperties() { + assertEquals(ID, idNameValue.getId()); + assertEquals(NMAE, idNameValue.getName()); + } + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/NameComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/NameComparatorTest.java new file mode 100644 index 00000000..8d9c3385 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/NameComparatorTest.java @@ -0,0 +1,64 @@ +/* + * ============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.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +public class NameComparatorTest { + + NameComparator nameComparator; + private String NAME = "name"; + + @Before + public void init() { + nameComparator = new NameComparator(); + } + + @Test + public void testCompare() { + IdNameValue idNameValue1 = new IdNameValue(); + idNameValue1.setName(NAME); + IdNameValue idNameValue2 = new IdNameValue(); + idNameValue2.setName(NAME); + + assertEquals(0, nameComparator.compare(idNameValue1, idNameValue2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderBySeqComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderBySeqComparatorTest.java new file mode 100644 index 00000000..cd403e7c --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderBySeqComparatorTest.java @@ -0,0 +1,65 @@ +/* + * ============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.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; + +public class OrderBySeqComparatorTest { + + OrderBySeqComparator orderBySeqComparator; + private Integer CHAR_SEQ = 100; + + @Before + public void init() { + orderBySeqComparator = new OrderBySeqComparator(); + } + + @Test + public void testCompare() { + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setOrderBySeq(CHAR_SEQ); + DataColumnType dataColumnType2 = new DataColumnType(); + dataColumnType2.setOrderBySeq(CHAR_SEQ); + + assertEquals(0, orderBySeqComparator.compare(dataColumnType1, dataColumnType2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderSeqComparatorTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderSeqComparatorTest.java new file mode 100644 index 00000000..dd6c7050 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/OrderSeqComparatorTest.java @@ -0,0 +1,64 @@ +/* + * ============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.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.onap.portalsdk.analytics.xmlobj.DataColumnType; + +public class OrderSeqComparatorTest { + OrderSeqComparator orderSeqComparator; + private Integer CHAR_SEQ = 100; + + @Before + public void init() { + orderSeqComparator = new OrderSeqComparator(); + } + + @Test + public void testCompare() { + DataColumnType dataColumnType1 = new DataColumnType(); + dataColumnType1.setOrderSeq(CHAR_SEQ); + DataColumnType dataColumnType2 = new DataColumnType(); + dataColumnType2.setOrderSeq(CHAR_SEQ); + + assertEquals(0, orderSeqComparator.compare(dataColumnType1, dataColumnType2)); + } +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportSecurityTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportSecurityTest.java new file mode 100644 index 00000000..c8a2a97e --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportSecurityTest.java @@ -0,0 +1,105 @@ +/* + * ============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.base; + +import java.util.Vector; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.portalsdk.analytics.error.RaptorException; +import org.onap.portalsdk.analytics.system.AppUtils; +import org.onap.portalsdk.analytics.system.DbUtils; +import org.onap.portalsdk.analytics.system.Globals; +import org.onap.portalsdk.analytics.util.DataSet; +import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({AppUtils.class, Globals.class, DbUtils.class}) +public class ReportSecurityTest { + + ReportSecurity reportSecurity; + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + + @Before + public void setUp() throws RaptorException { + PowerMockito.mockStatic(AppUtils.class); + PowerMockito.mockStatic(Globals.class); + PowerMockito.mockStatic(DbUtils.class); + Mockito.when(Globals.getReportSecurity()).thenReturn("select * from test"); + DataSet ds = Mockito.mock(DataSet.class); + Mockito.when(DbUtils.executeQuery(Mockito.anyString())).thenReturn(ds); + Mockito.when(ds.getString(Mockito.anyInt(), Mockito.anyInt())).thenReturn("test"); + Mockito.when(ds.getRowCount()).thenReturn(1); + Mockito.when(Globals.getReportUserAccess()).thenReturn("select * test"); + reportSecurity = new ReportSecurity("test"); + Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("USERID"); + Vector userRoles = new Vector(); + userRoles.add("test"); + Mockito.when(AppUtils.getUserRoles(Mockito.anyString())).thenReturn(userRoles); + Mockito.when(AppUtils.getUserName(Mockito.anyString())).thenReturn("test"); + Mockito.when(AppUtils.getAdminRoleIDs()).thenReturn(userRoles); + Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(userRoles); + Mockito.when(Globals.getDeleteOnlyByOwner()).thenReturn(false); + } + + @Test + public void testCheckUserReadAccess() throws RaptorException { + reportSecurity.checkUserReadAccess(mockedRequest, null); + } + + @Test + public void testCheckUserWriteAccess() throws RaptorException { + reportSecurity.checkUserWriteAccess(mockedRequest); + } + + @Test + public void testCheckUserDeleteAccess() throws RaptorException { + reportSecurity.checkUserWriteAccess(mockedRequest); + } + + +} diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportUserRoleTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportUserRoleTest.java new file mode 100644 index 00000000..19d1eddc --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/base/ReportUserRoleTest.java @@ -0,0 +1,74 @@ +/* + * ============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.base; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class ReportUserRoleTest { + + ReportUserRole reportUserRole; + private Long REP_ID = 1L; + private Long ORDER_NO = 2L; + private Long ROLE_ID = 3L; + private Long USER_ID = 4L; + private String READ_ONLY_YN = "Y"; + + @Before + public void init() { + reportUserRole = new ReportUserRole(REP_ID, ORDER_NO, ROLE_ID, USER_ID, READ_ONLY_YN); + } + + @Test + public void testNotNull() { + assertNotNull(reportUserRole); + } + + @Test + public void testReportUserRoleProperties() { + assertEquals(REP_ID, reportUserRole.getRepId()); + assertEquals(ORDER_NO, reportUserRole.getOrderNo()); + assertEquals(ROLE_ID, reportUserRole.getRoleId()); + assertEquals(USER_ID, reportUserRole.getUserId()); + assertEquals(READ_ONLY_YN, reportUserRole.getReadOnlyYn()); + } +} |