aboutsummaryrefslogtreecommitdiffstats
path: root/ms/neng/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'ms/neng/src/test/java')
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyEarlierTest.java4
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyLaterTest.java4
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyOnUnnamedTest.java2
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorExcMissingDataTest.java16
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorNoSequenceTest.java2
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSeqGenErrorsTest.java6
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSequenceMultiTest.java2
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSequenceTest.java2
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java26
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/AaiResponseTest.java21
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigRequestTest.java10
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigResponseTest.java2
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/HelloWorldTest.java5
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenRequestTest.java14
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenResponseTest.java11
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java38
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java95
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/validator/AaiNameValidatorTest.java52
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedNameTest.java127
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMapTest.java27
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetailsTest.java19
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameterTest.java35
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java69
23 files changed, 409 insertions, 180 deletions
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyEarlierTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyEarlierTest.java
index ccbd4913..44ff6e93 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyEarlierTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyEarlierTest.java
@@ -107,7 +107,7 @@ public class NameGeneratorDependencyEarlierTest {
when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), anyInt())).thenReturn(1L);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement1, allElements, earlierNames, policyCache);
+ namePresister, requestElement1, allElements, earlierNames, policyCache, new ArrayList<>());
Map<String, String> resp = gen.generate();
assertEquals("vnf-name", resp.get("resource-name"));
@@ -115,7 +115,7 @@ public class NameGeneratorDependencyEarlierTest {
assertEquals("abcde001ve1", resp.get("resource-value"));
NameGenerator gen2 = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement2, allElements, earlierNames, policyCache);
+ namePresister, requestElement2, allElements, earlierNames, policyCache, new ArrayList<>());
Map<String, String> resp2 = gen2.generate();
assertEquals("vm-name", resp2.get("resource-name"));
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyLaterTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyLaterTest.java
index 009db5da..a2f54337 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyLaterTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyLaterTest.java
@@ -106,7 +106,7 @@ public class NameGeneratorDependencyLaterTest {
when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), anyInt())).thenReturn(1L);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement1, allElements, earlierNames, policyCache);
+ namePresister, requestElement1, allElements, earlierNames, policyCache, new ArrayList<>());
Map<String, String> resp = gen.generate();
assertEquals("vm-name", resp.get("resource-name"));
@@ -114,7 +114,7 @@ public class NameGeneratorDependencyLaterTest {
assertEquals("abcde001ve1mts001", resp.get("resource-value"));
NameGenerator gen2 = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement2, allElements, earlierNames, policyCache);
+ namePresister, requestElement2, allElements, earlierNames, policyCache, new ArrayList<>());
Map<String, String> resp2 = gen2.generate();
assertEquals("vnf-name", resp2.get("resource-name"));
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyOnUnnamedTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyOnUnnamedTest.java
index e4f3ddc2..be243407 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyOnUnnamedTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorDependencyOnUnnamedTest.java
@@ -107,7 +107,7 @@ public class NameGeneratorDependencyOnUnnamedTest {
}).when(namePresister).persist(anyObject());
NameGenerator gen2 = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement2, allElements, earlierNames, policyCache);
+ namePresister, requestElement2, allElements, earlierNames, policyCache, new ArrayList<>());
Map<String, String> resp2 = gen2.generate();
assertEquals("vm-name", resp2.get("resource-name"));
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorExcMissingDataTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorExcMissingDataTest.java
index d05644b8..fdbf5d30 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorExcMissingDataTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorExcMissingDataTest.java
@@ -81,7 +81,7 @@ public class NameGeneratorExcMissingDataTest {
when(policyFinder.findPolicy(policyName)).thenReturn(null);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement, allElements, earlierNames, policyCache);
+ namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>());
try {
gen.generate();
@@ -102,7 +102,7 @@ public class NameGeneratorExcMissingDataTest {
allElements.add(requestElement);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement, allElements, earlierNames, policyCache);
+ namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>());
try {
gen.generate();
@@ -124,7 +124,7 @@ public class NameGeneratorExcMissingDataTest {
allElements.add(requestElement);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement, allElements, earlierNames, policyCache);
+ namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>());
try {
gen.generate();
@@ -145,7 +145,7 @@ public class NameGeneratorExcMissingDataTest {
allElements.add(requestElement);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement, allElements, earlierNames, policyCache);
+ namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>());
try {
gen.generate();
@@ -173,7 +173,7 @@ public class NameGeneratorExcMissingDataTest {
when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), anyInt())).thenReturn(1L);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement, allElements, earlierNames, policyCache);
+ namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>());
try {
gen.generate();
@@ -199,7 +199,7 @@ public class NameGeneratorExcMissingDataTest {
when(policyFinder.findPolicy(policyName)).thenReturn(policy);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement, allElements, earlierNames, policyCache);
+ namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>());
try {
gen.generate();
@@ -225,7 +225,7 @@ public class NameGeneratorExcMissingDataTest {
when(policyFinder.findPolicy(policyName)).thenReturn(policy);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement, allElements, earlierNames, policyCache);
+ namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>());
try {
gen.generate();
@@ -251,7 +251,7 @@ public class NameGeneratorExcMissingDataTest {
when(policyFinder.findPolicy(policyName)).thenReturn(policy);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement, allElements, earlierNames, policyCache);
+ namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>());
try {
gen.generate();
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorNoSequenceTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorNoSequenceTest.java
index e46ab083..2242229c 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorNoSequenceTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorNoSequenceTest.java
@@ -82,7 +82,7 @@ public class NameGeneratorNoSequenceTest {
when(dbValidator.validate(anyObject(), anyObject())).thenReturn(true);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement, allElements, earlierNames, policyCache);
+ namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>());
Map<String, String> resp = gen.generate();
assertEquals("vnf-name", resp.get("resource-name"));
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSeqGenErrorsTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSeqGenErrorsTest.java
index 46f1e942..ae8dcffd 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSeqGenErrorsTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSeqGenErrorsTest.java
@@ -124,7 +124,7 @@ public class NameGeneratorSeqGenErrorsTest {
}).when(namePresister).persist(anyObject());
NameGenerator gen2 = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement2, allElements, earlierNames, policyCache);
+ namePresister, requestElement2, allElements, earlierNames, policyCache, new ArrayList<>());
Map<String, String> resp2 = gen2.generate();
assertEquals("vm-name", resp2.get("resource-name"));
@@ -183,7 +183,7 @@ public class NameGeneratorSeqGenErrorsTest {
when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), eq(3))).thenReturn(3L);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement2, allElements, earlierNames, policyCache);
+ namePresister, requestElement2, allElements, earlierNames, policyCache, new ArrayList<>());
try {
gen.generate();
@@ -210,7 +210,7 @@ public class NameGeneratorSeqGenErrorsTest {
when(dbValidator.validate(anyObject(), anyObject())).thenReturn(false);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement2, allElements, earlierNames, policyCache);
+ namePresister, requestElement2, allElements, earlierNames, policyCache, new ArrayList<>());
try {
gen.generate();
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSequenceMultiTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSequenceMultiTest.java
index 41f0531a..2f23fbdb 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSequenceMultiTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSequenceMultiTest.java
@@ -103,7 +103,7 @@ public class NameGeneratorSequenceMultiTest {
when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), eq(4))).thenReturn(4L);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement, allElements, earlierNames, policyCache);
+ namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>());
Map<String, String> resp = gen.generate();
assertEquals("vnf-name", resp.get("resource-name"));
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSequenceTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSequenceTest.java
index 9501522d..df94ab50 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSequenceTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/gen/NameGeneratorSequenceTest.java
@@ -95,7 +95,7 @@ public class NameGeneratorSequenceTest {
when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), anyInt())).thenReturn(1L);
NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator,
- namePresister, requestElement, allElements, earlierNames, policyCache);
+ namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>());
Map<String, String> resp = gen.generate();
assertEquals("vnf-name", resp.get("resource-name"));
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java
index 38d44f18..c3471564 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java
@@ -65,7 +65,7 @@ public class PropertyOperatorTest {
Map<String, String> props = new HashMap<>();
props.put("property-operation", "to_lower_case()");
PropertyOperator op = new PropertyOperator();
- assertEquals("asdf", op.apply("ASDF", props, params));
+ assertEquals("asdf", op.apply("ASDF", props, params, null));
}
@Test
@@ -73,7 +73,7 @@ public class PropertyOperatorTest {
Map<String, String> props = new HashMap<>();
props.put("property-operation", "to_upper_case()");
PropertyOperator op = new PropertyOperator();
- assertEquals("ASDF", op.apply("asdf", props, params));
+ assertEquals("ASDF", op.apply("asdf", props, params, null));
}
@Test
@@ -90,21 +90,31 @@ public class PropertyOperatorTest {
Map<String, String> props = new HashMap<>();
props.put("property-operation", "sub_str(0,5)");
- assertEquals("01234", op.apply("0123456789", props, params));
+ assertEquals("01234", op.apply("0123456789", props, params, null));
props.put("property-operation", " sub_str(0,4)");
- assertEquals("0123", op.apply("0123456789", props, params));
+ assertEquals("0123", op.apply("0123456789", props, params, null));
props.put("property-operation", "sub_str(1,5)");
- assertEquals("1234", op.apply("0123456789", props, params));
+ assertEquals("1234", op.apply("0123456789", props, params, null));
props.put("property-operation", "sub_str(1)");
- assertEquals("0", op.apply("0", props, params));
+ assertEquals("0", op.apply("0", props, params, null));
props.put("property-operation", "sub_str(-2)");
- assertEquals("89", op.apply("0123456789", props, params));
+ assertEquals("89", op.apply("0123456789", props, params, null));
props.put("property-operation", "sub_str(-3)");
- assertEquals("789", op.apply("0123456789", props, params));
+ assertEquals("789", op.apply("0123456789", props, params, null));
+ }
+
+ @Test
+ public void testApply_non_mapped() throws Exception {
+ String operation = "to_upper_case";
+ PolicyParameters policyParams = mock(PolicyParameters.class);
+ when(policyParams.mapFunction("sub_str")).thenReturn("substring");
+ PropertyOperator op = new PropertyOperator();
+ String resp = op.apply("MyString", operation, policyParams);
+ assertEquals("MYSTRING", resp);
}
}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/AaiResponseTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/AaiResponseTest.java
index 81279b9d..a8b2cfa9 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/AaiResponseTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/AaiResponseTest.java
@@ -21,21 +21,22 @@
package org.onap.ccsdk.apps.ms.neng.core.resource.model;
import static org.junit.Assert.assertEquals;
+
import org.junit.Before;
import org.junit.Test;
public class AaiResponseTest {
- private AaiResponse aai;
+ private AaiResponse aai;
- @Before
- public void setup() {
- aai = new AaiResponse();
- }
-
- @Test
+ @Before
+ public void setup() {
+ aai = new AaiResponse();
+ }
+
+ @Test
public void isRecFound() {
- aai.setRecFound(true);
- assertEquals(true, aai.isRecFound());
+ aai.setRecFound(true);
+ assertEquals(true, aai.isRecFound());
}
-
}
+
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigRequestTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigRequestTest.java
index 20d234ab..fcf0d8bb 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigRequestTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigRequestTest.java
@@ -20,8 +20,6 @@
package org.onap.ccsdk.apps.ms.neng.core.resource.model;
-import static org.junit.Assert.assertEquals;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -35,25 +33,25 @@ public class GetConfigRequestTest {
}
@Test
- public void TestGetSetConfigName() {
+ public void testGetSetConfigName() {
getConfigRequest.setConfigName("configName");
Assert.assertEquals("configName", getConfigRequest.getConfigName());
}
@Test
- public void TestGetSetEcompName() {
+ public void testGetSetEcompName() {
getConfigRequest.setEcompName("ecompName");
Assert.assertEquals("ecompName", getConfigRequest.getEcompName());
}
@Test
- public void TestGetSetPolicyName() {
+ public void testGetSetPolicyName() {
getConfigRequest.setPolicyName("policy");
Assert.assertEquals("policy", getConfigRequest.getPolicyName());
}
@Test
- public void TestIsUniqueFunction() {
+ public void testIsUniqueFunction() {
getConfigRequest.setUnique(true);
Assert.assertTrue(getConfigRequest.isUnique());
}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigResponseTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigResponseTest.java
index a833834f..90735d95 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigResponseTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigResponseTest.java
@@ -33,7 +33,7 @@ public class GetConfigResponseTest {
}
@Test
- public void TestGetSetConfigName() {
+ public void testGetSetConfigName() {
String obj = new String();
getConfigResponse.setResponse(obj);
Assert.assertEquals(obj, getConfigResponse.getResponse());
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/HelloWorldTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/HelloWorldTest.java
index b09d6d60..d6e36fc9 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/HelloWorldTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/HelloWorldTest.java
@@ -21,21 +21,20 @@
package org.onap.ccsdk.apps.ms.neng.core.resource.model;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
public class HelloWorldTest {
private HelloWorld helloWorld;
@Test
- public void TestGetSetMessage() {
+ public void testGetSetMessage() {
helloWorld = new HelloWorld();
helloWorld.setMessage("new Message");
Assert.assertEquals("new Message", helloWorld.getMessage());
}
@Test
- public void TestToString() {
+ public void testToString() {
helloWorld = new HelloWorld("new Message");
Assert.assertEquals("message = new Message", helloWorld.toString());
}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenRequestTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenRequestTest.java
index 620208a1..ef33de21 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenRequestTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenRequestTest.java
@@ -20,13 +20,13 @@
package org.onap.ccsdk.apps.ms.neng.core.resource.model;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.HashMap;
public class NameGenRequestTest {
private NameGenRequest nameGenRequest;
@@ -37,7 +37,7 @@ public class NameGenRequestTest {
}
@Test
- public void TestGetSetElements() {
+ public void testGetSetElements() {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
Map<String, String> map = new HashMap<String, String>();
map.put("el1", "el2");
@@ -47,7 +47,7 @@ public class NameGenRequestTest {
}
@Test
- public void TestToStringFunction() {
+ public void testToStringFunction() {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
Map<String, String> map = new HashMap<String, String>();
map.put("el1", "el2");
@@ -57,7 +57,7 @@ public class NameGenRequestTest {
}
@Test
- public void TestGetSetUseDb() {
+ public void testGetSetUseDb() {
nameGenRequest.setUseDb(true);
Assert.assertTrue(nameGenRequest.getUseDb());
}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenResponseTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenResponseTest.java
index f1a73199..509601c1 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenResponseTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenResponseTest.java
@@ -20,16 +20,13 @@
package org.onap.ccsdk.apps.ms.neng.core.resource.model;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
public class NameGenResponseTest {
private NameGenResponse nameGenResponse;
@@ -40,7 +37,7 @@ public class NameGenResponseTest {
}
@Test
- public void TestGetSetElements() {
+ public void testGetSetElements() {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
Map<String, String> map = new HashMap<String, String>();
map.put("el1", "el2");
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java
index aca0a533..737eea7b 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -49,6 +50,7 @@ import org.onap.ccsdk.apps.ms.neng.persistence.entity.ExternalInterface;
import org.onap.ccsdk.apps.ms.neng.persistence.entity.GeneratedName;
import org.onap.ccsdk.apps.ms.neng.persistence.entity.PolicyDetails;
import org.onap.ccsdk.apps.ms.neng.persistence.repository.ExternalInterfaceRespository;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.GeneratedNameRespository;
import org.onap.ccsdk.apps.ms.neng.persistence.repository.PolicyDetailsRepository;
import org.onap.ccsdk.apps.ms.neng.persistence.repository.ServiceParameterRepository;
import org.onap.ccsdk.apps.ms.neng.service.extinf.impl.AaiServiceImpl;
@@ -90,6 +92,8 @@ public class SpringServiceIntTest {
RestServiceImpl restServiceImpl;
@Autowired
ExternalInterfaceRespository extIntRepo;
+ @Autowired
+ GeneratedNameRespository repository;
@Before
public void setup() {
@@ -115,7 +119,7 @@ public class SpringServiceIntTest {
name.setExternalId("EXT-11");
namePersister.persist(name);
- name = namePersister.findBy("VNF", "abcd6ytx", null);
+ name = namePersister.findByElementTypeAndNameAndReleased("VNF", "abcd6ytx", null);
assertNotNull(name);
}
@@ -238,5 +242,37 @@ public class SpringServiceIntTest {
assertNotNull(extIntDb);
assertEquals("nodes/generic-vnfs?vnf-name=",extIntDb.getUrlSuffix());
}
+
+ @Test
+ public void testUpdateNetworkElementName() throws Exception {
+ GeneratedName gn = new GeneratedName();
+ gn.setExternalId("VQA-UN81");
+ gn.setSequenceNumber(1L);
+ gn.setElementType("VNF");
+ gn.setName("DG001ESP");
+ gn.setPrefix("DG");
+ gn.setSuffix("ESP");
+ gn.setCreatedBy("test");
+ gn.setCreatedTime(new Timestamp(System.currentTimeMillis()));
+
+ namePersister.persist(gn);
+ Map<String, String> reqMap = new HashMap<String, String>();
+ reqMap.put("external-key","VQA-UN81");
+ reqMap.put("resource-name", "vnf-name");
+ reqMap.put("resource-value", "DG001ESP1");
+
+ when(aaiServiceImpl.validate(Matchers.anyString(), Matchers.anyString())).thenReturn(true);
+
+ List<Map<String,String>> elList = new ArrayList<>();
+ elList.add(reqMap);
+ NameGenRequest request = new NameGenRequest();
+ request.setElements(elList);
+ restServiceImpl.generateNetworkElementName(request);
+
+ List<GeneratedName> newGn = repository.findByExternalId("VQA-UN81");
+ assertTrue(newGn != null);
+ assertTrue(newGn.size() == 1);
+ assertEquals("DG001ESP1", newGn.get(0).getName());
+ }
}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java
index 22063a4d..b679e9ba 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java
@@ -30,11 +30,15 @@ import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
+import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.ccsdk.apps.ms.neng.core.exceptions.NengException;
+import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister;
import org.onap.ccsdk.apps.ms.neng.core.resource.model.HelloWorld;
import org.onap.ccsdk.apps.ms.neng.core.resource.model.NameGenRequest;
+import org.onap.ccsdk.apps.ms.neng.core.validator.AaiNameValidator;
import org.onap.ccsdk.apps.ms.neng.core.validator.ExternalKeyValidator;
import org.onap.ccsdk.apps.ms.neng.persistence.entity.GeneratedName;
import org.onap.ccsdk.apps.ms.neng.persistence.entity.PolicyDetails;
@@ -58,6 +62,10 @@ public class SpringServiceTest {
PolicyDetailsRepository policyDetailsRepository;
@Mock
GeneratedNameRespository generatedNameRepository;
+ @Mock
+ AaiNameValidator aaiNameValidator;
+ @Mock
+ NamePersister namePersister;
@InjectMocks
SpringServiceImpl springserviceImpl;
@@ -85,8 +93,31 @@ public class SpringServiceTest {
Mockito.when(externalKeyValidator.isPresent(req.get("external-key"))).thenReturn(false);
Mockito.when(serviceParamRepo.findByName("use_db_policy")).thenReturn(param);
springserviceImpl.genNetworkElementName(request);
+ }
+
+ @Test
+ public void genNetworkElementNameTest_empty_elements() throws Exception {
+ NameGenRequest request = new NameGenRequest();
+ request.setElements(new ArrayList<>());
+ springserviceImpl.genNetworkElementName(request);
}
+
+ @Test
+ public void genNetworkElementNameTest_extkey_error_3() throws Exception {
+ NameGenRequest request = new NameGenRequest();
+ List<Map<String, String>> rsp = new ArrayList<>();
+ request.setElements(rsp);
+ springserviceImpl.genNetworkElementName(request);
+ }
+
+ @Test(expected = Exception.class)
+ public void genNetworkElementNameTest_useDb() throws Exception {
+ Mockito.when(externalKeyValidator.isPresent(req.get("external-key"))).thenReturn(false);
+ Mockito.when(serviceParamRepo.findByName("use_db_policy")).thenReturn(param);
+ request.setUseDb(true);
+ springserviceImpl.genNetworkElementName(request);
+ }
@Test
public void getPolicyDetailsTest() {
@@ -109,9 +140,30 @@ public class SpringServiceTest {
Assert.assertNotNull(springserviceImpl.releaseNetworkElementName(request));
}
- @Test(expected=Exception.class)
+ @Test(expected = Exception.class)
public void releaseNetworkElementNameTestForNull() throws Exception {
- springserviceImpl.releaseNetworkElementName(null);
+ springserviceImpl.releaseNetworkElementName(null);
+ }
+
+ @Test(expected = Exception.class)
+ public void releaseNetworkElementNameTest_exp() throws Exception {
+ GeneratedName gn = new GeneratedName();
+ List<GeneratedName> generatedNameList = new ArrayList<>();
+ generatedNameList.add(gn);
+
+ Mockito.when(generatedNameRepository.findByExternalId(req.get("external-key"))).thenThrow(new Exception());
+ springserviceImpl.releaseNetworkElementName(request);
+ }
+
+ @Test(expected = Exception.class)
+ public void releaseNetworkElementNameTest_exp_neng() throws Exception {
+ GeneratedName gn = new GeneratedName();
+ List<GeneratedName> generatedNameList = new ArrayList<>();
+ generatedNameList.add(gn);
+
+ Mockito.when(generatedNameRepository.findByExternalId(req.get("external-key"))).thenThrow(
+ new NengException("Failed"));
+ springserviceImpl.releaseNetworkElementName(request);
}
@Test
@@ -123,4 +175,43 @@ public class SpringServiceTest {
public void testGetQuickHelloForNullMessage() {
Assert.assertTrue(springserviceImpl.getQuickHello("") instanceof HelloWorld);
}
+
+ @Test
+ public void updateNetworkElementName() throws Exception {
+ req.clear();
+ req.put("external-key", "TST-UV1");
+ req.put("resource-name", "vnf-name");
+ req.put("resource-value", "dst1000tv1");
+ req.put("naming-type", "vnf");
+
+ GeneratedName gn = new GeneratedName();
+ gn.setExternalId("TST-UV1");
+ gn.setElementType("VNF");
+ gn.setName("dst1000tv1");
+
+ List<GeneratedName> generatedNameList = new ArrayList<>();
+ generatedNameList.add(gn);
+ Mockito.when(namePersister.findByExternalIdAndElementType(req.get("external-key"), "VNF")).thenReturn(gn);
+ Mockito.when(aaiNameValidator.validate(Matchers.anyString(), Matchers.anyString())).thenReturn(true);
+ Assert.assertNotNull(springserviceImpl.updateNetworkElementName(request));
+ Mockito.verify(namePersister, Mockito.times(1)).persist(gn);
+ }
+
+ @Test(expected = NengException.class)
+ public void updateNetworkElementName_Aai_Fail() throws Exception {
+ req.clear();
+ req.put("external-key", "TST-UV1");
+ req.put("resource-name", "vnf-name");
+ req.put("resource-value", "dst1000tv1");
+ req.put("naming-type", "vnf");
+
+ GeneratedName gn = new GeneratedName();
+ gn.setExternalId("TST-UV1");
+ gn.setElementType("VNF");
+ gn.setName("dst1000tv1");
+
+ Mockito.when(namePersister.findByExternalIdAndElementType(req.get("external-key"), "VNF")).thenReturn(null);
+ Mockito.when(aaiNameValidator.validate(Matchers.anyString(), Matchers.anyString())).thenReturn(false);
+ springserviceImpl.updateNetworkElementName(request);
+ }
}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/validator/AaiNameValidatorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/validator/AaiNameValidatorTest.java
new file mode 100644
index 00000000..e8fa6d0b
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/validator/AaiNameValidatorTest.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.onap.ccsdk.apps.ms.neng.core.validator;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.ExternalInterfaceRespository;
+import org.onap.ccsdk.apps.ms.neng.service.extinf.impl.AaiServiceImpl;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AaiNameValidatorTest {
+ @Mock
+ AaiServiceImpl aaiImpl;
+
+ @Mock
+ ExternalInterfaceRespository dbStuff;
+
+ @InjectMocks
+ AaiNameValidator nameValidator;
+
+ @Test
+ public void testValidate() throws Exception {
+ when(dbStuff.getUriByNameType(Matchers.anyString())).thenReturn(null);
+ assertTrue(nameValidator.validate("VNF", "xyz112uyv"));
+ }
+}
+
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedNameTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedNameTest.java
index 7965b7a4..bdd5356c 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedNameTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedNameTest.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.ccsdk.apps.ms.neng.persistence.entity;
import org.junit.Assert;
@@ -24,67 +25,67 @@ import org.junit.Before;
import org.junit.Test;
public class GeneratedNameTest {
- private GeneratedName generatedName;
-
- @Before
- public void setUp() {
- generatedName = new GeneratedName();
- }
-
- @Test
- public void testGetSetGeneratedNameId() {
- generatedName.setGeneratedNameId(1);
- Integer expected = 1;
- Assert.assertEquals(expected, generatedName.getGeneratedNameId());
- }
-
- @Test
- public void testGetSetSequenceNumber() {
- generatedName.setSequenceNumber(2121314312321L);
- Long expected = 2121314312321L;
- Assert.assertEquals(expected, generatedName.getSequenceNumber());
- }
-
- @Test
- public void testGetSetSequenceNumberEnc() {
- generatedName.setSequenceNumberEnc("TestSequenceNumberEnc");
- String expected = "TestSequenceNumberEnc";
- Assert.assertEquals(expected, generatedName.getSequenceNumberEnc());
- }
-
- @Test
- public void testGetSetElementType() {
- generatedName.setElementType("TestElementType");
- String expected = "TestElementType";
- Assert.assertEquals(expected, generatedName.getElementType());
- }
-
- @Test
- public void testGetSetName() {
- generatedName.setName("TestName");
- String expected = "TestName";
- Assert.assertEquals(expected, generatedName.getName());
- }
-
- @Test
- public void testGetSetPrefix() {
- generatedName.setPrefix("TestPrefix");
- String expected = "TestPrefix";
- Assert.assertEquals(expected, generatedName.getPrefix());
- }
-
- @Test
- public void testGetSetSuffix() {
- generatedName.setSuffix("TestSuffix");
- String expected = "TestSuffix";
- Assert.assertEquals(expected, generatedName.getSuffix());
- }
-
- @Test
- public void testGetSetIsReleased() {
- generatedName.setIsReleased("TestIsReleased");
- String expected = "TestIsReleased";
- Assert.assertEquals(expected, generatedName.getIsReleased());
- }
-
+ private GeneratedName generatedName;
+
+ @Before
+ public void setUp() {
+ generatedName = new GeneratedName();
+ }
+
+ @Test
+ public void testGetSetGeneratedNameId() {
+ generatedName.setGeneratedNameId(1);
+ Integer expected = 1;
+ Assert.assertEquals(expected, generatedName.getGeneratedNameId());
+ }
+
+ @Test
+ public void testGetSetSequenceNumber() {
+ generatedName.setSequenceNumber(2121314312321L);
+ Long expected = 2121314312321L;
+ Assert.assertEquals(expected, generatedName.getSequenceNumber());
+ }
+
+ @Test
+ public void testGetSetSequenceNumberEnc() {
+ generatedName.setSequenceNumberEnc("TestSequenceNumberEnc");
+ String expected = "TestSequenceNumberEnc";
+ Assert.assertEquals(expected, generatedName.getSequenceNumberEnc());
+ }
+
+ @Test
+ public void testGetSetElementType() {
+ generatedName.setElementType("TestElementType");
+ String expected = "TestElementType";
+ Assert.assertEquals(expected, generatedName.getElementType());
+ }
+
+ @Test
+ public void testGetSetName() {
+ generatedName.setName("TestName");
+ String expected = "TestName";
+ Assert.assertEquals(expected, generatedName.getName());
+ }
+
+ @Test
+ public void testGetSetPrefix() {
+ generatedName.setPrefix("TestPrefix");
+ String expected = "TestPrefix";
+ Assert.assertEquals(expected, generatedName.getPrefix());
+ }
+
+ @Test
+ public void testGetSetSuffix() {
+ generatedName.setSuffix("TestSuffix");
+ String expected = "TestSuffix";
+ Assert.assertEquals(expected, generatedName.getSuffix());
+ }
+
+ @Test
+ public void testGetSetIsReleased() {
+ generatedName.setIsReleased("TestIsReleased");
+ String expected = "TestIsReleased";
+ Assert.assertEquals(expected, generatedName.getIsReleased());
+ }
}
+
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMapTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMapTest.java
index dc510429..30e98d4d 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMapTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMapTest.java
@@ -31,68 +31,69 @@ import org.junit.Before;
import org.junit.Test;
public class IdentifierMapTest {
- private IdentifierMap identifierMap;
+ private IdentifierMap identifierMap;
@Before
public void setUp() {
- identifierMap = new IdentifierMap();
+ identifierMap = new IdentifierMap();
}
@Test
public void testGetSetIdentifierMapId() {
- identifierMap.setIdentifierMapId(1);
+ identifierMap.setIdentifierMapId(1);
Integer expected = 1;
Assert.assertEquals(expected, identifierMap.getIdentifierMapId());
}
@Test
public void testGetSetPolicyFnName() {
- identifierMap.setPolicyFnName("PolicyFnName");
+ identifierMap.setPolicyFnName("PolicyFnName");
String expected = "PolicyFnName";
Assert.assertEquals(expected, identifierMap.getPolicyFnName());
}
@Test
public void testGetSetJsFnName() {
- identifierMap.setJsFnName("JsFnName");
+ identifierMap.setJsFnName("JsFnName");
String expected = "JsFnName";
Assert.assertEquals(expected, identifierMap.getJsFnName());
}
@Test
public void testGetSetCreatedTime() throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = dateFormat.parse("23/09/2007");
long time = date.getTime();
Timestamp timeStamp = new Timestamp(time);
- identifierMap.setCreatedTime(timeStamp);
- Timestamp expected = timeStamp;
+ identifierMap.setCreatedTime(timeStamp);
+ Timestamp expected = timeStamp;
Assert.assertEquals(expected, identifierMap.getCreatedTime());
}
@Test
public void testGetSetCreatedBy() {
- identifierMap.setCreatedBy("Name");
+ identifierMap.setCreatedBy("Name");
String expected = "Name";
Assert.assertEquals(expected, identifierMap.getCreatedBy());
}
@Test
public void testGetSetLastUpdatedTime() throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = dateFormat.parse("23/09/2007");
long time = date.getTime();
Timestamp timeStamp = new Timestamp(time);
- identifierMap.setLastUpdatedTime(timeStamp);
- Timestamp expected = timeStamp;
+ identifierMap.setLastUpdatedTime(timeStamp);
+ Timestamp expected = timeStamp;
Assert.assertEquals(expected, identifierMap.getLastUpdatedTime());
}
@Test
public void testGetSetLastUpdatedBy() {
- identifierMap.setLastUpdatedBy("Name");
+ identifierMap.setLastUpdatedBy("Name");
String expected = "Name";
Assert.assertEquals(expected, identifierMap.getLastUpdatedBy());
}
}
+
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetailsTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetailsTest.java
index 70508684..6506f439 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetailsTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetailsTest.java
@@ -20,7 +20,6 @@
package org.onap.ccsdk.apps.ms.neng.persistence.entity;
-
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
@@ -32,44 +31,42 @@ import org.junit.Before;
import org.junit.Test;
public class PolicyDetailsTest {
- private PolicyDetails policyDetails;
+ private PolicyDetails policyDetails;
@Before
public void setUp() {
- policyDetails = new PolicyDetails();
+ policyDetails = new PolicyDetails();
}
@Test
public void testGetSetPolicyId() {
- policyDetails.setPolicyId(1);
+ policyDetails.setPolicyId(1);
Integer expected = 1;
Assert.assertEquals(expected, policyDetails.getPolicyId());
}
@Test
public void testGetSetPolicyName() {
- policyDetails.setPolicyName("PolicyName");
+ policyDetails.setPolicyName("PolicyName");
String expected = "PolicyName";
Assert.assertEquals(expected, policyDetails.getPolicyName());
}
@Test
public void testGetSetPolicyResponse() {
- policyDetails.setPolicyResponse("PolicyResponse");
+ policyDetails.setPolicyResponse("PolicyResponse");
String expected = "PolicyResponse";
Assert.assertEquals(expected, policyDetails.getPolicyResponse());
}
@Test
public void testGetSetCreatedTime() throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = dateFormat.parse("23/09/2007");
long time = date.getTime();
Timestamp timeStamp = new Timestamp(time);
- policyDetails.setCreatedTime(timeStamp);
- String expected = "PolicyResponse";
+ policyDetails.setCreatedTime(timeStamp);
Assert.assertEquals(timeStamp, policyDetails.getCreatedTime());
}
-
-
}
+
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameterTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameterTest.java
index 42118a5d..25bfe126 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameterTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameterTest.java
@@ -31,65 +31,66 @@ import org.junit.Before;
import org.junit.Test;
public class ServiceParameterTest {
- private ServiceParameter serviceParameter;
+ private ServiceParameter serviceParameter;
@Before
public void setUp() {
- serviceParameter = new ServiceParameter();
+ serviceParameter = new ServiceParameter();
}
@Test
public void testGetSetServiceParameterId() {
- serviceParameter.setServiceParameterId(1);
+ serviceParameter.setServiceParameterId(1);
Integer expected = 1;
Assert.assertEquals(expected, serviceParameter.getServiceParameterId());
}
@Test
public void testGetSetName() {
- serviceParameter.setName("Name");
+ serviceParameter.setName("Name");
String expected = "Name";
Assert.assertEquals(expected, serviceParameter.getName());
}
@Test
public void testGetSetValue() {
- serviceParameter.setValue("Value");
+ serviceParameter.setValue("Value");
String expected = "Value";
Assert.assertEquals(expected, serviceParameter.getValue());
}
@Test
public void testGetSetCreatedTime() throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateFormat.parse("23/09/2007");
- long time = date.getTime();
- Timestamp timeStamp = new Timestamp(time);
- serviceParameter.setCreatedTime(timeStamp);
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateFormat.parse("23/09/2007");
+ long time = date.getTime();
+ Timestamp timeStamp = new Timestamp(time);
+ serviceParameter.setCreatedTime(timeStamp);
Assert.assertEquals(timeStamp, serviceParameter.getCreatedTime());
}
@Test
public void testGetSetCreatedBy() {
- serviceParameter.setCreatedBy("CreatedBy");
+ serviceParameter.setCreatedBy("CreatedBy");
String expected = "CreatedBy";
Assert.assertEquals(expected, serviceParameter.getCreatedBy());
}
@Test
public void testGetSetLastUpdatedBy() {
- serviceParameter.setLastUpdatedBy("LastUpdatedBy");
+ serviceParameter.setLastUpdatedBy("LastUpdatedBy");
String expected = "LastUpdatedBy";
Assert.assertEquals(expected, serviceParameter.getLastUpdatedBy());
}
@Test
public void testGetSetLastUpdatedTime() throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateFormat.parse("23/09/2007");
- long time = date.getTime();
- Timestamp timeStamp = new Timestamp(time);
- serviceParameter.setLastUpdatedTime(timeStamp);
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateFormat.parse("23/09/2007");
+ long time = date.getTime();
+ Timestamp timeStamp = new Timestamp(time);
+ serviceParameter.setLastUpdatedTime(timeStamp);
Assert.assertEquals(timeStamp, serviceParameter.getLastUpdatedTime());
}
}
+
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java
index 77ec7eeb..7732ac71 100644
--- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java
@@ -22,7 +22,18 @@
package org.onap.ccsdk.apps.ms.neng.service.extinf.impl;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.when;
+
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -43,14 +54,6 @@ import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class PolicyFinderServiceImplTest {
@InjectMocks
@@ -77,13 +80,13 @@ public class PolicyFinderServiceImplTest {
assertNull(policyFinder.findPolicy("policy"));
}
- @SuppressWarnings("unchecked")
@Test(expected = NengException.class)
- public void testHandleError_NOT_FOUND() throws Exception{
- HttpStatusCodeException e = new HttpClientErrorException(HttpStatus.NOT_FOUND,"",null,StandardCharsets.US_ASCII);
+ public void testHandleError_Not_Found() throws Exception {
+ HttpStatusCodeException e = new HttpClientErrorException(HttpStatus.NOT_FOUND,"",
+ null,StandardCharsets.US_ASCII);
policyFinder.handleError(e);
-
}
+
@SuppressWarnings("unchecked")
@Test
public void testmakeOutboundCall() throws Exception {
@@ -213,4 +216,46 @@ public class PolicyFinderServiceImplTest {
configMap.put("config", contentMap);
return configMap;
}
+
+ @SuppressWarnings("unchecked")
+ @Test(expected = NengException.class)
+ public void testmakeOutboundCall_500_statusExp() throws Exception {
+ HttpClientErrorException exp = new HttpClientErrorException(HttpStatus.METHOD_NOT_ALLOWED, "{error}");
+ when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenThrow(exp);
+ policManProps.setUrl("http://policyManager.onap.org");
+ GetConfigRequest request = new GetConfigRequest();
+ request.setPolicyName("policy");
+ policyFinder.makeOutboundCall(request, GetConfigResponse.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test(expected = NengException.class)
+ public void testmakeOutboundCall_500_statusExp_notFound() throws Exception {
+ HttpClientErrorException exp = new HttpClientErrorException(HttpStatus.NOT_FOUND, "{error}");
+ when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenThrow(exp);
+ policManProps.setUrl("http://policyManager.onap.org");
+ GetConfigRequest request = new GetConfigRequest();
+ request.setPolicyName("policy");
+ policyFinder.makeOutboundCall(request, GetConfigResponse.class);
+ }
+
+ @Test
+ public void testmakeOutboundCall_err_policy() throws Exception {
+ Map<String, Object> configMap = buildPolicyResponse();
+ Object resp = configMap;
+ GetConfigResponse configResp = new GetConfigResponse();
+ configResp.setResponse(resp);
+ doReturn(configResp).when(policyFinder).getConfig("policy");
+ assertNull(policyFinder.findPolicy("policy"));
+ }
+
+ @Test
+ public void testmakeOutboundCall_err_policy_empty() throws Exception {
+ Object resp = Arrays.asList(new Object[]{});
+ GetConfigResponse configResp = new GetConfigResponse();
+ configResp.setResponse(resp);
+ doReturn(configResp).when(policyFinder).getConfig("policy");
+ assertNull(policyFinder.findPolicy("policy"));
+ }
+
}