diff options
Diffstat (limited to 'ms')
27 files changed, 114 insertions, 209 deletions
diff --git a/ms/neng/pom.xml b/ms/neng/pom.xml index 6af6f768..795617da 100644 --- a/ms/neng/pom.xml +++ b/ms/neng/pom.xml @@ -18,6 +18,7 @@ * limitations under the License. * ============LICENSE_END========================================================= --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -54,18 +55,19 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <sdk.java.rest>6.2.0.11</sdk.java.rest> <serviceArtifactName>ms-networkelementnamegen</serviceArtifactName> - <ccsdk.distribution.version>1.2.2</ccsdk.distribution.version> + <ccsdk.distribution.version>1.4.1</ccsdk.distribution.version> <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy> <docker.push.phase>deploy</docker.push.phase> <docker.verbose>true</docker.verbose> <ccsdk.project.version>${project.version}</ccsdk.project.version> <base.image.name>onap/ccsdk-alpine-j11-image</base.image.name> - <base.image.version>1.2.2</base.image.version> + <base.image.version>1.4.1</base.image.version> <image.name>onap/ccsdk-apps-ms-neng</image.name> <timestamp>${maven.build.timestamp}</timestamp> <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format> - <ccsdk.project.version>${project.version}</ccsdk.project.version> - <ccsdk.build.timestamp>${maven.build.timestamp}</ccsdk.build.timestamp> + <ccsdk.project.version>${project.version}</ccsdk.project.version> + <ccsdk.build.timestamp>${maven.build.timestamp}</ccsdk.build.timestamp> + </properties> <dependencies> @@ -125,10 +127,6 @@ <artifactId>mariadb-java-client</artifactId> </dependency> <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - </dependency> - <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> @@ -183,10 +181,20 @@ <version>${ccsdk.sli.version}</version> </dependency> <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>${gson.version}</version> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> 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 29251794..cdddadad 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 @@ -21,8 +21,8 @@ package org.onap.ccsdk.apps.ms.neng.core.gen; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyObject; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -35,7 +35,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister; import org.onap.ccsdk.apps.ms.neng.core.policy.FilePolicyReader; import org.onap.ccsdk.apps.ms.neng.core.policy.PolicyFinder; @@ -103,9 +103,9 @@ public class NameGeneratorDependencyEarlierTest { Map<String, Object> policy = new FilePolicyReader("vnf_and_vm_policy.json").getPolicy(); Mockito.lenient().when(policyFinder.findPolicy(policyName)).thenReturn(policy); - Mockito.lenient().when(aaiValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(dbValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), anyInt())).thenReturn(1L); + Mockito.lenient().when(aaiValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(dbValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), anyInt())).thenReturn(1L); NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator, namePresister, requestElement1, allElements, earlierNames, policyCache, new ArrayList<>()); 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 0463c6b2..1a863ce9 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 @@ -21,8 +21,8 @@ package org.onap.ccsdk.apps.ms.neng.core.gen; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyObject; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -35,7 +35,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister; import org.onap.ccsdk.apps.ms.neng.core.policy.FilePolicyReader; import org.onap.ccsdk.apps.ms.neng.core.policy.PolicyFinder; @@ -102,9 +102,9 @@ public class NameGeneratorDependencyLaterTest { Map<String, Object> policy = new FilePolicyReader("vnf_and_vm_policy.json").getPolicy(); Mockito.lenient().when(policyFinder.findPolicy(policyName)).thenReturn(policy); - Mockito.lenient().when(aaiValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(dbValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), anyInt())).thenReturn(1L); + Mockito.lenient().when(aaiValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(dbValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), anyInt())).thenReturn(1L); NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator, namePresister, requestElement1, allElements, earlierNames, policyCache, new ArrayList<>()); 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 b9b781b7..b1c74412 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 @@ -21,8 +21,8 @@ package org.onap.ccsdk.apps.ms.neng.core.gen; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyObject; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -37,7 +37,7 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.mockito.stubbing.Answer; import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister; import org.onap.ccsdk.apps.ms.neng.core.policy.FilePolicyReader; @@ -94,9 +94,9 @@ public class NameGeneratorDependencyOnUnnamedTest { Map<String, Object> policy = new FilePolicyReader("vnf_and_vm_policy.json").getPolicy(); Mockito.lenient().when(policyFinder.findPolicy(policyName)).thenReturn(policy); - Mockito.lenient().when(aaiValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(dbValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), anyInt())).thenReturn(1L); + Mockito.lenient().when(aaiValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(dbValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), anyInt())).thenReturn(1L); final List<Object> savedNames = new ArrayList<>(); doAnswer(new Answer<Void>() { @@ -105,7 +105,7 @@ public class NameGeneratorDependencyOnUnnamedTest { savedNames.add(invocation.getArguments()[0]); return null; } - }).when(namePresister).persist(anyObject()); + }).when(namePresister).persist(any()); NameGenerator gen2 = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator, namePresister, requestElement2, allElements, earlierNames, policyCache, new ArrayList<>()); 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 a28d364b..76fb3298 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 @@ -22,8 +22,8 @@ package org.onap.ccsdk.apps.ms.neng.core.gen; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyObject; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -35,7 +35,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister; import org.onap.ccsdk.apps.ms.neng.core.policy.FilePolicyReader; import org.onap.ccsdk.apps.ms.neng.core.policy.PolicyFinder; @@ -169,9 +169,9 @@ public class NameGeneratorExcMissingDataTest { Map<String, Object> policy = new FilePolicyReader("bad_policy_missing_recipe.json").getPolicy(); Mockito.lenient().when(policyFinder.findPolicy(policyName)).thenReturn(policy); - Mockito.lenient().when(aaiValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(dbValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), anyInt())).thenReturn(1L); + Mockito.lenient().when(aaiValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(dbValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), anyInt())).thenReturn(1L); NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator, namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>()); 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 aa2d96cf..bc3e6c81 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 @@ -21,7 +21,7 @@ package org.onap.ccsdk.apps.ms.neng.core.gen; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyObject; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -33,7 +33,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister; import org.onap.ccsdk.apps.ms.neng.core.policy.FilePolicyReader; import org.onap.ccsdk.apps.ms.neng.core.policy.PolicyFinder; @@ -79,8 +79,8 @@ public class NameGeneratorNoSequenceTest { Map<String, Object> policy = new FilePolicyReader("vnf_policy_no_seq.json").getPolicy(); Mockito.lenient().when(policyFinder.findPolicy(policyName)).thenReturn(policy); - Mockito.lenient().when(aaiValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(dbValidator.validate(anyObject(), anyObject())).thenReturn(true); + Mockito.lenient().when(aaiValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(dbValidator.validate(any(), any())).thenReturn(true); NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator, namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>()); 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 bf8e9b35..d5ba85b2 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 @@ -22,7 +22,7 @@ package org.onap.ccsdk.apps.ms.neng.core.gen; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import static org.mockito.Matchers.anyObject; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; @@ -38,7 +38,7 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.mockito.stubbing.Answer; import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister; import org.onap.ccsdk.apps.ms.neng.core.policy.FilePolicyReader; @@ -108,13 +108,13 @@ public class NameGeneratorSeqGenErrorsTest { Mockito.lenient().when(policyParams.getMaxGenAttempt()).thenReturn(100); Mockito.lenient().when(policyFinder.findPolicy(policyName)).thenReturn(policy); - Mockito.lenient().when(aaiValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(aaiValidator.validate(eq("VNF"), anyObject())).thenReturn(true); + Mockito.lenient().when(aaiValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(aaiValidator.validate(eq("VNF"), any())).thenReturn(true); Mockito.lenient().when(aaiValidator.validate(eq("VNF"), eq("abcde001ve1"))).thenReturn(false); - Mockito.lenient().when(dbValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), eq(1))).thenReturn(1L); - Mockito.lenient().when(sequenceGenerator.generate(eq("abcde"), anyObject(), anyObject(), anyObject(), eq(2))).thenReturn(2L); + Mockito.lenient().when(dbValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), eq(1))).thenReturn(1L); + Mockito.lenient().when(sequenceGenerator.generate(eq("abcde"), any(), any(), any(), eq(2))).thenReturn(2L); final List<Object> savedNames = new ArrayList<>(); doAnswer(new Answer<Void>() { @@ -123,7 +123,7 @@ public class NameGeneratorSeqGenErrorsTest { savedNames.add(invocation.getArguments()[0]); return null; } - }).when(namePresister).persist(anyObject()); + }).when(namePresister).persist(any()); NameGenerator gen2 = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator, namePresister, requestElement2, allElements, earlierNames, policyCache, new ArrayList<>()); @@ -180,10 +180,10 @@ public class NameGeneratorSeqGenErrorsTest { Map<String, Object> policy = new FilePolicyReader("vnf_and_vm_policy.json").getPolicy(); Mockito.lenient().when(policyParams.getMaxGenAttempt()).thenReturn(3); Mockito.lenient().when(policyFinder.findPolicy(policyName)).thenReturn(policy); - Mockito.lenient().when(dbValidator.validate(anyObject(), anyObject())).thenReturn(false); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), eq(1))).thenReturn(1L); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), eq(2))).thenReturn(2L); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), eq(3))).thenReturn(3L); + Mockito.lenient().when(dbValidator.validate(any(), any())).thenReturn(false); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), eq(1))).thenReturn(1L); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), eq(2))).thenReturn(2L); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), eq(3))).thenReturn(3L); NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator, namePresister, requestElement2, allElements, earlierNames, policyCache, new ArrayList<>()); @@ -210,7 +210,7 @@ public class NameGeneratorSeqGenErrorsTest { Map<String, Object> policy = new FilePolicyReader("vnf_policy_no_seq.json").getPolicy(); Mockito.lenient().when(policyParams.getMaxGenAttempt()).thenReturn(3); Mockito.lenient().when(policyFinder.findPolicy(policyName)).thenReturn(policy); - Mockito.lenient().when(dbValidator.validate(anyObject(), anyObject())).thenReturn(false); + Mockito.lenient().when(dbValidator.validate(any(), any())).thenReturn(false); NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator, namePresister, requestElement2, allElements, earlierNames, policyCache, new ArrayList<>()); 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 18e85e51..96157372 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 @@ -21,7 +21,7 @@ package org.onap.ccsdk.apps.ms.neng.core.gen; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyObject; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -35,7 +35,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister; import org.onap.ccsdk.apps.ms.neng.core.policy.FilePolicyReader; import org.onap.ccsdk.apps.ms.neng.core.policy.PolicyFinder; @@ -92,16 +92,16 @@ public class NameGeneratorSequenceMultiTest { Map<String, Object> policy = new FilePolicyReader("vnf_policy_seq.json").getPolicy(); Mockito.lenient().when(policyParams.getMaxGenAttempt()).thenReturn(100); Mockito.lenient().when(policyFinder.findPolicy(policyName)).thenReturn(policy); - Mockito.lenient().when(aaiValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(dbValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(dbValidator.validate(anyObject(), eq("abcde001ve1"))).thenReturn(false); - Mockito.lenient().when(dbValidator.validate(anyObject(), eq("abcde002ve1"))).thenReturn(false); - Mockito.lenient().when(dbValidator.validate(anyObject(), eq("abcde003ve1"))).thenReturn(false); - Mockito.lenient().when(dbValidator.validate(anyObject(), eq("abcde004ve1"))).thenReturn(true); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), eq(1))).thenReturn(1L); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), eq(2))).thenReturn(2L); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), eq(3))).thenReturn(3L); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), eq(4))).thenReturn(4L); + Mockito.lenient().when(aaiValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(dbValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(dbValidator.validate(any(), eq("abcde001ve1"))).thenReturn(false); + Mockito.lenient().when(dbValidator.validate(any(), eq("abcde002ve1"))).thenReturn(false); + Mockito.lenient().when(dbValidator.validate(any(), eq("abcde003ve1"))).thenReturn(false); + Mockito.lenient().when(dbValidator.validate(any(), eq("abcde004ve1"))).thenReturn(true); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), eq(1))).thenReturn(1L); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), eq(2))).thenReturn(2L); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), eq(3))).thenReturn(3L); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), eq(4))).thenReturn(4L); NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator, namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>()); 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 0f38d3fa..ce990b73 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 @@ -21,8 +21,8 @@ package org.onap.ccsdk.apps.ms.neng.core.gen; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyObject; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -35,7 +35,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister; import org.onap.ccsdk.apps.ms.neng.core.policy.FilePolicyReader; import org.onap.ccsdk.apps.ms.neng.core.policy.PolicyFinder; @@ -91,9 +91,9 @@ public class NameGeneratorSequenceTest { Map<String, Object> policy = new FilePolicyReader("vnf_policy_seq.json").getPolicy(); Mockito.lenient().when(policyFinder.findPolicy(policyName)).thenReturn(policy); - Mockito.lenient().when(aaiValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(dbValidator.validate(anyObject(), anyObject())).thenReturn(true); - Mockito.lenient().when(sequenceGenerator.generate(anyObject(), anyObject(), anyObject(), anyObject(), anyInt())).thenReturn(1L); + Mockito.lenient().when(aaiValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(dbValidator.validate(any(), any())).thenReturn(true); + Mockito.lenient().when(sequenceGenerator.generate(any(), any(), any(), any(), anyInt())).thenReturn(1L); NameGenerator gen = new NameGenerator(policyFinder, policyParams, sequenceGenerator, dbValidator, aaiValidator, namePresister, requestElement, allElements, earlierNames, policyCache, new ArrayList<>()); diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParametersImplTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParametersImplTest.java index e31a8868..be029122 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParametersImplTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParametersImplTest.java @@ -27,7 +27,7 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.persistence.entity.IdentifierMap; import org.onap.ccsdk.apps.ms.neng.persistence.entity.ServiceParameter; import org.onap.ccsdk.apps.ms.neng.persistence.repository.IdentifierMapRespository; diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequenceTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequenceTest.java index 9a0bbbd3..1df6d36b 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequenceTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequenceTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class PolicySequenceTest { 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 07d8c7af..f4e7824e 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 @@ -33,7 +33,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class PropertyOperatorTest { diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParserTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParserTest.java index 744d967d..b00641bf 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParserTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParserTest.java @@ -26,7 +26,7 @@ import static org.mockito.Mockito.mock; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class RecipeParserTest { diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/AaiAuthorizationInterceptorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/AaiAuthorizationInterceptorTest.java index 40e507ea..75a3e78e 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/AaiAuthorizationInterceptorTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/AaiAuthorizationInterceptorTest.java @@ -32,7 +32,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Spy; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigRequest; import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigResponse; import org.onap.ccsdk.apps.ms.neng.extinf.props.AaiProps; diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/PolicyManagerAuthorizationInterceptorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/PolicyManagerAuthorizationInterceptorTest.java index d814c253..3898e7b4 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/PolicyManagerAuthorizationInterceptorTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/PolicyManagerAuthorizationInterceptorTest.java @@ -32,7 +32,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Spy; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigRequest; import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigResponse; import org.onap.ccsdk.apps.ms.neng.extinf.props.PolicyManagerProps; diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/seq/SequenceGeneratorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/seq/SequenceGeneratorTest.java index 9aa4e3b7..51483472 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/seq/SequenceGeneratorTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/seq/SequenceGeneratorTest.java @@ -28,7 +28,7 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.core.policy.PolicySequence; import org.onap.ccsdk.apps.ms.neng.persistence.entity.ServiceParameter; import org.onap.ccsdk.apps.ms.neng.persistence.repository.GeneratedNameRespository; 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 61d68115..7882a221 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 @@ -39,7 +39,7 @@ import javax.ws.rs.core.Response; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; import org.onap.ccsdk.apps.ms.neng.core.exceptions.NengException; @@ -129,8 +129,8 @@ public class SpringServiceIntTest { public void testGenName_1() throws Exception { ResponseEntity<Object> resp = new ResponseEntity<Object>( getConfigResponse("JQINSRIOV.Config_MS_SriovBigJson.1.xml"), HttpStatus.OK); - Mockito.lenient().when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenReturn(resp); - Mockito.lenient().when(aaiServiceImpl.validate(Matchers.anyString(), Matchers.anyString())).thenReturn(true); + Mockito.lenient().when(restTemplate.exchange(ArgumentMatchers.any(RequestEntity.class), ArgumentMatchers.any(Class.class))).thenReturn(resp); + Mockito.lenient().when(aaiServiceImpl.validate(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(true); NameGenRequest request = nameGenRequest_1(); NameGenResponse genresp = springService.genNetworkElementName(request); assertTrue("vnf-name".equals(genresp.getElements().get(0).get("resource-name"))); @@ -180,8 +180,8 @@ public class SpringServiceIntTest { NameGenRequest request = nameGenRequest_1(); ResponseEntity<Object> resp = new ResponseEntity<Object>( getConfigResponse("JQINSRIOV.Config_MS_SriovBigJson.1.xml"), HttpStatus.OK); - Mockito.lenient().when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenReturn(resp); - Mockito.lenient().when(aaiServiceImpl.validate(Matchers.anyString(), Matchers.anyString())).thenReturn(true); + Mockito.lenient().when(restTemplate.exchange(ArgumentMatchers.any(RequestEntity.class), ArgumentMatchers.any(Class.class))).thenReturn(resp); + Mockito.lenient().when(aaiServiceImpl.validate(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(true); restServiceImpl.generateNetworkElementName(request); } @@ -262,7 +262,7 @@ public class SpringServiceIntTest { reqMap.put("resource-name", "vnf-name"); reqMap.put("resource-value", "DG001ESP1"); - Mockito.lenient().when(aaiServiceImpl.validate(Matchers.anyString(), Matchers.anyString())).thenReturn(true); + Mockito.lenient().when(aaiServiceImpl.validate(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(true); List<Map<String,String>> elList = new ArrayList<>(); elList.add(reqMap); 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 1e7e3baa..7a177a32 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,10 +30,10 @@ import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.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; @@ -192,7 +192,7 @@ public class SpringServiceTest { List<GeneratedName> generatedNameList = new ArrayList<>(); generatedNameList.add(gn); Mockito.lenient().when(namePersister.findByExternalIdAndElementType(req.get("external-key"), "VNF")).thenReturn(gn); - Mockito.lenient().when(aaiNameValidator.validate(Matchers.anyString(), Matchers.anyString())).thenReturn(true); + Mockito.lenient().when(aaiNameValidator.validate(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(true); Assert.assertNotNull(springserviceImpl.updateNetworkElementName(request)); Mockito.verify(namePersister, Mockito.times(1)).persist(gn); } 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 index 628156d6..c180b285 100644 --- 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 @@ -26,10 +26,10 @@ 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.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.persistence.repository.ExternalInterfaceRespository; import org.onap.ccsdk.apps.ms.neng.service.extinf.impl.AaiServiceImpl; @@ -46,7 +46,7 @@ public class AaiNameValidatorTest { @Test public void testValidate() throws Exception { - Mockito.lenient().when(dbStuff.getUriByNameType(Matchers.anyString())).thenReturn(null); + Mockito.lenient().when(dbStuff.getUriByNameType(ArgumentMatchers.anyString())).thenReturn(null); assertTrue(nameValidator.validate("VNF", "xyz112uyv")); } } diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/validator/ExternalKeyValidatorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/validator/ExternalKeyValidatorTest.java index 7c6c95f3..46576bc7 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/validator/ExternalKeyValidatorTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/validator/ExternalKeyValidatorTest.java @@ -24,7 +24,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.persistence.repository.GeneratedNameRespository; @RunWith(MockitoJUnitRunner.class) 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 e31c0987..8831118e 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 @@ -37,11 +37,11 @@ import java.util.Map; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.ccsdk.apps.ms.neng.core.exceptions.NengException; import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigRequest; import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigResponse; @@ -72,14 +72,14 @@ public class PolicyFinderServiceImplTest { @Test public void testConfig() throws Exception { doReturn(new GetConfigResponse()).when(policyFinder).makeOutboundCall( - Matchers.any(), Matchers.any(), Matchers.any()); + ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any()); assertNotNull(policyFinder.getConfig("policy")); } @Test public void testFindPolicy() throws Exception { doReturn(new GetConfigResponse()).when(policyFinder).makeOutboundCall( - Matchers.any(), Matchers.any(), Matchers.any()); + ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any()); assertNull(policyFinder.findPolicy("policy")); } @@ -96,7 +96,7 @@ public class PolicyFinderServiceImplTest { Map<String, Object> configMap = buildPolicyResponse(); Object resp = Arrays.asList(new Object[] {configMap}); ResponseEntity<Object> respEn = new ResponseEntity<>(resp, HttpStatus.OK); - Mockito.lenient().when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenReturn(respEn); + Mockito.lenient().when(restTemplate.exchange(ArgumentMatchers.any(RequestEntity.class), ArgumentMatchers.any(Class.class))).thenReturn(respEn); policManProps.setUrl("http://policyManager.onap.org"); @@ -112,7 +112,7 @@ public class PolicyFinderServiceImplTest { Map<String, Object> configMap = buildPolicyResponse(); Object resp = Arrays.asList(new Object[] {configMap}); ResponseEntity<Object> respEn = new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR); - Mockito.lenient().when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenReturn(respEn); + Mockito.lenient().when(restTemplate.exchange(ArgumentMatchers.any(RequestEntity.class), ArgumentMatchers.any(Class.class))).thenReturn(respEn); policManProps.setUrl("http://policyManager.onap.org"); @@ -224,7 +224,7 @@ public class PolicyFinderServiceImplTest { @Test(expected = NengException.class) public void testmakeOutboundCall_500_statusExp() throws Exception { HttpClientErrorException exp = new HttpClientErrorException(HttpStatus.METHOD_NOT_ALLOWED, "{error}"); - Mockito.lenient().when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenThrow(exp); + Mockito.lenient().when(restTemplate.exchange(ArgumentMatchers.any(RequestEntity.class), ArgumentMatchers.any(Class.class))).thenThrow(exp); policManProps.setUrl("http://policyManager.onap.org"); GetConfigRequest request = new GetConfigRequest(); request.setPolicyName("policy"); @@ -235,7 +235,7 @@ public class PolicyFinderServiceImplTest { @Test(expected = NengException.class) public void testmakeOutboundCall_500_statusExp_notFound() throws Exception { HttpClientErrorException exp = new HttpClientErrorException(HttpStatus.NOT_FOUND, "{error}"); - Mockito.lenient().when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenThrow(exp); + Mockito.lenient().when(restTemplate.exchange(ArgumentMatchers.any(RequestEntity.class), ArgumentMatchers.any(Class.class))).thenThrow(exp); policManProps.setUrl("http://policyManager.onap.org"); GetConfigRequest request = new GetConfigRequest(); request.setPolicyName("policy"); @@ -18,6 +18,7 @@ * limitations under the License. * ============LICENSE_END========================================================= --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> diff --git a/ms/sliboot/pom.xml b/ms/sliboot/pom.xml index dfecd1b5..fb46a823 100644 --- a/ms/sliboot/pom.xml +++ b/ms/sliboot/pom.xml @@ -187,6 +187,7 @@ <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> + <version>${gson.version}</version> </dependency> <dependency> <groupId>org.apache.derby</groupId> diff --git a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/controllers/ExecuteGraphController.java b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/controllers/ExecuteGraphController.java deleted file mode 100644 index 07191446..00000000 --- a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/controllers/ExecuteGraphController.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - CCSDK - * ================================================================================ - * Copyright (C) 2020 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.sliboot.controllers; - -import java.util.HashMap; -import java.util.Map.Entry; -import java.util.Properties; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -@Controller -@EnableAutoConfiguration -public class ExecuteGraphController { - @Autowired - protected SvcLogicServiceBase svc; - - @RequestMapping(value = "/executeGraph", method = RequestMethod.POST) - @ResponseBody - public HashMap<String, String> executeGraph(@RequestBody String input) { - HashMap<String, String> hash = new HashMap<String, String>(); - Properties parms = new Properties(); - - hash.put("status", "success"); - JsonObject jsonInput = new Gson().fromJson(input, JsonObject.class); - JsonObject passthroughObj = jsonInput.get("input").getAsJsonObject(); - - writeResponseToCtx(passthroughObj.toString(), parms, "input"); - - JsonObject inputObject = jsonInput.get("graphDetails").getAsJsonObject(); - try { - // Any of these can throw a nullpointer exception - String calledModule = inputObject.get("module").getAsString(); - String calledRpc = inputObject.get("rpc").getAsString(); - String modeStr = inputObject.get("mode").getAsString(); - // execute should only throw a SvcLogicException - Properties respProps = svc.execute(calledModule, calledRpc, null, modeStr, parms); - for (Entry<Object, Object> prop : respProps.entrySet()) { - hash.put((String) prop.getKey(), (String) prop.getValue()); - } - } catch (NullPointerException npe) { - HashMap<String, String> errorHash = new HashMap<String, String>(); - errorHash.put("error-message", "check that you populated module, rpc and or mode correctly."); - return errorHash; - } catch (SvcLogicException e) { - HashMap<String, String> errorHash = new HashMap<String, String>(); - errorHash.put("status", "failure"); - errorHash.put("message", e.getMessage()); - return errorHash; - } - return hash; - } - - public static void writeResponseToCtx(String resp, Properties ctx, String prefix) { - JsonParser jp = new JsonParser(); - JsonElement element = jp.parse(resp); - writeJsonObject(element.getAsJsonObject(), ctx, prefix + "."); - } - - public static void writeJsonObject(JsonObject obj, Properties ctx, String root) { - for (Entry<String, JsonElement> entry : obj.entrySet()) { - if (entry.getValue().isJsonObject()) { - writeJsonObject(entry.getValue().getAsJsonObject(), ctx, root + entry.getKey() + "."); - } else if (entry.getValue().isJsonArray()) { - JsonArray array = entry.getValue().getAsJsonArray(); - ctx.put(root + entry.getKey() + "_length", String.valueOf(array.size())); - Integer arrayIdx = 0; - for (JsonElement element : array) { - if (element.isJsonObject()) { - writeJsonObject(element.getAsJsonObject(), ctx, root + entry.getKey() + "[" + arrayIdx + "]."); - } - arrayIdx++; - } - } else { - ctx.put(root + entry.getKey(), entry.getValue().getAsString()); - } - } - } - - -} diff --git a/ms/sliboot/src/main/resources/application.properties b/ms/sliboot/src/main/resources/application.properties index d98aac30..5fae584e 100644 --- a/ms/sliboot/src/main/resources/application.properties +++ b/ms/sliboot/src/main/resources/application.properties @@ -25,3 +25,4 @@ spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.database=mysql +spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER diff --git a/ms/sliboot/src/test/resources/application.properties b/ms/sliboot/src/test/resources/application.properties index 58bf3cd8..507d98d9 100644 --- a/ms/sliboot/src/test/resources/application.properties +++ b/ms/sliboot/src/test/resources/application.properties @@ -15,4 +15,5 @@ spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl -spring.jpa.database=derby
\ No newline at end of file +spring.jpa.database=derby +spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER
\ No newline at end of file diff --git a/ms/vlantag-api/pom.xml b/ms/vlantag-api/pom.xml index 3b4af879..37b622ca 100644 --- a/ms/vlantag-api/pom.xml +++ b/ms/vlantag-api/pom.xml @@ -88,6 +88,11 @@ <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>${gson.version}</version> + </dependency> <dependency> <groupId>junit</groupId> |