aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/test/java
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-06-19 13:53:06 +0100
committerChristophe Closset <christophe.closset@intl.att.com>2021-07-05 09:21:17 +0000
commit70975c212b58b793d3893e131a3d23d8144f5df9 (patch)
tree320721c50bb0e54030a52c3959a8133642811721 /catalog-dao/src/test/java
parent0625050758c4f999167ef74a22e994fbd356195f (diff)
Reduce usage of outdated library JMockit (catalog-dao)
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3379 Change-Id: I6b46049b71eafbfedfd3d40c68c743efff13ef54
Diffstat (limited to 'catalog-dao/src/test/java')
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDescTest.java68
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java128
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/JsonUtilTest.java137
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceCategoryDataTest.java34
4 files changed, 162 insertions, 205 deletions
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDescTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDescTest.java
index 34529f2b22..036b86e0f5 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDescTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDescTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file 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.
@@ -21,46 +21,30 @@
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
-import mockit.Deencapsulation;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.junit.Test;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribStatusEventTableDesc.DSEFieldsDescription;
-
-import java.util.HashMap;
import java.util.Map;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
+
+class DistribStatusEventTableDescTest {
+
+ private DistribStatusEventTableDesc createTestSubject() {
+ return new DistribStatusEventTableDesc();
+ }
+
+ @Test
+ void testUpdateColumnDistribDescription() throws Exception {
+ final DistribStatusEventTableDesc testSubject = createTestSubject();
+ final Map<String, ImmutablePair<DataType, Boolean>> columnDescription = testSubject.getColumnDescription();
+ Assertions.assertNotNull(columnDescription);
+ Assertions.assertEquals(10, columnDescription.size());
+ }
+
+ @Test
+ void testGetTableName() throws Exception {
+ final DistribStatusEventTableDesc testSubject = createTestSubject();
+ Assertions.assertEquals(AuditingTypesConstants.DISTRIBUTION_STATUS_EVENT_TYPE, testSubject.getTableName());
+ }
-public class DistribStatusEventTableDescTest {
-
- private DistribStatusEventTableDesc createTestSubject() {
- return new DistribStatusEventTableDesc();
- }
-
- @Test
- public void testUpdateColumnDistribDescription() throws Exception {
- DistribStatusEventTableDesc testSubject;
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
- // default test
- testSubject = createTestSubject();
- Deencapsulation.invoke(testSubject, "updateColumnDistribDescription", columns);
- }
-
- @Test
- public void testGetTableName() throws Exception {
- DistribStatusEventTableDesc testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTableName();
- }
-
- @Test
- public void testDSEFieldsDescription() throws Exception {
- DSEFieldsDescription testSubject = DistribStatusEventTableDesc.DSEFieldsDescription.CONSUMER_ID;
-
- testSubject.getName();
- testSubject.getType();
- testSubject.isIndexed();
- }
}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java
index 931186d336..4156c41ce1 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/graph/GraphElementFactoryTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file 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.
@@ -20,81 +20,81 @@
package org.openecomp.sdc.be.dao.graph;
-import mockit.Deencapsulation;
-import org.junit.Test;
+import static org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum.AnnotationType;
+import static org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum.Component;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
+import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
-import java.util.HashMap;
-import java.util.Map;
-
-public class GraphElementFactoryTest {
-
- private static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
- "src/test/resources/config/catalog-dao");
- private static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
-
- @Test
- public void testCreateElement() throws Exception {
- String label = "mock";
- Map<String, Object> properties = new HashMap<>();
- Class<GraphNode> clazz = (Class<GraphNode>) (Mockito.mock(GraphNode.class)).getClass();
-
- // default test
- GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties, clazz);
- }
-
- @Test
- public void testCreateElement_1() throws Exception {
- String label = "mock";
- GraphElementTypeEnum type = null;
- Map<String, Object> properties = new HashMap<>();
- GraphNode result;
+class GraphElementFactoryTest {
- // default test
- result = GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties);
- }
+ private static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+ "src/test/resources/config/catalog-dao");
+ private static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
- @Test
- public void testCreateRelation() throws Exception {
- String type = "";
- Map<String, Object> properties = new HashMap<>();
- GraphNode from = Mockito.mock(GraphNode.class);
- GraphNode to = Mockito.mock(GraphNode.class);
- ;
- GraphRelation result;
+ @Test
+ void testCreateElement() throws Exception {
+ Map<String, Object> properties = new HashMap<>();
+ Arrays.stream(NodeTypeEnum.values()).filter(nodeTypeEnum -> !nodeTypeEnum.equals(AnnotationType) && !nodeTypeEnum.equals(Component))
+ .forEach(nodeTypeEnum -> {
+ Assertions.assertTrue(GraphElementFactory
+ .createElement(nodeTypeEnum.getName(), GraphElementTypeEnum.Node, properties, GraphNode.class) instanceof GraphNode);
+ });
+ Assertions.assertNull(GraphElementFactory.createElement(Component.getName(), GraphElementTypeEnum.Node, properties, GraphNode.class));
+ Assertions.assertThrows(NullPointerException.class,
+ () -> GraphElementFactory.createElement(AnnotationType.getName(), GraphElementTypeEnum.Node, properties, GraphNode.class));
+ }
- // default test
- result = GraphElementFactory.createRelation(type, properties, from, to);
- }
+ @Test
+ void testCreateRelation() throws Exception {
+ GraphRelation result = GraphElementFactory.createRelation("", new HashMap<>(), Mockito.mock(GraphNode.class), Mockito.mock(GraphNode.class));
+ Assertions.assertTrue(result instanceof GraphRelation);
+ Assertions.assertTrue(result.getFrom() instanceof RelationEndPoint);
+ Assertions.assertTrue(result.getTo() instanceof RelationEndPoint);
+ }
- @Test
- public void testCreateNode() throws Exception {
- Map<String, Object> properties = new HashMap<>();
- GraphNode result;
+ @Test
+ void testCreateNode() throws Exception {
+ Map<String, Object> properties = new HashMap<>();
+ GraphNode result;
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.User.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
- NodeTypeEnum.ResourceCategory.getName(), properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.ServiceCategory.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Tag.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Service.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.Property.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode", NodeTypeEnum.HeatParameter.getName(),
- properties);
- result = Deencapsulation.invoke(GraphElementFactory.class, "createNode",
- NodeTypeEnum.HeatParameterValue.getName(), properties);
- }
+ result = GraphElementFactory.createElement(NodeTypeEnum.User.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof GraphNode);
+ result = GraphElementFactory.createElement(NodeTypeEnum.ResourceCategory.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof GraphNode);
+ result = GraphElementFactory.createElement(NodeTypeEnum.ServiceCategory.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ result = GraphElementFactory.createElement(NodeTypeEnum.Tag.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertTrue(result instanceof GraphNode);
+ Assertions.assertNotNull(result);
+ result = GraphElementFactory.createElement(NodeTypeEnum.Service.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof GraphNode);
+ result = GraphElementFactory.createElement(NodeTypeEnum.Property.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ result = GraphElementFactory.createElement(NodeTypeEnum.Resource.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertTrue(result instanceof GraphNode);
+ Assertions.assertNotNull(result);
+ result = GraphElementFactory.createElement(NodeTypeEnum.HeatParameter.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof GraphNode);
+ result = GraphElementFactory.createElement(NodeTypeEnum.HeatParameterValue.getName(), GraphElementTypeEnum.Node, properties);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof GraphNode);
+ }
}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/JsonUtilTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/JsonUtilTest.java
index 5eccc780e5..98dda47129 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/JsonUtilTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/JsonUtilTest.java
@@ -21,82 +21,65 @@
*/
package org.openecomp.sdc.be.dao.utils;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import mockit.Deencapsulation;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import java.io.InputStream;
import java.util.List;
import java.util.Map;
-
-public class JsonUtilTest {
-
- @Test
- public void testGetOneObjectMapper() throws Exception {
- ObjectMapper result;
-
- // default test
- result = Deencapsulation.invoke(JsonUtil.class, "getOneObjectMapper");
- }
-
- @Test
- public void testReadObject() throws Exception {
- String objectText = "{}";
- Class objectClass = Object.class;
- Object result;
-
- // default test
- result = JsonUtil.readObject(objectText, objectClass);
- }
-
- @Test
- public void testReadObject_2() throws Exception {
- String objectText = "{}";
- Object result;
-
- // default test
- result = JsonUtil.readObject(objectText);
- }
-
- @Test
- public void testToMap() throws Exception {
- String json = "{\"name\":\"mock\",\"age\":0}";
- Map<String, Object> result;
-
- // default test
- result = JsonUtil.toMap(json);
- }
-
- @Test
- public void testToMap_1() throws Exception {
- String json = "{\"name\":\"mock\",\"age\":0}";
- Class keyTypeClass = Object.class;
- Class valueTypeClass = Object.class;
- Map result;
-
- // default test
- result = JsonUtil.toMap(json, keyTypeClass, valueTypeClass);
- }
-
- @Test
- public void testToArray() throws Exception {
- String json = "[]";
- Class valueTypeClass = Object.class;
- Object[] result;
-
- // default test
- result = JsonUtil.toArray(json, valueTypeClass);
- }
-
- @Test
- public void testToList() throws Exception {
- String json = "[]";
- Class clazz = Object.class;
- List result;
-
- // default test
- result = JsonUtil.toList(json, clazz);
- }
-} \ No newline at end of file
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class JsonUtilTest {
+
+ @Test
+ void testReadObject_1() throws Exception {
+ final String objectText = "{}";
+ final Class objectClass = Object.class;
+ final Object result = JsonUtil.readObject(objectText, objectClass);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof Map);
+ Assertions.assertEquals(0, ((Map) result).size());
+ }
+
+ @Test
+ void testReadObject_2() throws Exception {
+ final String objectText = "{}";
+ final Object result = JsonUtil.readObject(objectText);
+ Assertions.assertNotNull(result);
+ Assertions.assertTrue(result instanceof Map);
+ Assertions.assertEquals(0, ((Map) result).size());
+ }
+
+ @Test
+ void testToMap_1() throws Exception {
+ final String json = "{\"name\":\"mock\",\"age\":0}";
+ final Map<String, Object> result = JsonUtil.toMap(json);
+ Assertions.assertNotNull(result);
+ Assertions.assertEquals(2, result.size());
+ }
+
+ @Test
+ void testToMap_2() throws Exception {
+ final String json = "{\"name\":\"mock\",\"age\":0}";
+ final Class keyTypeClass = Object.class;
+ final Class valueTypeClass = Object.class;
+ final Map result = JsonUtil.toMap(json, keyTypeClass, valueTypeClass);
+ Assertions.assertNotNull(result);
+ Assertions.assertEquals(2, result.size());
+ }
+
+ @Test
+ void testToArray() throws Exception {
+ final String json = "[]";
+ final Class valueTypeClass = Object.class;
+ final Object[] result = JsonUtil.toArray(json, valueTypeClass);
+ Assertions.assertNotNull(result);
+ }
+
+ @Test
+ void testToList_1() throws Exception {
+ final String json = "[]";
+ final Class clazz = Object.class;
+ final List result = JsonUtil.toList(json, clazz);
+ Assertions.assertNotNull(result);
+ Assertions.assertEquals(0, result.size());
+ }
+
+}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceCategoryDataTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceCategoryDataTest.java
index da0239af05..ba1f735a81 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceCategoryDataTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/ServiceCategoryDataTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file 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.
@@ -20,28 +20,18 @@
package org.openecomp.sdc.be.resources.data;
-import mockit.Deencapsulation;
-import org.apache.commons.collections.map.HashedMap;
-import org.junit.Test;
-public class ServiceCategoryDataTest {
+import java.util.HashMap;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
- private ServiceCategoryData createTestSubject() {
- return new ServiceCategoryData();
- }
+class ServiceCategoryDataTest {
- @Test
- public void testCtor() throws Exception {
- new ServiceCategoryData(new HashedMap());
- new ServiceCategoryData("mock");
- }
-
- @Test
- public void testCreateUniqueId() throws Exception {
- ServiceCategoryData testSubject;
+ @Test
+ void testCtor() throws Exception {
+ Assertions.assertNotNull(new ServiceCategoryData());
+ Assertions.assertNotNull(new ServiceCategoryData(new HashMap()));
+ Assertions.assertNotNull(new ServiceCategoryData("mock"));
+ }
- // default test
- testSubject = createTestSubject();
- Deencapsulation.invoke(testSubject, "createUniqueId");
- }
}