From 865100d2bbaafac77f1d9e637bca81adc03c4c44 Mon Sep 17 00:00:00 2001 From: "adheli.tavares" Date: Thu, 28 Sep 2023 18:26:22 +0100 Subject: Fix nexus and sonar vulnerabilities - IQ nexus dependencies - sonar hotspots and code smells Issue-ID: POLICY-4760 Change-Id: Ic4260c568f9d9164a33aacb34a5ff3a6f91b1bd8 Signed-off-by: adheli.tavares --- .../controlloop/actor/appc/AppcOperation.java | 24 ++++++++-------------- .../actor/appc/ModifyConfigOperation.java | 3 ++- .../controlloop/actor/appc/AppcOperationTest.java | 16 +++++++-------- .../actor/appclcm/AppcLcmOperation.java | 18 +++++++--------- .../controlloop/actor/sdnr/SdnrOperation.java | 24 +++++++++------------- models-interactions/model-impl/aai/pom.xml | 2 +- models-interactions/model-impl/cds/pom.xml | 2 +- .../AuthorativeToscaProviderNodeTemplateTest.java | 6 +++--- 8 files changed, 41 insertions(+), 54 deletions(-) diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java index b8ec634e3..ffdbde831 100644 --- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java +++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.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. @@ -74,11 +75,10 @@ public abstract class AppcOperation extends BidirectionalTopicOperation Status.SUCCESS; + case FAILURE -> Status.FAILURE; + case ERROR, REJECT -> throw new IllegalArgumentException("APP-C request was not accepted, code=" + code); + // awaiting a "final" response + default -> Status.STILL_WAITING; + }; } /** diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java index 524c797b6..0cf004935 100644 --- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java +++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.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. @@ -43,6 +44,6 @@ public class ModifyConfigOperation extends AppcOperation { @Override protected Request makeRequest(int attempt) { - return makeRequest(attempt, getRequiredProperty(OperationProperties.AAI_RESOURCE_VNF, "resource VNF")); + return makeRequest(getRequiredProperty(OperationProperties.AAI_RESOURCE_VNF, "resource VNF")); } } diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java index d40fa025d..b6e9b34e7 100644 --- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java +++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java @@ -90,7 +90,7 @@ public class AppcOperationTest extends BasicAppcOperation { String subreq = oper.getSubRequestId(); assertNotNull(subreq); - Request request = oper.makeRequest(2, genvnf); + Request request = oper.makeRequest(genvnf); assertEquals(DEFAULT_OPERATION, request.getAction()); assertNotNull(request.getPayload()); @@ -101,18 +101,18 @@ public class AppcOperationTest extends BasicAppcOperation { assertEquals(subreq, header.getSubRequestId()); - request = oper.makeRequest(2, genvnf); + request = oper.makeRequest(genvnf); assertEquals(subreq, request.getCommonHeader().getSubRequestId()); // repeat using a null payload params = params.toBuilder().payload(null).build(); oper = new MyOper(params, config); - assertEquals(Map.of(AppcOperation.VNF_ID_KEY, MY_VNF), oper.makeRequest(2, genvnf).getPayload()); + assertEquals(Map.of(AppcOperation.VNF_ID_KEY, MY_VNF), oper.makeRequest(genvnf).getPayload()); } @Test public void testConvertPayload() { - Request request = oper.makeRequest(2, genvnf); + Request request = oper.makeRequest(genvnf); // @formatter:off assertEquals( @@ -132,7 +132,7 @@ public class AppcOperationTest extends BasicAppcOperation { params = params.toBuilder().payload(payload).build(); oper = new MyOper(params, config); - request = oper.makeRequest(2, genvnf); + request = oper.makeRequest(genvnf); // @formatter:off assertEquals( @@ -153,7 +153,7 @@ public class AppcOperationTest extends BasicAppcOperation { params = params.toBuilder().payload(payload).build(); oper = new MyOper(params, config); - request = oper.makeRequest(2, genvnf); + request = oper.makeRequest(genvnf); payload.put(AppcOperation.VNF_ID_KEY, MY_VNF); payload.put(KEY1, "abc"); @@ -166,7 +166,7 @@ public class AppcOperationTest extends BasicAppcOperation { @Test public void testGetExpectedKeyValues() { oper.generateSubRequestId(2); - Request request = oper.makeRequest(2, genvnf); + Request request = oper.makeRequest(genvnf); assertEquals(Arrays.asList(request.getCommonHeader().getSubRequestId()), oper.getExpectedKeyValues(50, request)); } @@ -239,7 +239,7 @@ public class AppcOperationTest extends BasicAppcOperation { @Override protected Request makeRequest(int attempt) { - return makeRequest(attempt, genvnf); + return makeRequest(genvnf); } } } diff --git a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java index 5d256e8ae..4e8f59008 100644 --- a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java +++ b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.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. @@ -150,18 +151,13 @@ public class AppcLcmOperation extends BidirectionalTopicOperation Status.SUCCESS; + case AppcLcmResponseCode.FAILURE -> Status.FAILURE; + case AppcLcmResponseCode.ERROR, AppcLcmResponseCode.REJECT -> throw new IllegalArgumentException("APPC-LCM request was not accepted, code=" + code); - case AppcLcmResponseCode.ACCEPTED: - default: - return Status.STILL_WAITING; - } + default -> Status.STILL_WAITING; + }; } /** diff --git a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java index 5b30c673a..7e57bcccd 100644 --- a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java +++ b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java @@ -3,6 +3,7 @@ * SdnrOperation * ================================================================================ * 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. @@ -90,22 +91,17 @@ public class SdnrOperation extends BidirectionalTopicOperation Status.SUCCESS; + case FAILURE, PARTIAL_FAILURE -> Status.FAILURE; + case ERROR, REJECT -> { logger.warn("SDNR request was not accepted, code={}", code); - return Status.FAILURE; - case ACCEPTED: - default: + yield Status.FAILURE; + } + default -> // awaiting a "final" response - return Status.STILL_WAITING; - } + Status.STILL_WAITING; + }; } /** diff --git a/models-interactions/model-impl/aai/pom.xml b/models-interactions/model-impl/aai/pom.xml index cc9619a69..fd3707b35 100644 --- a/models-interactions/model-impl/aai/pom.xml +++ b/models-interactions/model-impl/aai/pom.xml @@ -52,7 +52,7 @@ org.onap.aai.schema-service aai-schema - 1.7.2 + 1.9.6 com.google.code.javaparser diff --git a/models-interactions/model-impl/cds/pom.xml b/models-interactions/model-impl/cds/pom.xml index d70265426..1bfdc7d7f 100644 --- a/models-interactions/model-impl/cds/pom.xml +++ b/models-interactions/model-impl/cds/pom.xml @@ -35,7 +35,7 @@ - 1.25.0 + 1.29.0 diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java index 64c164796..d47e194eb 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java @@ -63,8 +63,8 @@ public class AuthorativeToscaProviderNodeTemplateTest { private static ToscaServiceTemplate createToscaNodeTemplate; private PfDao pfDao; private StandardCoder standardCoder; - private AuthorativeToscaProvider authorativeToscaProvider = new AuthorativeToscaProvider(); - private YamlJsonTranslator yamlJsonTranslator = new YamlJsonTranslator(); + private final AuthorativeToscaProvider authorativeToscaProvider = new AuthorativeToscaProvider(); + private final YamlJsonTranslator yamlJsonTranslator = new YamlJsonTranslator(); /** * Read policy metadataSet input json. @@ -230,7 +230,7 @@ public class AuthorativeToscaProviderNodeTemplateTest { } @Test - public void testToscaNodeTemplatetDelete() throws Exception { + public void testToscaNodeTemplateDelete() throws Exception { assertThatThrownBy(() -> { authorativeToscaProvider.deleteToscaNodeTemplate(null, null, null); }).hasMessageMatching(DAO_IS_NULL); -- cgit 1.2.3-korg