diff options
Diffstat (limited to 'models-sim')
26 files changed, 210 insertions, 213 deletions
diff --git a/models-sim/models-sim-dmaap/pom.xml b/models-sim/models-sim-dmaap/pom.xml index 3ee3b32d0..2cfeadd3d 100644 --- a/models-sim/models-sim-dmaap/pom.xml +++ b/models-sim/models-sim-dmaap/pom.xml @@ -1,6 +1,6 @@ <!-- ============LICENSE_START======================================================= - Copyright (C) 2019,2023 Nordix Foundation. + Copyright (C) 2019, 2023 Nordix Foundation. Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.policy.models.sim</groupId> <artifactId>policy-models-sim</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <artifactId>policy-models-sim-dmaap</artifactId> @@ -35,10 +35,6 @@ <dependencies> <dependency> - <groupId>commons-cli</groupId> - <artifactId>commons-cli</artifactId> - </dependency> - <dependency> <groupId>org.onap.policy.common</groupId> <artifactId>common-parameters</artifactId> <version>${policy.common.version}</version> @@ -46,6 +42,7 @@ <dependency> <groupId>org.onap.policy.common</groupId> <artifactId>utils</artifactId> + <version>${policy.common.version}</version> </dependency> <dependency> <groupId>org.onap.policy.common</groupId> @@ -64,9 +61,8 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> + <groupId>commons-cli</groupId> + <artifactId>commons-cli</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java index 2119a6521..afbe10f51 100644 --- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java +++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ @@ -22,6 +22,8 @@ package org.onap.policy.models.sim.dmaap.provider; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; @@ -30,8 +32,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; import lombok.Getter; import lombok.Setter; import org.onap.policy.common.utils.services.ServiceManagerContainer; diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/BaseRestControllerV1.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/BaseRestControllerV1.java index 472a898c9..84b610a8f 100644 --- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/BaseRestControllerV1.java +++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/BaseRestControllerV1.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,11 @@ package org.onap.policy.models.sim.dmaap.rest; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.Response.ResponseBuilder; import java.net.HttpURLConnection; import java.util.UUID; -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Response.ResponseBuilder; /** * Version v1 common superclass to provide DMaaP endpoints for the DMaaP simulator component. diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandler.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandler.java index 64ea29dca..0efab160b 100644 --- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandler.java +++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandler.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,11 @@ package org.onap.policy.models.sim.dmaap.rest; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.ext.MessageBodyReader; +import jakarta.ws.rs.ext.Provider; import java.io.BufferedReader; import java.io.EOFException; import java.io.IOException; @@ -31,11 +37,6 @@ import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.util.LinkedList; import java.util.List; -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.Provider; import org.apache.commons.io.IOUtils; /** @@ -146,7 +147,7 @@ public class CambriaMessageBodyHandler implements MessageBodyReader<Object> { if (chr == '.') { String text = bldr.toString().trim(); - return (text.isEmpty() ? 0 : Integer.valueOf(text)); + return (text.isEmpty() ? 0 : Integer.parseInt(text)); } if (!Character.isDigit(chr)) { diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1.java index 17b7529f6..5ed04f1a3 100644 --- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1.java +++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019,2021 Nordix Foundation. + * Copyright (C) 2019, 2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ @@ -22,15 +22,15 @@ package org.onap.policy.models.sim.dmaap.rest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DefaultValue; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.Response; import org.onap.policy.models.sim.dmaap.provider.DmaapSimProvider; /** diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandler.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandler.java index c72b7482a..6d3bd730e 100644 --- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandler.java +++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandler.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,11 @@ package org.onap.policy.models.sim.dmaap.rest; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.ext.MessageBodyReader; +import jakarta.ws.rs.ext.Provider; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -29,11 +35,6 @@ import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.util.LinkedList; import java.util.List; -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.Provider; /** * Provider that decodes "text/plain" messages. diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProviderTest.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProviderTest.java index 3d72f2e4c..f82ef03f2 100644 --- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProviderTest.java +++ b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProviderTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +33,8 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -39,8 +42,6 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -104,7 +105,7 @@ public class DmaapSimProviderTest { } /** - * Verifies that the constructor adds all of the expected actions to the service + * Verifies that the constructor adds all the expected actions to the service * manager container. */ @Test @@ -202,7 +203,7 @@ public class DmaapSimProviderTest { public void testProcessDmaapMessageGet_Ex() throws InterruptedException { BlockingQueue<Response> respQueue = new LinkedBlockingQueue<>(); - // put in a background thread so it doesn't interrupt the tester thread + // put in a background thread, so it doesn't interrupt the tester thread new Thread(() -> { try { when(data1.read(any(), anyInt(), anyLong())).thenThrow(new InterruptedException(EXPECTED_EXCEPTION)); @@ -240,15 +241,15 @@ public class DmaapSimProviderTest { @Test public void testMakeTimerPool() { - // use a real provider so we can test the real makeTimer() method + // use a real provider, so we can test the real makeTimer() method DmaapSimProvider prov2 = new DmaapSimProvider(params); prov2.start(); - assertThatCode(() -> prov2.stop()).doesNotThrowAnyException(); + assertThatCode(prov2::stop).doesNotThrowAnyException(); } @Test public void testMakeTopicData() { - // use a real provider so we can test the real makeTopicData() method + // use a real provider, so we can test the real makeTopicData() method DmaapSimProvider prov2 = new DmaapSimProvider(params); assertThatCode(() -> prov2.processDmaapMessageGet(TOPIC1, CONSUMER1, CONSUMER_ID1, 0, 0)) .doesNotThrowAnyException(); @@ -277,14 +278,11 @@ public class DmaapSimProviderTest { @Override protected TopicData makeTopicData(String topicName) { - switch (topicName) { - case TOPIC1: - return data1; - case TOPIC2: - return data2; - default: - throw new IllegalArgumentException("unknown topic name: " + topicName); - } + return switch (topicName) { + case TOPIC1 -> data1; + case TOPIC2 -> data2; + default -> throw new IllegalArgumentException("unknown topic name: " + topicName); + }; } } } diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/BaseRestControllerV1Test.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/BaseRestControllerV1Test.java index 5cba78355..0d24436f7 100644 --- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/BaseRestControllerV1Test.java +++ b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/BaseRestControllerV1Test.java @@ -3,6 +3,7 @@ * ONAP PAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +24,9 @@ package org.onap.policy.models.sim.dmaap.rest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.ResponseBuilder; import java.util.UUID; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.ResponseBuilder; import org.junit.Before; import org.junit.Test; diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandlerTest.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandlerTest.java index 5d9186c75..ea2a4a530 100644 --- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandlerTest.java +++ b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/CambriaMessageBodyHandlerTest.java @@ -3,6 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,13 +26,13 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import jakarta.ws.rs.core.MediaType; import java.io.ByteArrayInputStream; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.List; -import javax.ws.rs.core.MediaType; import org.junit.Before; import org.junit.Test; diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1Test.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1Test.java index dd938d310..fd9397e34 100644 --- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1Test.java +++ b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1Test.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +23,10 @@ package org.onap.policy.models.sim.dmaap.rest; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; +import jakarta.ws.rs.core.Response; import java.io.File; import java.util.Arrays; import java.util.Map; -import javax.ws.rs.core.Response; import org.junit.Before; import org.junit.Test; import org.onap.policy.common.utils.coder.Coder; @@ -43,7 +44,7 @@ public class DmaapSimRestControllerV1Test { private static final String CONSUMER = "my-consumer"; private static final String CONSUMER_ID = "my-id"; - private static Coder coder = new StandardCoder(); + private static final Coder coder = new StandardCoder(); private DmaapSimRestControllerV1 rest; diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandlerTest.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandlerTest.java index 2dfbae980..50db94e5c 100644 --- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandlerTest.java +++ b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/TextMessageBodyHandlerTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,12 +23,12 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import jakarta.ws.rs.core.MediaType; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.List; -import javax.ws.rs.core.MediaType; import org.junit.Before; import org.junit.Test; diff --git a/models-sim/packages/models-simulator-docker/pom.xml b/models-sim/packages/models-simulator-docker/pom.xml index 773158ecc..4a7ba73d8 100644 --- a/models-sim/packages/models-simulator-docker/pom.xml +++ b/models-sim/packages/models-simulator-docker/pom.xml @@ -21,12 +21,12 @@ --> <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"> + 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> <parent> <groupId>org.onap.policy.models.sim</groupId> <artifactId>models-sim-packages</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <artifactId>models-simulator-docker</artifactId> @@ -46,7 +46,7 @@ <docker.push.registry>nexus3.onap.org:10003</docker.push.registry> <docker.contextDir>${project.basedir}/src/main/docker</docker.contextDir> <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format> - <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. --> + <!-- There is no code in this submodule, only holds interfaces. So skip sonar. --> <sonar.skip>true</sonar.skip> </properties> @@ -101,7 +101,8 @@ <dependencySets> <dependencySet> <includes> - <include>org.onap.policy.models.sim:models-simulator-tarball</include> + <include>org.onap.policy.models.sim:models-simulator-tarball + </include> </includes> <outputDirectory>/lib</outputDirectory> <outputFileNameMapping>models-simulator.tar.gz</outputFileNameMapping> diff --git a/models-sim/packages/models-simulator-docker/src/main/docker/Dockerfile b/models-sim/packages/models-simulator-docker/src/main/docker/Dockerfile index 724bfb346..b4d159f84 100644 --- a/models-sim/packages/models-simulator-docker/src/main/docker/Dockerfile +++ b/models-sim/packages/models-simulator-docker/src/main/docker/Dockerfile @@ -26,7 +26,7 @@ RUN mkdir /packages /extracted COPY /maven/lib/models-simulator.tar.gz /packages/ RUN tar xvzf /packages/models-simulator.tar.gz --directory /extracted/ -FROM onap/policy-jre-alpine:3.0.0-SNAPSHOT +FROM onap/policy-jre-alpine:3.0.1-SNAPSHOT LABEL maintainer="Policy Team" LABEL org.opencontainers.image.title="Policy Models Simulator" diff --git a/models-sim/packages/models-simulator-tarball/pom.xml b/models-sim/packages/models-simulator-tarball/pom.xml index c38978ec1..d2a73ed62 100644 --- a/models-sim/packages/models-simulator-tarball/pom.xml +++ b/models-sim/packages/models-simulator-tarball/pom.xml @@ -22,73 +22,73 @@ --> <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> - <parent> - <groupId>org.onap.policy.models.sim</groupId> - <artifactId>models-sim-packages</artifactId> - <version>3.0.0-SNAPSHOT</version> - </parent> + 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> + <parent> + <groupId>org.onap.policy.models.sim</groupId> + <artifactId>models-sim-packages</artifactId> + <version>3.0.1-SNAPSHOT</version> + </parent> - <artifactId>models-simulator-tarball</artifactId> + <artifactId>models-simulator-tarball</artifactId> - <name>${project.artifactId}</name> - <description>A module that runs all "simulators", including DMaaP.</description> + <name>${project.artifactId}</name> + <description>A module that runs all "simulators", including DMaaP.</description> - <properties> - <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. --> - <sonar.skip>true</sonar.skip> - </properties> + <properties> + <!-- There is no code in this submodule, only holds interfaces. So skip sonar. --> + <sonar.skip>true</sonar.skip> + </properties> - <dependencies> - <dependency> - <groupId>org.onap.policy.models.sim</groupId> - <artifactId>policy-models-simulators</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> + <dependencies> + <dependency> + <groupId>org.onap.policy.models.sim</groupId> + <artifactId>policy-models-simulators</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> - <build> - <resources> - <!-- Output the version of the service --> - <resource> - <directory>src/main/resources</directory> - <filtering>true</filtering> - <includes> - <include>**/version.txt</include> - </includes> - </resource> - <resource> - <directory>src/main/resources</directory> - <filtering>false</filtering> - <excludes> - <exclude>**/version.txt</exclude> - </excludes> - </resource> - </resources> + <build> + <resources> + <!-- Output the version of the service --> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <includes> + <include>**/version.txt</include> + </includes> + </resource> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <excludes> + <exclude>**/version.txt</exclude> + </excludes> + </resource> + </resources> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-assembly-plugin</artifactId> - <executions> - <execution> - <id>generate-complete-tar</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - <configuration> - <descriptors> - <descriptor>src/main/assembly.xml</descriptor> - </descriptors> - <finalName>${project.artifactId}-${project.version}</finalName> - </configuration> - </execution> - </executions> - </plugin> - </plugins> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>generate-complete-tar</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <descriptors> + <descriptor>src/main/assembly.xml</descriptor> + </descriptors> + <finalName>${project.artifactId}-${project.version}</finalName> + </configuration> + </execution> + </executions> + </plugin> + </plugins> - </build> + </build> </project> diff --git a/models-sim/packages/pom.xml b/models-sim/packages/pom.xml index c0ffeada6..9b3e5c36f 100644 --- a/models-sim/packages/pom.xml +++ b/models-sim/packages/pom.xml @@ -20,12 +20,12 @@ --> <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"> + 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> <parent> <groupId>org.onap.policy.models.sim</groupId> <artifactId>policy-models-sim</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <artifactId>models-sim-packages</artifactId> @@ -35,7 +35,7 @@ <description>The module for packaging the policy-models-simulator component.</description> <properties> - <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. --> + <!-- There is no code in this submodule, only holds interfaces. So skip sonar. --> <sonar.skip>true</sonar.skip> </properties> diff --git a/models-sim/policy-models-sim-pdp/pom.xml b/models-sim/policy-models-sim-pdp/pom.xml index cf89b12eb..326a76a30 100644 --- a/models-sim/policy-models-sim-pdp/pom.xml +++ b/models-sim/policy-models-sim-pdp/pom.xml @@ -1,17 +1,38 @@ -<?xml version="1.0"?> -<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.policy.models.sim</groupId> - <artifactId>policy-models-sim</artifactId> - <version>3.0.0-SNAPSHOT</version> - </parent> - <artifactId>policy-models-sim-pdp</artifactId> - <name>policy-models-sim-pdp</name> +<!-- + ============LICENSE_START======================================================= + Copyright (C) 2019 Bell Canada. All rights reserved. + Modifications Copyright (C) 2023 Nordix Foundation. + ================================================================================ + 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 -<description>A module that implements a simulator for PDP.</description> - <dependencies> + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= +--> + +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.policy.models.sim</groupId> + <artifactId>policy-models-sim</artifactId> + <version>3.0.1-SNAPSHOT</version> + </parent> + <artifactId>policy-models-sim-pdp</artifactId> + <name>policy-models-sim-pdp</name> + + <description>A module that implements a simulator for PDP.</description> + <dependencies> <dependency> <groupId>org.onap.policy.models</groupId> <artifactId>policy-models-pdp</artifactId> @@ -37,23 +58,6 @@ <artifactId>common-parameters</artifactId> <version>${policy.common.version}</version> </dependency> - - <!--test dependencies --> - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> </dependencies> <build> <resources> diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java index 1bc2ff72d..31d5b4120 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorActivator.java @@ -52,8 +52,8 @@ public class PdpSimulatorActivator { private static final Logger LOGGER = LoggerFactory.getLogger(PdpSimulatorActivator.class); private final PdpSimulatorParameterGroup pdpSimulatorParameterGroup; - private List<TopicSink> topicSinks; // topics to which pdp sends pdp status - private List<TopicSource> topicSources; // topics to which pdp listens to for messages from pap. + private final List<TopicSink> topicSinks; // topics to which pdp sends pdp status + private final List<TopicSource> topicSources; // topics to which pdp listens to for messages from pap. private static final String[] MSG_TYPE_NAMES = { "messageName" }; /* @@ -70,7 +70,7 @@ public class PdpSimulatorActivator { /** * Used to manage the services. */ - private ServiceManager manager; + private final ServiceManager manager; @Getter diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java index 1441ba37f..88d1b2686 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -132,7 +132,7 @@ public class PdpSimulatorMain { activator.terminate(); } } catch (final PdpSimulatorException e) { - LOGGER.warn("error occured during shut down of the pdp simulator service", e); + LOGGER.warn("error occurred during shut down of the pdp simulator service", e); } } } diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java index 6be59b100..69b25dddd 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,10 +41,10 @@ public class PdpStatusPublisher extends TimerTask { private static final Logger LOGGER = LoggerFactory.getLogger(PdpStatusPublisher.class); - private TopicSinkClient topicSinkClient; - private Timer timer; + private final TopicSinkClient topicSinkClient; + private final Timer timer; @Getter - private long interval; + private final long interval; /** * Constructor for instantiating PdpStatusPublisher. diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java index ae028dd32..ad1a32d7b 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpMessageHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -101,8 +101,8 @@ public class PdpMessageHandler { * * @return PdpResponseDetails */ - public PdpResponseDetails createPdpResonseDetails(final String requestId, final PdpResponseStatus status, - final String responseMessage) { + public PdpResponseDetails createPdpResponseDetails(final String requestId, final PdpResponseStatus status, + final String responseMessage) { final var pdpResponseDetails = new PdpResponseDetails(); pdpResponseDetails.setResponseTo(requestId); pdpResponseDetails.setResponseStatus(status); diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java index 4f9804f7e..23df912e2 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpStateChangeMessageHandler.java @@ -81,16 +81,16 @@ public class PdpStateChangeMessageHandler { final PdpStatus pdpStatusContext, final PdpMessageHandler pdpMessageHandler) { PdpResponseDetails pdpResponseDetails = null; if (pdpStatusContext.getState().equals(PdpState.ACTIVE)) { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp already in active state"); } else { final List<ToscaPolicy> policies = Registry.get(PdpSimulatorConstants.REG_PDP_TOSCA_POLICY_LIST); if (policies.isEmpty()) { pdpStatusContext.setState(PdpState.ACTIVE); - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "State changed to active. No policies found."); } else { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp started. State changed to active."); pdpStatusContext.setState(PdpState.ACTIVE); } @@ -110,10 +110,10 @@ public class PdpStateChangeMessageHandler { final PdpStatus pdpStatusContext, final PdpMessageHandler pdpMessageHandler) { PdpResponseDetails pdpResponseDetails = null; if (pdpStatusContext.getState().equals(PdpState.PASSIVE)) { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp already in passive state"); } else { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpStateChangeMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp state changed from Active to Passive."); pdpStatusContext.setState(PdpState.PASSIVE); } diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java index a90f74fba..60f7c1461 100644 --- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java +++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/handler/PdpUpdateMessageHandler.java @@ -56,7 +56,7 @@ public class PdpUpdateMessageHandler { final var pdpStatusPublisher = Registry.get(PdpSimulatorConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class); if (checkIfAlreadyHandled(pdpUpdateMsg, pdpStatusContext)) { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpUpdateMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp already updated"); } else { if (null != pdpUpdateMsg.getPdpHeartbeatIntervalMs() && pdpUpdateMsg.getPdpHeartbeatIntervalMs() > 0 @@ -74,12 +74,12 @@ public class PdpUpdateMessageHandler { .collect(Collectors.toList())); if (pdpStatusContext.getState().equals(PdpState.ACTIVE) && !pdpUpdateMsg.getPoliciesToBeDeployed().isEmpty()) { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpUpdateMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp engine started and policies are running."); } Registry.registerOrReplace(PdpSimulatorConstants.REG_PDP_TOSCA_POLICY_LIST, policies); if (null == pdpResponseDetails) { - pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(), + pdpResponseDetails = pdpMessageHandler.createPdpResponseDetails(pdpUpdateMsg.getRequestId(), PdpResponseStatus.SUCCESS, "Pdp update successful."); } } diff --git a/models-sim/policy-models-sim-pdp/src/main/package/docker/Dockerfile b/models-sim/policy-models-sim-pdp/src/main/package/docker/Dockerfile index d1a68ae30..d13fe8e35 100644 --- a/models-sim/policy-models-sim-pdp/src/main/package/docker/Dockerfile +++ b/models-sim/policy-models-sim-pdp/src/main/package/docker/Dockerfile @@ -23,7 +23,7 @@ # Docker file to build an image that runs the PDP simulator on Java 8 in alpine # -FROM onap/policy-jre-alpine:3.0.0-SNAPSHOT +FROM onap/policy-jre-alpine:3.0.1-SNAPSHOT LABEL maintainer="Policy Team" diff --git a/models-sim/policy-models-simulators/pom.xml b/models-sim/policy-models-simulators/pom.xml index a3895eeb0..d8b873979 100644 --- a/models-sim/policy-models-simulators/pom.xml +++ b/models-sim/policy-models-simulators/pom.xml @@ -22,13 +22,13 @@ --> <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"> + 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> <parent> <groupId>org.onap.policy.models.sim</groupId> <artifactId>policy-models-sim</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <artifactId>policy-models-simulators</artifactId> @@ -42,15 +42,5 @@ <artifactId>simulators</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> </dependencies> </project> diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java index e1517f3a8..6326b704b 100644 --- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java +++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +31,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import jakarta.ws.rs.core.Response; import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashMap; @@ -39,7 +41,6 @@ import java.util.Map.Entry; import java.util.Properties; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; -import javax.ws.rs.core.Response; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; diff --git a/models-sim/pom.xml b/models-sim/pom.xml index b5da2b10b..98a6a3765 100644 --- a/models-sim/pom.xml +++ b/models-sim/pom.xml @@ -20,27 +20,28 @@ ============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> - <parent> - <groupId>org.onap.policy.models</groupId> - <artifactId>policy-models</artifactId> - <version>3.0.0-SNAPSHOT</version> - </parent> +<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> + <parent> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models</artifactId> + <version>3.0.1-SNAPSHOT</version> + </parent> - <groupId>org.onap.policy.models.sim</groupId> - <artifactId>policy-models-sim</artifactId> - <packaging>pom</packaging> - <name>${project.artifactId}</name> + <groupId>org.onap.policy.models.sim</groupId> + <artifactId>policy-models-sim</artifactId> + <packaging>pom</packaging> + <name>${project.artifactId}</name> - <properties> - <jacoco.dataFile>${project.basedir}/../../target/code-coverage/jacoco-ut.exec</jacoco.dataFile> - </properties> + <properties> + <jacoco.dataFile>${project.basedir}/../../target/code-coverage/jacoco-ut.exec</jacoco.dataFile> + </properties> - <modules> - <module>models-sim-dmaap</module> - <module>policy-models-sim-pdp</module> - <module>policy-models-simulators</module> - <module>packages</module> - </modules> + <modules> + <module>models-sim-dmaap</module> + <module>policy-models-sim-pdp</module> + <module>policy-models-simulators</module> + <module>packages</module> + </modules> </project> |