summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxuegao <xue.gao@intl.att.com>2021-03-25 16:00:32 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2021-03-26 19:16:24 +0000
commite83d137179fa3c532c191f89f9e6cdd53b0778c7 (patch)
treef397a70f4096c068b24b55eb52a93f6789d1523b
parent021978494010df2a4258845b2ada19967869afd1 (diff)
Improve test coverage
Add unit tests to improve test coverage. Issue-ID: SDC-3428 Change-Id: Ifd9e6eb25fa3ec9f4f93d283277574120edff835 Signed-off-by: xuegao <xue.gao@intl.att.com>
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/CollectionUtilsTest.java78
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceTest.java183
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/ResponseFormatTest.java127
-rw-r--r--common-be/src/test/java/org/openecomp/sdc/be/config/NonManoFolderTypeTest.java43
-rw-r--r--common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnumTest.java63
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/test/java/org/openecomp/sdc/health/data/HealthCheckStatusTest.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/test/java/org/openecomp/sdc/health/data/MonitoredModulesTest.java11
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescription.java53
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescriptionTest.java53
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/composition/NodeTemplateInformation.java31
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/YamlValidatorUtilTest.java53
11 files changed, 465 insertions, 242 deletions
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/CollectionUtilsTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/CollectionUtilsTest.java
index eaa2538d11..c5a27bc425 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/CollectionUtilsTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/CollectionUtilsTest.java
@@ -21,59 +21,67 @@
package org.openecomp.sdc.be.dao.utils;
import org.apache.tinkerpop.gremlin.structure.T;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import java.util.*;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class CollectionUtilsTest {
@Test
public void testMerge() throws Exception {
- Set<T> source = null;
- Set<T> target = null;
- Set<T> result;
-
- // test 1
- target = null;
- result = CollectionUtils.merge(source, target);
- Assert.assertEquals(null, result);
+ Set<T> source = new HashSet<>();
+ Set<T> target = new HashSet<>();
+ assertNull(CollectionUtils.merge(source, target));
- // test 2
- source = null;
- result = CollectionUtils.merge(source, target);
- Assert.assertEquals(null, result);
+ T t = null;
+ source.add(t);
+ assertNotNull(CollectionUtils.merge(source, target));
}
@Test
public void testMerge_1() throws Exception {
Map<String, String> source = new HashMap();
Map<String, String> target = new HashMap();
- boolean override = false;
- Map<String, String> result;
- result = CollectionUtils.merge(source, target, override);
- Assert.assertEquals(null, result);
-
- // test 1
- target = null;
- result = CollectionUtils.merge(source, target, override);
- Assert.assertEquals(null, result);
-
- // test 2
- source = null;
- result = CollectionUtils.merge(source, target, override);
- Assert.assertEquals(null, result);
+ source.put("key", "value");
+ target.put("key", "value2");
+ assertEquals("value2", CollectionUtils.merge(source, target, false).get("key"));
+ assertEquals("value", CollectionUtils.merge(source, target, true).get("key"));
}
@Test
public void testMerge_2() throws Exception {
- List<T> source = new LinkedList<>();
- List<T> target = new LinkedList<>();
- List<T> result;
+ List<String> source = null;
+ List<String> target = null;
+ assertEquals(0, CollectionUtils.merge(source, target).size());
+
+ source = new LinkedList<>();
+ target = new LinkedList<>();
+ assertEquals(0, CollectionUtils.merge(source, target).size());
+
+ source.add("test1");
+ target.add("test2");
+ assertEquals("test2", CollectionUtils.merge(source, target).get(0));
+ assertEquals("test1", CollectionUtils.merge(source, target).get(1));
+ }
+
+ @Test
+ public void testUnion() throws Exception {
+ List<String> source = new LinkedList<>();
+ List<String> target = new LinkedList<>();
- // test 1
- result = CollectionUtils.merge(source, target);
- Assert.assertEquals(target, result);
+ source.add("test1");
+ target.add("test2");
+ assertEquals("test1", CollectionUtils.union(source, target).get(0));
+ assertEquals("test2", CollectionUtils.union(source, target).get(1));
}
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceTest.java
index c1a9ad8bba..0cb6f15367 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceTest.java
@@ -20,13 +20,24 @@
package org.openecomp.sdc.be.model;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.CreatedFrom;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
+import org.openecomp.sdc.common.log.api.ILogConfiguration;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
public class ComponentInstanceTest {
private ComponentInstance createTestSubject() {
@@ -35,127 +46,81 @@ public class ComponentInstanceTest {
@Test
public void testCtor() throws Exception {
- new ComponentInstance(new ComponentInstanceDataDefinition());
+ assertNotNull(new ComponentInstance(new ComponentInstanceDataDefinition()));
}
@Test
- public void testGetCapabilities() throws Exception {
- ComponentInstance testSubject;
- Map<String, List<CapabilityDefinition>> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCapabilities();
- }
-
- @Test
- public void testSetCapabilities() throws Exception {
+ public void testCapabilities() throws Exception {
ComponentInstance testSubject;
Map<String, List<CapabilityDefinition>> capabilities = null;
// default test
testSubject = createTestSubject();
testSubject.setCapabilities(capabilities);
+ assertNull(testSubject.getCapabilities());
}
@Test
- public void testGetRequirements() throws Exception {
- ComponentInstance testSubject;
- Map<String, List<RequirementDefinition>> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRequirements();
- }
-
- @Test
- public void testSetRequirements() throws Exception {
+ public void testRequirements() throws Exception {
ComponentInstance testSubject;
Map<String, List<RequirementDefinition>> requirements = null;
// default test
testSubject = createTestSubject();
testSubject.setRequirements(requirements);
+ assertNull(testSubject.getRequirements());
}
@Test
- public void testGetDeploymentArtifacts() throws Exception {
- ComponentInstance testSubject;
- Map<String, ArtifactDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDeploymentArtifacts();
+ public void testDeploymentArtifacts() throws Exception {
+ ComponentInstance testSubject = createTestSubject();
+ Map<String, ArtifactDefinition> deploymentArtifacts = null;
+ testSubject.setDeploymentArtifacts(deploymentArtifacts);
+ assertNull(testSubject.getDeploymentArtifacts());
}
@Test
- public void testSafeGetDeploymentArtifacts() throws Exception {
- ComponentInstance testSubject;
- Map<String, ArtifactDefinition> result;
+ public void testSafeGetDeploymentArtifacts() {
+ ComponentInstance testSubject = createTestSubject();
+ assertEquals(0, testSubject.safeGetDeploymentArtifacts().size());
- // default test
- testSubject = createTestSubject();
- result = testSubject.safeGetDeploymentArtifacts();
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap();
+ deploymentArtifacts.put("test", new ArtifactDefinition());
+ testSubject.setDeploymentArtifacts(deploymentArtifacts);
+ assertEquals(1, testSubject.safeGetDeploymentArtifacts().size());
}
@Test
public void testSafeGetInformationalArtifacts() throws Exception {
- ComponentInstance testSubject;
- Map<String, ArtifactDefinition> result;
+ ComponentInstance testSubject = createTestSubject();
+ assertEquals(0, testSubject.safeGetInformationalArtifacts().size());
- // default test
- testSubject = createTestSubject();
- result = testSubject.safeGetInformationalArtifacts();
+ Map<String, ArtifactDefinition> informationArtifacts = new HashMap();
+ informationArtifacts.put("test", new ArtifactDefinition());
+ testSubject.setArtifacts(informationArtifacts);
+ assertNull(testSubject.safeGetInformationalArtifacts());
}
- @Test
- public void testSetDeploymentArtifacts() throws Exception {
- ComponentInstance testSubject;
- Map<String, ArtifactDefinition> deploymentArtifacts = null;
+ @Test
+ public void testSafeGetArtifacts() throws Exception {
+ ComponentInstance testSubject = createTestSubject();
+ assertEquals(0, testSubject.safeGetArtifacts().size());
- // default test
- testSubject = createTestSubject();
- testSubject.setDeploymentArtifacts(deploymentArtifacts);
- }
+ Map<String, ArtifactDefinition> artifacts = new HashMap();
+ artifacts.put("test", new ArtifactDefinition());
+ testSubject.setArtifacts(artifacts);
+ assertEquals(1, testSubject.safeGetArtifacts().size());
+ }
@Test
- public void testGetArtifacts() throws Exception {
- ComponentInstance testSubject;
- Map<String, ArtifactDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getArtifacts();
- }
-
- @Test
- public void testSafeGetArtifacts() throws Exception {
- ComponentInstance testSubject;
- Map<String, ArtifactDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.safeGetArtifacts();
- }
-
- @Test
- public void testSetArtifacts() throws Exception {
+ public void testArtifacts() throws Exception {
ComponentInstance testSubject;
Map<String, ArtifactDefinition> artifacts = null;
// default test
testSubject = createTestSubject();
testSubject.setArtifacts(artifacts);
- }
-
- @Test
- public void testGetGroupInstances() throws Exception {
- ComponentInstance testSubject;
- List<GroupInstance> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getGroupInstances();
+ assertNull(testSubject.getArtifacts());
}
@Test
@@ -166,29 +131,65 @@ public class ComponentInstanceTest {
// default test
testSubject = createTestSubject();
testSubject.setGroupInstances(groupInstances);
+ assertNull(testSubject.getGroupInstances());
}
@Test
public void testGetActualComponentUid() throws Exception {
- ComponentInstance testSubject;
- String result;
+ ComponentInstance testSubject = createTestSubject();
+ testSubject.setOriginType(OriginTypeEnum.ServiceSubstitution);
+ testSubject.setSourceModelUid("sourceModelUid");
+ testSubject.setComponentUid("componentUid");
+ assertEquals("sourceModelUid", testSubject.getActualComponentUid());
- // default test
- testSubject = createTestSubject();
- result = testSubject.getActualComponentUid();
+ testSubject.setOriginType(OriginTypeEnum.VFC);
+ assertEquals("componentUid", testSubject.getActualComponentUid());
}
@Test
public void testIsArtifactExists() throws Exception {
ComponentInstance testSubject;
- ArtifactGroupTypeEnum groupType = null;
- String artifactLabel = "";
- boolean result;
// default test
testSubject = createTestSubject();
- result = testSubject.isArtifactExists(groupType, artifactLabel);
+ assertFalse(testSubject.isArtifactExists(null, ""));
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap();
+ deploymentArtifacts.put("test", new ArtifactDefinition());
+ testSubject.setDeploymentArtifacts(deploymentArtifacts);
+ testSubject.setArtifacts(deploymentArtifacts);
+ assertTrue(testSubject.isArtifactExists(null, "test"));
+
testSubject = createTestSubject();
- result = testSubject.isArtifactExists(ArtifactGroupTypeEnum.DEPLOYMENT, artifactLabel);
+ assertFalse(testSubject.isArtifactExists(ArtifactGroupTypeEnum.DEPLOYMENT, ""));
+ testSubject.setDeploymentArtifacts(deploymentArtifacts);
+ assertTrue(testSubject.isArtifactExists(ArtifactGroupTypeEnum.DEPLOYMENT, "test"));
}
+
+ @Test
+ public void testAddInterface() throws Exception {
+ ComponentInstance testSubject = createTestSubject();
+ assertNull(testSubject.getInterfaces());
+ testSubject.addInterface("test", new InterfaceDefinition());
+ assertEquals(1, testSubject.getInterfaces().size());
+ }
+
+ @Test
+ public void testGetComponentMetadataForSupportLog() throws Exception {
+ ComponentInstance testSubject = createTestSubject();
+ testSubject.setName("testName");
+ testSubject.setToscaPresentationValue(JsonPresentationFields.VERSION, "1.0");
+ testSubject.setSourceModelUuid("sourceModelUuid");
+ assertEquals(3, testSubject.getComponentMetadataForSupportLog().size());
+ assertEquals("testName", testSubject.getComponentMetadataForSupportLog().get(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME));
+ assertEquals("1.0", testSubject.getComponentMetadataForSupportLog().get(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION));
+ assertEquals("sourceModelUuid", testSubject.getComponentMetadataForSupportLog().get(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID));
+ }
+
+ @Test
+ public void testIsCreatedFromCsar() throws Exception {
+ ComponentInstance testSubject = createTestSubject();
+ testSubject.setCreatedFrom(CreatedFrom.CSAR);
+ assertTrue(testSubject.isCreatedFromCsar());
+ testSubject.setCreatedFrom(CreatedFrom.UI);
+ assertFalse(testSubject.isCreatedFromCsar());}
}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/ResponseFormatTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/ResponseFormatTest.java
index a0e86b9758..8e56d507a0 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/exception/ResponseFormatTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/ResponseFormatTest.java
@@ -20,14 +20,129 @@
package org.openecomp.sdc.exception;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.exception.ResponseFormat.RequestErrorWrapper;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class ResponseFormatTest {
private ResponseFormat createTestSubject() {
return new ResponseFormat();
}
+ @Test
+ public void testGetFormattedMessage() {
+ // okResponseInfo not null
+ ResponseFormat responseFormat1 = new ResponseFormat();
+ RequestErrorWrapper requestErrorWrapper = responseFormat1.new RequestErrorWrapper();
+ OkResponseInfo okResponseInfo = new OkResponseInfo("1", "text", new String[2]);
+ requestErrorWrapper.setOkResponseInfo(okResponseInfo);
+ responseFormat1.setRequestError(requestErrorWrapper);
+
+ assertEquals("text", responseFormat1.getFormattedMessage());
+
+ // okResponseInfo null, serviceException not null
+ ResponseFormat responseFormat2 = new ResponseFormat();
+ RequestErrorWrapper requestErrorWrapper2 = responseFormat2.new RequestErrorWrapper();
+ ServiceException serviceException = new ServiceException("1", "text2", new String[2]);
+ requestErrorWrapper2.setServiceException(serviceException);
+ responseFormat2.setRequestError(requestErrorWrapper2);
+
+ assertEquals("text2", responseFormat2.getFormattedMessage());
+
+ // okResponseInfo null, serviceException null, policyException not null
+ ResponseFormat responseFormat3 = new ResponseFormat();
+ RequestErrorWrapper requestErrorWrapper3 = responseFormat3.new RequestErrorWrapper();
+ PolicyException policyException = new PolicyException("1", "text3", new String[2]);
+ requestErrorWrapper3.setPolicyException(policyException);
+ responseFormat3.setRequestError(requestErrorWrapper3);
+
+ assertEquals("text3", responseFormat3.getFormattedMessage());
+ }
+
+ @Test
+ public void testGetVariables() {
+ // okResponseInfo not null
+ ResponseFormat responseFormat1 = new ResponseFormat();
+ RequestErrorWrapper requestErrorWrapper = responseFormat1.new RequestErrorWrapper();
+ OkResponseInfo okResponseInfo = new OkResponseInfo("1", "text", new String[2]);
+ requestErrorWrapper.setOkResponseInfo(okResponseInfo);
+ responseFormat1.setRequestError(requestErrorWrapper);
+
+ assertEquals(0, responseFormat1.getVariables().length);
+
+ // okResponseInfo null, serviceException not null
+ ResponseFormat responseFormat2 = new ResponseFormat();
+ RequestErrorWrapper requestErrorWrapper2 = responseFormat2.new RequestErrorWrapper();
+ ServiceException serviceException = new ServiceException("1", "text2", new String[2]);
+ requestErrorWrapper2.setServiceException(serviceException);
+ responseFormat2.setRequestError(requestErrorWrapper2);
+
+ assertEquals(0, responseFormat2.getVariables().length);
+
+ // okResponseInfo null, serviceException null, policyException not null
+ ResponseFormat responseFormat3 = new ResponseFormat();
+ RequestErrorWrapper requestErrorWrapper3 = responseFormat3.new RequestErrorWrapper();
+ PolicyException policyException = new PolicyException("1", "text3", new String[2]);
+ requestErrorWrapper3.setPolicyException(policyException);
+ responseFormat3.setRequestError(requestErrorWrapper3);
+
+ assertEquals(0, responseFormat3.getVariables().length);
+ }
+
+ @Test
+ public void testGetMessageId() {
+ // okResponseInfo not null
+ ResponseFormat responseFormat1 = new ResponseFormat();
+ RequestErrorWrapper requestErrorWrapper = responseFormat1.new RequestErrorWrapper();
+ OkResponseInfo okResponseInfo = new OkResponseInfo("1", "text", new String[2]);
+ requestErrorWrapper.setOkResponseInfo(okResponseInfo);
+ responseFormat1.setRequestError(requestErrorWrapper);
+
+ assertEquals("1", responseFormat1.getMessageId());
+
+ // okResponseInfo null, serviceException not null
+ ResponseFormat responseFormat2 = new ResponseFormat();
+ RequestErrorWrapper requestErrorWrapper2 = responseFormat2.new RequestErrorWrapper();
+ ServiceException serviceException = new ServiceException("2", "text2", new String[2]);
+ requestErrorWrapper2.setServiceException(serviceException);
+ responseFormat2.setRequestError(requestErrorWrapper2);
+
+ assertEquals("2", responseFormat2.getMessageId());
+
+ // okResponseInfo null, serviceException null, policyException not null
+ ResponseFormat responseFormat3 = new ResponseFormat();
+ RequestErrorWrapper requestErrorWrapper3 = responseFormat3.new RequestErrorWrapper();
+ PolicyException policyException = new PolicyException("3", "text3", new String[2]);
+ requestErrorWrapper3.setPolicyException(policyException);
+ responseFormat3.setRequestError(requestErrorWrapper3);
+
+ assertEquals("3", responseFormat3.getMessageId());
+ }
+
+ @Test
+ public void testRequestErrorWrapper() {
+ ResponseFormat responseFormat1 = new ResponseFormat();
+ RequestErrorWrapper requestErrorWrapper = responseFormat1.new RequestErrorWrapper();
+ ResponseFormat.RequestError requestError = responseFormat1.new RequestError();
+ requestErrorWrapper.setRequestError(requestError);
+ assertEquals(requestError, requestErrorWrapper.getRequestError());
+ }
+
+ @Test
+ public void testRequestError() {
+ ResponseFormat responseFormat1 = new ResponseFormat();
+ ResponseFormat.RequestError requestError = responseFormat1.new RequestError();
+ ServiceException serviceException = new ServiceException("2", "text2", new String[2]);
+ requestError.setServiceException(serviceException);
+ OkResponseInfo okResponseInfo = new OkResponseInfo("1", "text", new String[2]);
+ requestError.setOkResponseInfo(okResponseInfo);
+ PolicyException policyException = new PolicyException("1", "text3", new String[2]);
+ requestError.setPolicyException(policyException);
+ assertEquals(serviceException, requestError.getServiceException());
+ assertEquals(okResponseInfo, requestError.getOkResponseInfo());
+ assertEquals(policyException, requestError.getPolicyException());
+ }
@Test
public void testSetStatus() throws Exception {
@@ -50,7 +165,7 @@ public class ResponseFormatTest {
}
@Test
- public void testGetRequestError() throws Exception {
+ public void testGetRequestError() {
ResponseFormat testSubject;
RequestErrorWrapper result;
@@ -60,7 +175,7 @@ public class ResponseFormatTest {
}
@Test
- public void testSetRequestError() throws Exception {
+ public void testSetRequestError() {
ResponseFormat testSubject;
RequestErrorWrapper requestErrorWrapper = null;
@@ -70,7 +185,7 @@ public class ResponseFormatTest {
}
@Test
- public void testSetPolicyException() throws Exception {
+ public void testSetPolicyException() {
ResponseFormat testSubject;
PolicyException policyException = null;
@@ -80,7 +195,7 @@ public class ResponseFormatTest {
}
@Test
- public void testSetServiceException() throws Exception {
+ public void testSetServiceException() {
ResponseFormat testSubject;
ServiceException serviceException = null;
@@ -90,7 +205,7 @@ public class ResponseFormatTest {
}
@Test
- public void testSetOkResponseInfo() throws Exception {
+ public void testSetOkResponseInfo() {
ResponseFormat testSubject;
OkResponseInfo okResponseInfo = null;
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/config/NonManoFolderTypeTest.java b/common-be/src/test/java/org/openecomp/sdc/be/config/NonManoFolderTypeTest.java
new file mode 100644
index 0000000000..cf31223973
--- /dev/null
+++ b/common-be/src/test/java/org/openecomp/sdc/be/config/NonManoFolderTypeTest.java
@@ -0,0 +1,43 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.config;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class NonManoFolderTypeTest {
+
+ @Test
+ public void getPathTest() {
+ NonManoFolderType instance = new NonManoFolderType();
+ instance.setType("type");
+ instance.setLocation("location");
+ assertEquals("Artifacts/type/location", instance.getPath());
+ }
+
+ @Test
+ public void isValidTest() {
+ NonManoFolderType instance = new NonManoFolderType();
+ instance.setType("type");
+ instance.setLocation("location");
+ assertTrue(instance.isValid());
+ }
+} \ No newline at end of file
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnumTest.java b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnumTest.java
index 9d98cf237d..6177ada28d 100644
--- a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnumTest.java
+++ b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnumTest.java
@@ -20,7 +20,11 @@
package org.openecomp.sdc.be.datatypes.enums;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class ComponentTypeEnumTest {
@@ -30,48 +34,43 @@ public class ComponentTypeEnumTest {
@Test
public void testGetValue() throws Exception {
- ComponentTypeEnum testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getValue();
+ ComponentTypeEnum testSubject = createTestSubject();
+ assertEquals("Product", testSubject.getValue());
}
@Test
- public void testGetNodeType() throws Exception {
- ComponentTypeEnum testSubject;
- NodeTypeEnum result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getNodeType();
+ public void testGetNodeType() {
+ assertEquals(NodeTypeEnum.Resource, ComponentTypeEnum.RESOURCE.getNodeType());
+ assertEquals(NodeTypeEnum.Product, ComponentTypeEnum.PRODUCT.getNodeType());
+ assertEquals(NodeTypeEnum.Service, ComponentTypeEnum.SERVICE.getNodeType());
+ assertEquals(NodeTypeEnum.ResourceInstance, ComponentTypeEnum.RESOURCE_INSTANCE.getNodeType());
+ assertThrows(UnsupportedOperationException.class, () -> {
+ ComponentTypeEnum.SERVICE_INSTANCE.getNodeType();
+ });
}
@Test
- public void testFindByValue() throws Exception {
- String value = "";
- ComponentTypeEnum result;
-
- // default test
- result = ComponentTypeEnum.findByValue(value);
+ public void testFindByValue() {
+ assertNull(ComponentTypeEnum.findByValue(""));
+ assertEquals(ComponentTypeEnum.RESOURCE, ComponentTypeEnum.findByValue("Resource"));
+ assertEquals(ComponentTypeEnum.SERVICE, ComponentTypeEnum.findByValue("Service"));
+ assertEquals(ComponentTypeEnum.PRODUCT, ComponentTypeEnum.findByValue("Product"));
}
@Test
- public void testFindByParamName() throws Exception {
- String paramName = "";
- ComponentTypeEnum result;
-
- // default test
- result = ComponentTypeEnum.findByParamName(paramName);
+ public void testFindByParamName() {
+ assertNull(ComponentTypeEnum.findByParamName(""));
+ assertEquals(ComponentTypeEnum.RESOURCE, ComponentTypeEnum.findByParamName("resources"));
+ assertEquals(ComponentTypeEnum.SERVICE, ComponentTypeEnum.findByParamName("services"));
+ assertEquals(ComponentTypeEnum.PRODUCT, ComponentTypeEnum.findByParamName("products"));
}
@Test
- public void testFindParamByType() throws Exception {
- ComponentTypeEnum type = null;
- String result;
-
- // default test
- result = ComponentTypeEnum.findParamByType(type);
+ public void testFindParamByType() {
+ assertNull(ComponentTypeEnum.findParamByType(null));
+ assertNull(ComponentTypeEnum.findParamByType(ComponentTypeEnum.RESOURCE_INSTANCE));
+ assertEquals("resources", ComponentTypeEnum.findParamByType(ComponentTypeEnum.RESOURCE));
+ assertEquals("services", ComponentTypeEnum.findParamByType(ComponentTypeEnum.SERVICE));
+ assertEquals("products", ComponentTypeEnum.findParamByType(ComponentTypeEnum.PRODUCT));
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/test/java/org/openecomp/sdc/health/data/HealthCheckStatusTest.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/test/java/org/openecomp/sdc/health/data/HealthCheckStatusTest.java
index 98850defd1..091118e0fa 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/test/java/org/openecomp/sdc/health/data/HealthCheckStatusTest.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/test/java/org/openecomp/sdc/health/data/HealthCheckStatusTest.java
@@ -19,10 +19,11 @@
*/
package org.openecomp.sdc.health.data;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class HealthCheckStatusTest {
@@ -37,4 +38,9 @@ public class HealthCheckStatusTest {
HealthCheckStatus status = HealthCheckStatus.toValue("MAYBE");
assertNull(status);
}
+
+ @Test
+ public void toStringTest() {
+ assertEquals("UP", HealthCheckStatus.UP.toString());
+ }
} \ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/test/java/org/openecomp/sdc/health/data/MonitoredModulesTest.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/test/java/org/openecomp/sdc/health/data/MonitoredModulesTest.java
index fe9415a72c..be578d9ac8 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/test/java/org/openecomp/sdc/health/data/MonitoredModulesTest.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/test/java/org/openecomp/sdc/health/data/MonitoredModulesTest.java
@@ -19,10 +19,10 @@
*/
package org.openecomp.sdc.health.data;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class MonitoredModulesTest {
@@ -37,4 +37,9 @@ public class MonitoredModulesTest {
MonitoredModules modules = MonitoredModules.toValue("UP");
assertNull(modules);
}
+
+ @org.junit.jupiter.api.Test
+ public void toStringTest() {
+ assertEquals("BE", MonitoredModules.BE.toString());
+ }
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescription.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescription.java
index 64d90262da..3e2b38e227 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescription.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescription.java
@@ -19,9 +19,14 @@
*/
package org.openecomp.sdc.enrichment.impl.tosca.model;
+import lombok.Getter;
+import lombok.Setter;
+
import java.util.Objects;
@SuppressWarnings("CheckStyle")
+@Getter
+@Setter
public class PortMirroringConnectionPointDescription {
private String nf_type;
@@ -44,54 +49,6 @@ public class PortMirroringConnectionPointDescription {
pps_capacity = "";
}
- public String getNf_type() {
- return nf_type;
- }
-
- public void setNf_type(String nf_type) {
- this.nf_type = nf_type;
- }
-
- public String getNfc_type() {
- return nfc_type;
- }
-
- public void setNfc_type(String nfc_type) {
- this.nfc_type = nfc_type;
- }
-
- public String getNf_naming_code() {
- return nf_naming_code;
- }
-
- public void setNf_naming_code(String nf_naming_code) {
- this.nf_naming_code = nf_naming_code;
- }
-
- public String getNfc_naming_code() {
- return nfc_naming_code;
- }
-
- public void setNfc_naming_code(String nfc_naming_code) {
- this.nfc_naming_code = nfc_naming_code;
- }
-
- public Object getNetwork_role() {
- return network_role;
- }
-
- public void setNetwork_role(Object network_role) {
- this.network_role = network_role;
- }
-
- public Object getPps_capacity() {
- return pps_capacity;
- }
-
- public void setPps_capacity(String pps_capacity) {
- this.pps_capacity = pps_capacity;
- }
-
public boolean isEmpty() {
return Objects.isNull(nf_type) && Objects.isNull(nfc_type) && Objects.isNull(nf_naming_code) && Objects.isNull(nfc_naming_code) && Objects
.isNull(network_role) && Objects.isNull(pps_capacity);
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescriptionTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescriptionTest.java
new file mode 100644
index 0000000000..c9b08769e0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/model/PortMirroringConnectionPointDescriptionTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.enrichment.impl.tosca.model;
+
+import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PortMirroringConnectionPointDescriptionTest {
+
+ @Test
+ public void testIsEmpty() {
+ PortMirroringConnectionPointDescription testSuite = new PortMirroringConnectionPointDescription();
+ assertFalse(testSuite.isEmpty());
+
+ testSuite.setNf_type(null);
+ assertFalse(testSuite.isEmpty());
+
+ testSuite.setNfc_type(null);
+ assertFalse(testSuite.isEmpty());
+
+ testSuite.setNf_naming_code(null);
+ assertFalse(testSuite.isEmpty());
+
+ testSuite.setNfc_naming_code(null);
+ assertFalse(testSuite.isEmpty());
+
+ testSuite.setNetwork_role(null);
+ assertFalse(testSuite.isEmpty());
+
+ testSuite.setPps_capacity(null);
+ assertTrue(testSuite.isEmpty());
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/composition/NodeTemplateInformation.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/composition/NodeTemplateInformation.java
index 79d00c3048..f0c78fbb9d 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/composition/NodeTemplateInformation.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/composition/NodeTemplateInformation.java
@@ -19,37 +19,20 @@
*/
package org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
/**
* Created by Talio on 4/4/2017.
*/
+@Getter
+@Setter
+@AllArgsConstructor
public class NodeTemplateInformation {
UnifiedCompositionEntity unifiedCompositionEntity;
private NodeTemplate nodeTemplate;
-
- public NodeTemplateInformation() {
- }
-
- public NodeTemplateInformation(UnifiedCompositionEntity unifiedCompositionEntity, NodeTemplate nodeTemplate) {
- this.unifiedCompositionEntity = unifiedCompositionEntity;
- this.nodeTemplate = nodeTemplate;
- }
-
- public UnifiedCompositionEntity getUnifiedCompositionEntity() {
- return unifiedCompositionEntity;
- }
-
- public void setUnifiedCompositionEntity(UnifiedCompositionEntity unifiedCompositionEntity) {
- this.unifiedCompositionEntity = unifiedCompositionEntity;
- }
-
- public NodeTemplate getNodeTemplate() {
- return nodeTemplate;
- }
-
- public void setNodeTemplate(NodeTemplate nodeTemplate) {
- this.nodeTemplate = nodeTemplate;
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/YamlValidatorUtilTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/YamlValidatorUtilTest.java
new file mode 100644
index 0000000000..d7f5b08988
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/util/YamlValidatorUtilTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.validation.util;
+
+
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.openecomp.sdc.validation.impl.util.YamlValidatorUtil;
+import org.yaml.snakeyaml.error.MarkedYAMLException;
+import org.yaml.snakeyaml.parser.ParserException;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.when;
+
+public class YamlValidatorUtilTest {
+ @Test
+ public void testIsEmpty() {
+ MarkedYAMLException markedYamlException = Mockito.mock(MarkedYAMLException.class);
+ when(markedYamlException.getMessage()).thenReturn("test");
+ assertEquals("test", YamlValidatorUtil.getParserExceptionReason(markedYamlException));
+
+ Exception exception = Mockito.mock(Exception.class);
+ when(exception.getCause()).thenReturn(new Exception());
+ assertEquals("general parser error", YamlValidatorUtil.getParserExceptionReason(exception));
+
+ when(markedYamlException.getCause()).thenReturn(new Exception());
+ when(exception.getCause()).thenReturn(markedYamlException);
+ assertEquals("test", YamlValidatorUtil.getParserExceptionReason(exception));
+
+ ParserException parserException = Mockito.mock(ParserException.class);
+ when(parserException.getMessage()).thenReturn("parseException");
+ when(markedYamlException.getCause()).thenReturn(parserException);
+ when(exception.getCause()).thenReturn(markedYamlException);
+ assertEquals("parseException", YamlValidatorUtil.getParserExceptionReason(exception));
+ }
+}