From c31b73a86a38ab45fa833016a18637f6431918db Mon Sep 17 00:00:00 2001 From: Anjali walsatwar Date: Fri, 5 Oct 2018 14:14:27 +0530 Subject: UT for catalog be datamodel UT for catalog be datamodel class Issue-ID: SDC-1775 Change-Id: Id1a9a8c32fc674a553a1fd5d40426b0c08b07d15 Signed-off-by: Anjali walsatwar --- .../sdc/be/datamodel/ForwardingPathsTest.java | 21 ++++++++++++ .../openecomp/sdc/be/datamodel/NameIdPairTest.java | 10 ++++++ .../sdc/be/datamodel/NameIdPairWrapperTest.java | 9 ++++++ .../sdc/be/datamodel/ServiceRelationsTest.java | 37 ++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/ForwardingPathsTest.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/ServiceRelationsTest.java (limited to 'catalog-be/src/test') diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/ForwardingPathsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/ForwardingPathsTest.java new file mode 100644 index 0000000000..ba5f4cb0a7 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/ForwardingPathsTest.java @@ -0,0 +1,21 @@ +package org.openecomp.sdc.be.datamodel; + +import org.junit.Test; + +import java.util.Set; +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ForwardingPathsTest { + + @Test + public void testForwardingPaths() { + ForwardingPaths testForwardingPaths = new ForwardingPaths(); + Set path= new HashSet<>(Arrays.asList("test")); + testForwardingPaths.setForwardingPathToDelete(path); + Set getPath = testForwardingPaths.getForwardingPathToDelete(); + assertThat(getPath).isEqualTo(path); + } + +} \ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairTest.java index f2a468207b..cc6c03bdd5 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairTest.java @@ -20,6 +20,16 @@ public class NameIdPairTest { result = testSubject.getName(); } + @Test + public void testConstructorWith3Parameters() throws Exception { + NameIdPair testSubject; + String result; + + // default test + testSubject = new NameIdPair("", "",""); + result = testSubject.getOwnerId(); + } + @Test public void testSetName() throws Exception { NameIdPair testSubject; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairWrapperTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairWrapperTest.java index 452d02d3ea..4f6e7cace4 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairWrapperTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/NameIdPairWrapperTest.java @@ -19,6 +19,15 @@ public class NameIdPairWrapperTest { testSubject.init(nameIdPair); } + @Test + public void testInitWithObject() throws Exception { + NameIdPairWrapper testSubject; + NameIdPair nameIdPair = new NameIdPair("mock", "mock"); + + // default test + testSubject = new NameIdPairWrapper(nameIdPair); + } + @Test public void testGetId() throws Exception { NameIdPairWrapper testSubject; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/ServiceRelationsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/ServiceRelationsTest.java new file mode 100644 index 0000000000..dc89f1ed37 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/ServiceRelationsTest.java @@ -0,0 +1,37 @@ +package org.openecomp.sdc.be.datamodel; + +import org.junit.Test; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ServiceRelationsTest { + + private NameIdPair getNameIdPairWrapper() { + return new NameIdPair("mock", "mock"); + } + + @Test + public void testServiceRelations() { + + NameIdPairWrapper testNameIdPairWrapper; + NameIdPair nameIdPair = new NameIdPair("mock", "mock"); + + testNameIdPairWrapper = new NameIdPairWrapper(); + testNameIdPairWrapper.init(nameIdPair); + + Set result = new HashSet(); + result.add(testNameIdPairWrapper); + + + ServiceRelations testServiceRelations = new ServiceRelations(); + ServiceRelations testServiceRelationsWithRelations = new ServiceRelations(result); + testServiceRelations.setRelations(result); + Set getResult = testServiceRelations.getRelations(); + assertThat(getResult).isEqualTo(result); + } + +} \ No newline at end of file -- cgit 1.2.3-korg