diff options
Diffstat (limited to 'models-interactions/model-simulators/src')
13 files changed, 78 insertions, 72 deletions
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java index ea50240ba..146dcec4a 100644 --- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java +++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java @@ -3,7 +3,7 @@ * simulators * ================================================================================ * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019, 2023 Nordix Foundation. * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,16 +22,15 @@ package org.onap.policy.simulators; -import java.io.IOException; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -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.MediaType; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.PUT; +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.MediaType; +import jakarta.ws.rs.core.Response; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.common.utils.services.Registry; @@ -71,13 +70,12 @@ public class AaiSimulatorJaxRs { * * @param req the request * @return the response - * @throws IOException if a response file cannot be read */ @PUT @Path("/{version:v16|v21}/query") @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") - public Response aaiPutQuery(final String req) throws IOException { + public Response aaiPutQuery(final String req) { return getResponse("AaiCqResponse", "invalid-cq"); } @@ -85,13 +83,12 @@ public class AaiSimulatorJaxRs { * A&AI get PNF query using pnfName. * * @return the result - * @throws IOException if a response file cannot be read */ @GET @Path("/{version:v16|v21}/network/pnfs/pnf/{pnfName}") @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") - public Response aaiGetPnfUsingPnfName(@PathParam("pnfName") final String pnfName) throws IOException { + public Response aaiGetPnfUsingPnfName(@PathParam("pnfName") final String pnfName) { return getResponse(pnfName, INVALID_PNF_FILE_NAME); } @@ -99,13 +96,12 @@ public class AaiSimulatorJaxRs { * A&AI get PNF query using pnf-id. * * @return the result - * @throws IOException if a response file cannot be read */ @GET @Path("/{version:v16|v21}/network/pnfs/pnf") @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") - public Response aaiGetPnfUsingPnfId(@QueryParam("pnf-id") final String pnfId) throws IOException { + public Response aaiGetPnfUsingPnfId(@QueryParam("pnf-id") final String pnfId) { return getResponse(pnfId, INVALID_PNF_FILE_NAME); } @@ -113,13 +109,12 @@ public class AaiSimulatorJaxRs { * A&AI get VNF query using vnf-id. * * @return the result - * @throws IOException if a response file cannot be read */ @GET @Path("/{version:v16|v21}/network/generic-vnfs/generic-vnf/{vnfId}") @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") - public Response aaiGetVnfUsingVnfId(@PathParam("vnfId") final String vnfId) throws IOException { + public Response aaiGetVnfUsingVnfId(@PathParam("vnfId") final String vnfId) { return getResponse(vnfId, INVALID_VNF_FILE_NAME); } @@ -127,13 +122,12 @@ public class AaiSimulatorJaxRs { * A&AI get VNF query using vnf-name. * * @return the result - * @throws IOException if a response file cannot be read */ @GET @Path("/{version:v16|v21}/network/generic-vnfs/generic-vnf") @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") - public Response aaiGetVnfUsingVnfName(@QueryParam("vnf-name") final String vnfName) throws IOException { + public Response aaiGetVnfUsingVnfName(@QueryParam("vnf-name") final String vnfName) { return getResponse(vnfName, INVALID_VNF_FILE_NAME); } diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java index 7a28791ba..20e1811db 100644 --- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java +++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SdncSimulatorJaxRs.java @@ -3,7 +3,7 @@ * simulators * ================================================================================ * Copyright (C) 2018 Huawei. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications 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"); @@ -22,12 +22,12 @@ package org.onap.policy.simulators; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import java.util.UUID; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import org.onap.policy.sdnc.SdncResponse; import org.onap.policy.sdnc.SdncResponseOutput; import org.onap.policy.sdnc.util.Serialization; diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SimulatorRuntimeException.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SimulatorRuntimeException.java index b97e4d9f7..ed2b0fd69 100644 --- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SimulatorRuntimeException.java +++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SimulatorRuntimeException.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 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,7 +21,10 @@ package org.onap.policy.simulators; +import java.io.Serial; + public class SimulatorRuntimeException extends RuntimeException { + @Serial private static final long serialVersionUID = 1L; public SimulatorRuntimeException() { diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java index 957541993..a1456c15e 100644 --- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java +++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java @@ -3,7 +3,7 @@ * simulators * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019, 2023 Nordix Foundation. * Modifications Copyright (C) 2020 Wipro Limited. * Modifications Copyright (C) 2022 CTC, Inc. and others. * ================================================================================ @@ -23,20 +23,20 @@ package org.onap.policy.simulators; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.PUT; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import lombok.Setter; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.so.SoRequest; @@ -67,8 +67,8 @@ public class SoSimulatorJaxRs { /** * SO post query. * - * @param serviceInstanceId the service instance Id - * @param vnfInstanceId the VNF Id + * @param serviceInstanceId the service instance ID + * @param vnfInstanceId the VNF ID * @return the response */ @POST @@ -91,8 +91,8 @@ public class SoSimulatorJaxRs { /** * SO Delete. * - * @param serviceInstanceId the service instance Id - * @param vnfInstanceId the VNF Id + * @param serviceInstanceId the service instance ID + * @param vnfInstanceId the VNF ID * @return the response */ @DELETE diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java index 155107bbd..bbe1a3604 100644 --- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java +++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/Util.java @@ -3,7 +3,7 @@ * simulators * ================================================================================ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications 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. @@ -101,7 +101,7 @@ public final class Util { /** - * Build an SO simulator. + * Build a SO simulator. * * @return the simulator * @throws InterruptedException if a thread is interrupted @@ -174,7 +174,7 @@ public final class Util { */ public static HttpServletServer buildDmaapSim(String resourceName) throws InterruptedException { var json = ResourceUtils.getResourceAsString(resourceName); - DmaapSimParameterGroup params = null; + DmaapSimParameterGroup params; try { params = new StandardCoder().decode(json, DmaapSimParameterGroup.class); } catch (CoderException ce) { diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java index 3702fdd6d..7f1b6ddea 100644 --- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java +++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java @@ -3,7 +3,7 @@ * simulators * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications 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. @@ -21,15 +21,15 @@ package org.onap.policy.simulators; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.Consumes; -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.core.Context; -import javax.ws.rs.core.MediaType; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.ws.rs.Consumes; +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.core.Context; +import jakarta.ws.rs.core.MediaType; import org.slf4j.LoggerFactory; @Path("/api/nslcm/v1") @@ -63,7 +63,7 @@ public class VfcSimulatorJaxRs { /** * VFC get query. * - * @param jobId tthe job id + * @param jobId the job id * @return the response */ @GET @@ -74,9 +74,9 @@ public class VfcSimulatorJaxRs { return "{\"jobId\" : " + jobId + ",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"finished\",\"statusDescription" + "\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": 101 ,\"" - + "responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription" + + "responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"processing\",\"statusDescription" + "\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\"" - + "progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are " + + "progress\" : \"41\",\"status\" : \"processing\",\"statusDescription\" : \"OMC VMs are " + "decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}"; } diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/XacmlSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/XacmlSimulatorJaxRs.java index 36964210b..c19f53807 100644 --- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/XacmlSimulatorJaxRs.java +++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/XacmlSimulatorJaxRs.java @@ -3,7 +3,7 @@ * simulators * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications 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. @@ -21,15 +21,15 @@ package org.onap.policy.simulators; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.function.Function; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java index d5d93e07f..a730d977d 100644 --- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java +++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java @@ -42,7 +42,8 @@ public class AaiSimulatorTest { @BeforeClass public static void setUpSimulator() { try { - Util.buildAaiSim(); + var testServer = Util.buildAaiSim(); + assertNotNull(testServer); } catch (final Exception e) { fail(e.getMessage()); } diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java index 6c71940af..57707693c 100644 --- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java +++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020-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. @@ -31,6 +32,7 @@ import io.grpc.netty.NettyChannelBuilder; import io.grpc.stub.StreamObserver; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.util.Objects; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -71,7 +73,8 @@ public class CdsSimulatorTest { @Test public void test() throws Exception { - String reqstr = IOUtils.toString(getClass().getResource("cds/cds.request.json"), StandardCharsets.UTF_8); + String reqstr = IOUtils.toString(Objects.requireNonNull(getClass().getResource("cds/cds.request.json")), + StandardCharsets.UTF_8); Builder builder = ExecutionServiceInput.newBuilder(); JsonFormat.parser().ignoringUnknownFields().merge(reqstr, builder); ExecutionServiceInput request = builder.build(); @@ -83,7 +86,7 @@ public class CdsSimulatorTest { BluePrintProcessingServiceStub asyncStub = BluePrintProcessingServiceGrpc.newStub(channel); - StreamObserver<ExecutionServiceOutput> responseObserver = new StreamObserver<ExecutionServiceOutput>() { + StreamObserver<ExecutionServiceOutput> responseObserver = new StreamObserver<>() { @Override public void onNext(ExecutionServiceOutput output) { future.complete(output); diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java index 197c25f6c..97ecfc2ca 100644 --- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java +++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019, 2022 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2022 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. @@ -42,7 +43,7 @@ import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; import org.onap.policy.common.utils.coder.StandardCoder; public class DmaapSimulatorTest { - private static final int MAX_WAIT_SEC = 5; + private static final int MAX_WAIT_SEC = 10; private static final String TOPIC = "MY-TOPIC"; private static final String AUTH_TOPIC = "MY-AUTH-TOPIC"; private static final String AUTH_PORT = "3903"; diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java index 31b76270c..129f2841b 100644 --- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java +++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java @@ -57,7 +57,8 @@ public class SoSimulatorTest { @BeforeClass public static void setUpSimulator() { try { - Util.buildSoSim(); + var testServer = Util.buildSoSim(); + assertNotNull(testServer); } catch (final Exception e) { fail(e.getMessage()); } diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java index dc48e75a1..a290f56f3 100644 --- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java +++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java @@ -43,7 +43,8 @@ public class VfcSimulatorTest { @BeforeClass public static void setUpSimulator() { try { - Util.buildVfcSim(); + var testServer = Util.buildVfcSim(); + assertNotNull(testServer); } catch (final Exception e) { fail(e.getMessage()); } @@ -58,7 +59,7 @@ public class VfcSimulatorTest { public void testPost() { final Pair<Integer, String> httpDetails = new RestManager().post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username", "password", - new HashMap<String, String>(), "application/json", "Some Request Here"); + new HashMap<>(), "application/json", "Some Request Here"); assertNotNull(httpDetails); assertEquals(202, httpDetails.getLeft().intValue()); final VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.getRight(), VfcResponse.class); @@ -68,7 +69,7 @@ public class VfcSimulatorTest { @Test public void testGet() { final Pair<Integer, String> httpDetails = new RestManager().get("http://localhost:6668/api/nslcm/v1/jobs/1234", - "username", "password", new HashMap<String, String>()); + "username", "password", new HashMap<>()); assertNotNull(httpDetails); final VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.getRight(), VfcResponse.class); assertNotNull(response); diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/XacmlSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/XacmlSimulatorTest.java index e188edc77..417dcc9b3 100644 --- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/XacmlSimulatorTest.java +++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/XacmlSimulatorTest.java @@ -48,7 +48,8 @@ public class XacmlSimulatorTest { @BeforeClass public static void setupSimulator() { try { - org.onap.policy.simulators.Util.buildXacmlSim(); + var testServer = Util.buildXacmlSim(); + assertNotNull(testServer); } catch (Exception e) { fail(e.getMessage()); } |