Resolve IDE problems and warnings 10/143410/1
authorFiete Ostkamp <fiete.ostkamp@telekom.de>
Sun, 1 Mar 2026 09:34:45 +0000 (10:34 +0100)
committerFiete Ostkamp <fiete.ostkamp@telekom.de>
Sun, 1 Mar 2026 09:58:32 +0000 (10:58 +0100)
Issue-ID: SO-4252
Change-Id: I46c81ba904b013c95a6ab5bb0aa58fe006166eb6
Signed-off-by: Fiete Ostkamp <fiete.ostkamp@telekom.de>
24 files changed:
adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCServiceResponse.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV3ClientImpl.java
adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java
bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java
common/clients/clients-base/src/main/java/org/onap/so/client/CommonObjectMapperProvider.java
common/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java
common/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java
common/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java
graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java
graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java
graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java
mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java
mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java
mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java

index 842bcfc..92564bf 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -20,7 +20,6 @@
 
 package org.onap.so.adapters.sdncrest;
 
-import java.io.Serializable;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import javax.xml.bind.annotation.XmlElement;
@@ -43,7 +42,7 @@ import com.fasterxml.jackson.annotation.JsonRootName;
 @JsonRootName("SDNCServiceResponse")
 @JsonInclude(Include.NON_NULL)
 @XmlRootElement(name = "SDNCServiceResponse")
-public class SDNCServiceResponse extends SDNCResponseCommon implements Serializable {
+public class SDNCServiceResponse extends SDNCResponseCommon {
     private static final long serialVersionUID = 1L;
 
     // Map of response parameters (possibly none).
index a0c05b4..3d8ea8b 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -50,6 +50,7 @@ public class OpenstackV3ClientImpl extends OpenstackClientImpl {
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("rawtypes")
     protected OSClient getClient() {
         return client;
     }
index 8d02cc9..644bacb 100644 (file)
@@ -124,6 +124,7 @@ public class ApplicationControllerClient {
         }
     }
 
+    @SuppressWarnings("rawtypes")
     public Status vnfCommand(Action action, String requestId, String vnfId, Optional<String> vserverId,
             Optional<String> request, String controllerType, ApplicationControllerCallback listener, String requestorId)
             throws ApplicationControllerOrchestratorException {
@@ -148,6 +149,7 @@ public class ApplicationControllerClient {
     }
 
 
+    @SuppressWarnings("rawtypes")
     public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers,
             org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener,
             String requestorId) {
index 3f10df3..bd98750 100644 (file)
@@ -1056,10 +1056,10 @@ public class JsonUtils {
             return report.toString();
         } catch (IOException e) {
             logger.debug("IOException performing JSON schema validation on document:", e);
-            throw new ValidationException(e.getMessage());
+            throw new ValidationException(e.getMessage(), true);
         } catch (ProcessingException e) {
             logger.debug("ProcessingException performing JSON schema validation on document:", e);
-            throw new ValidationException(e.getMessage());
+            throw new ValidationException(e.getMessage(), true);
         }
     }
 }
index 5dbe66c..29616e3 100644 (file)
@@ -24,7 +24,6 @@ import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.Provider;
 import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.MapperFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
 
@@ -37,7 +36,6 @@ public class CommonObjectMapperProvider implements ContextResolver<ObjectMapper>
 
         mapper = new ObjectMapper();
         mapper.setSerializationInclusion(Include.NON_NULL);
-        mapper.enable(MapperFeature.USE_ANNOTATIONS);
         mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
         mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
index 9a25d6f..a47b80f 100644 (file)
@@ -71,4 +71,12 @@ public class NssiAllocateRequest implements Serializable {
     public void setAllocateAnNssi(AllocateAnNssi allocateAnNssi) {
         this.allocateAnNssi = allocateAnNssi;
     }
+
+    public ServiceInfo getServiceInfo() {
+        return serviceInfo;
+    }
+
+    public void setServiceInfo(ServiceInfo serviceInfo) {
+        this.serviceInfo = serviceInfo;
+    }
 }
index cc6c9bb..bac041d 100644 (file)
 package org.onap.so.beans.nsmf;
 
 import java.io.Serializable;
-import java.util.HashMap;
 import java.util.Map;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@@ -47,4 +43,3 @@ public class ServiceProfile implements Serializable {
         this.serviceProfile = serviceProfile;
     }
 }
-
index 026db1e..91b05f4 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -25,8 +25,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
+
 
 @JsonRootName(value = "requestInfo")
 @JsonInclude(Include.NON_DEFAULT)
@@ -47,13 +46,13 @@ public class RequestInfo implements Serializable {
     protected String productFamilyName;
     @JsonProperty("orderVersion")
     protected Integer orderVersion;
-    @JsonSerialize(include = Inclusion.ALWAYS)
+    @JsonInclude(Include.ALWAYS)
     @JsonProperty("source")
     protected String source;
     @JsonProperty("instanceName")
     protected String instanceName;
     @JsonProperty("suppressRollback")
-    @JsonSerialize(include = Inclusion.ALWAYS)
+    @JsonInclude(Include.ALWAYS)
     protected boolean suppressRollback;
     @JsonProperty("requestorId")
     protected String requestorId;
@@ -194,7 +193,7 @@ public class RequestInfo implements Serializable {
 
     /**
      * Required for Marshalers to send the fields.
-     * 
+     *
      * @return
      */
     public boolean getSuppressRollback() {
index ddadb27..98b917c 100644 (file)
@@ -52,6 +52,6 @@ public class ServiceInstanceUri extends HttpLookupUri {
 
     @Override
     public URI buildNoNetwork() {
-        return super.build(new String[] {"NONE", "NONE", (String) this.values[0]});
+        return super.build("NONE", "NONE", (String) this.values[0]);
     }
 }
index 99a231a..6c17264 100644 (file)
@@ -46,7 +46,7 @@ public abstract class GraphInventoryClient {
 
     protected abstract RestClient createClient(URI uri);
 
-    public RestClient createClient(GraphInventoryUri uri) {
+    public RestClient createClient(GraphInventoryUri<?, ?> uri) {
         final URI result;
         if (uri instanceof HttpAwareUri) {
             result = ((HttpAwareUri) uri).locateAndBuild();
@@ -59,6 +59,7 @@ public abstract class GraphInventoryClient {
     }
 
 
+    @SuppressWarnings("unchecked")
     public <T extends RestProperties> T getRestProperties() {
         if (props == null) {
             throw new IllegalStateException("No RestProperty implementation found on classpath");
index 2814bd6..dd795f2 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.onap.aaiclient.client.aai;
 
+import static org.junit.Assert.assertThrows;
 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
 import static com.github.tomakehurst.wiremock.client.WireMock.get;
 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
@@ -36,7 +37,6 @@ import javax.ws.rs.core.Response.Status;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
 import org.mockito.InjectMocks;
 import org.mockito.Spy;
@@ -54,9 +54,6 @@ public class AAIResourcesClientWithServiceInstanceUriTest {
     @Rule
     public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
 
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
-
     @Spy
     public AAIClient client;
 
@@ -107,8 +104,7 @@ public class AAIResourcesClientWithServiceInstanceUriTest {
     @Test
     public void getWithException() {
         AAIResourcesClient client = aaiClient;
-        this.thrown.expect(IllegalArgumentException.class);
-        AAIResultWrapper result = client.get(uri, IllegalArgumentException.class);
+        assertThrows(IllegalArgumentException.class, () -> client.get(uri, IllegalArgumentException.class));
     }
 
     @Test
index 2b08d11..60356b9 100644 (file)
@@ -9,9 +9,9 @@
  * 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.
@@ -25,6 +25,7 @@ package org.onap.so.apihandler.common;
 
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import javax.xml.XMLConstants;
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
@@ -60,7 +61,7 @@ public class XMLValidator {
 
         try (FileInputStream xsdStream = new FileInputStream(XSDS_PATH + xsdFile)) {
 
-            stringXsd = IOUtils.toString(xsdStream);
+            stringXsd = IOUtils.toString(xsdStream, StandardCharsets.UTF_8);
 
             factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
             factory.setResourceResolver(new PathResourceResolver(XSDS_PATH));
index 7c90052..5a79458 100644 (file)
@@ -109,16 +109,16 @@ public class ManualTasks {
             taskRequest = mapper.readValue(request, TasksRequest.class);
 
             if (taskRequest.getRequestDetails() == null) {
-                throw new ValidationException("requestDetails");
+                throw new ValidationException("requestDetails", true);
             }
             if (taskRequest.getRequestDetails().getRequestInfo() == null) {
-                throw new ValidationException("requestInfo");
+                throw new ValidationException("requestInfo", true);
             }
             if (empty(taskRequest.getRequestDetails().getRequestInfo().getSource())) {
-                throw new ValidationException("source");
+                throw new ValidationException("source", true);
             }
             if (empty(taskRequest.getRequestDetails().getRequestInfo().getRequestorId())) {
-                throw new ValidationException("requestorId");
+                throw new ValidationException("requestorId", true);
             }
 
         } catch (IOException e) {
index 6b50eec..69100a2 100644 (file)
@@ -23,7 +23,6 @@ package org.onap.so.apihandlerinfra;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
-import java.io.IOException;
 import java.sql.Timestamp;
 import java.util.HashMap;
 import java.util.List;
@@ -44,7 +43,6 @@ import javax.ws.rs.core.Response;
 import org.apache.http.HttpStatus;
 import org.onap.logging.filter.base.ErrorCode;
 import org.onap.so.apihandler.camundabeans.CamundaResponse;
-import org.onap.so.apihandler.common.CamundaClient;
 import org.onap.so.apihandler.common.ErrorNumbers;
 import org.onap.so.apihandler.common.RequestClientParameter;
 import org.onap.so.apihandler.common.ResponseBuilder;
@@ -76,6 +74,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Component;
 import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import io.swagger.v3.oas.annotations.OpenAPIDefinition;
 import io.swagger.v3.oas.annotations.Operation;
@@ -118,9 +117,6 @@ public class Onap3gppServiceInstances {
     @Autowired
     private ResponseBuilder builder;
 
-    @Autowired
-    private CamundaClient camundaClient;
-
     @Autowired
     private ResponseHandler responseHandler;
 
@@ -599,7 +595,7 @@ public class Onap3gppServiceInstances {
                 line = bufferedReader.readLine();
             }
             inputFileString = sb.toString();
-            subnetCapability = mapper.readValue(inputFileString, Map.class);
+            subnetCapability = mapper.readValue(inputFileString, new TypeReference<Map<String, Object>>() {});
         } catch (Exception e) {
             logger.debug("Exception while reading subnet capability value from json", e);
         }
index 6464aca..df51364 100644 (file)
@@ -49,8 +49,6 @@ import org.onap.so.apihandlerinfra.tasksbeans.TaskVariableValue;
 import org.onap.so.apihandlerinfra.tasksbeans.TaskVariables;
 import org.onap.so.apihandlerinfra.tasksbeans.TasksGetResponse;
 import org.onap.so.logger.MessageEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.ResponseEntity;
@@ -71,7 +69,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
 public class TasksHandler {
 
 
-    private static Logger logger = LoggerFactory.getLogger(TasksHandler.class);
     private static final ObjectMapper mapper = new ObjectMapper();
 
     @Value("${mso.camunda.rest.task.uri}")
index 61d31b3..b4e9ff6 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -20,9 +20,9 @@
 
 package org.onap.so.apihandlerinfra.tasksbeans;
 
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
 
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT)
+@JsonInclude(JsonInclude.Include.NON_DEFAULT)
 public class RequestInfo {
 
     protected String source;
index fab4251..0c8b94b 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -20,9 +20,9 @@
 
 package org.onap.so.apihandlerinfra.tasksbeans;
 
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonInclude;
 
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT)
+@JsonInclude(JsonInclude.Include.NON_DEFAULT)
 public class TaskVariableValue {
 
     protected String name;
index b30140c..badee84 100644 (file)
@@ -9,9 +9,9 @@
  * 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.
@@ -36,16 +36,12 @@ import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
 import org.onap.logging.filter.base.ErrorCode;
 import org.onap.so.logger.MessageEnum;
 import org.onap.so.requestsdb.RequestsDBHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 @Component
 public class DeactivateVnfOperationalEnvironment {
 
-    private static Logger logger = LoggerFactory.getLogger(DeactivateVnfOperationalEnvironment.class);
-
     @Autowired
     private AAIClientHelper aaiHelper;
     @Autowired
index 6ffd9dc..e5ecc75 100644 (file)
@@ -8,9 +8,9 @@
  * 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.
@@ -38,21 +38,21 @@ public class InPlaceSoftwareUpdateValidation implements ValidationRule {
         RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo();
 
         if (cloudConfiguration == null) {
-            throw new ValidationException("cloudConfiguration");
+            throw new ValidationException("cloudConfiguration", true);
         } else if (empty(cloudConfiguration.getLcpCloudRegionId())) {
-            throw new ValidationException("lcpCloudRegionId");
+            throw new ValidationException("lcpCloudRegionId", true);
         } else if (empty(cloudConfiguration.getTenantId())) {
-            throw new ValidationException("tenantId");
+            throw new ValidationException("tenantId", true);
         }
         if (requestInfo == null) {
-            throw new ValidationException("requestInfo");
+            throw new ValidationException("requestInfo", true);
         } else if (empty(requestInfo.getRequestorId())) {
-            throw new ValidationException("requestorId");
+            throw new ValidationException("requestorId", true);
         } else if (empty(requestInfo.getSource())) {
-            throw new ValidationException("source");
+            throw new ValidationException("source", true);
         }
         if (requestParameters == null) {
-            throw new ValidationException("requestParameters");
+            throw new ValidationException("requestParameters", true);
         }
         return info;
     }
index 55a68ff..6e84fcc 100644 (file)
@@ -8,9 +8,9 @@
  * 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.
@@ -45,42 +45,42 @@ public class InstanceIdMapValidation implements ValidationRule {
         if (instanceIdMap != null) {
             if (instanceIdMap.get(Service_InstanceId) != null) {
                 if (!UUIDChecker.isValidUUID(instanceIdMap.get(Service_InstanceId))) {
-                    throw new ValidationException(Service_InstanceId);
+                    throw new ValidationException(Service_InstanceId, true);
                 }
                 sir.setServiceInstanceId(instanceIdMap.get(Service_InstanceId));
             }
 
             if (instanceIdMap.get(Vnf_InstanceId) != null) {
                 if (!UUIDChecker.isValidUUID(instanceIdMap.get(Vnf_InstanceId))) {
-                    throw new ValidationException(Vnf_InstanceId);
+                    throw new ValidationException(Vnf_InstanceId, true);
                 }
                 sir.setVnfInstanceId(instanceIdMap.get(Vnf_InstanceId));
             }
 
             if (instanceIdMap.get(vfModule_InstanceId) != null) {
                 if (!UUIDChecker.isValidUUID(instanceIdMap.get(vfModule_InstanceId))) {
-                    throw new ValidationException(vfModule_InstanceId);
+                    throw new ValidationException(vfModule_InstanceId, true);
                 }
                 sir.setVfModuleInstanceId(instanceIdMap.get(vfModule_InstanceId));
             }
 
             if (instanceIdMap.get(volume_Group_InstanceId) != null) {
                 if (!UUIDChecker.isValidUUID(instanceIdMap.get(volume_Group_InstanceId))) {
-                    throw new ValidationException(volume_Group_InstanceId);
+                    throw new ValidationException(volume_Group_InstanceId, true);
                 }
                 sir.setVolumeGroupInstanceId(instanceIdMap.get(volume_Group_InstanceId));
             }
 
             if (instanceIdMap.get(Network_Instance_Id) != null) {
                 if (!UUIDChecker.isValidUUID(instanceIdMap.get(Network_Instance_Id))) {
-                    throw new ValidationException(Network_Instance_Id);
+                    throw new ValidationException(Network_Instance_Id, true);
                 }
                 sir.setNetworkInstanceId(instanceIdMap.get(Network_Instance_Id));
             }
 
             if (instanceIdMap.get(Configuration_Instance_Id) != null) {
                 if (!UUIDChecker.isValidUUID(instanceIdMap.get(Configuration_Instance_Id))) {
-                    throw new ValidationException(Configuration_Instance_Id);
+                    throw new ValidationException(Configuration_Instance_Id, true);
                 }
                 sir.setConfigurationId(instanceIdMap.get(Configuration_Instance_Id));
             }
index ef160e9..9bbe4b4 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
 package org.onap.so.apihandlerinfra.validation;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.HashMap;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.onap.so.apihandlerinfra.Action;
 import org.onap.so.apihandlerinfra.BaseTest;
 import org.onap.so.exceptions.ValidationException;
@@ -40,9 +40,6 @@ public class RelatedInstancesValidationTest extends BaseTest {
 
     RelatedInstancesValidation validation = new RelatedInstancesValidation();
 
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
-
     public ValidationInformation setupValidationInformation(String path) throws IOException {
         String jsonInput = new String(Files.readAllBytes(Paths.get(path)));
         ObjectMapper mapper = new ObjectMapper();
@@ -96,43 +93,43 @@ public class RelatedInstancesValidationTest extends BaseTest {
     }
 
     @Test
-    public void validateModelTypeExceptionTest() throws IOException, ValidationException {
-        thrown.expect(ValidationException.class);
-        thrown.expectMessage("No valid modelType in relatedInstance is specified");
-        validation.validate(
-                setupValidationInformation("src/test/resources/Validation/VpnBondingValidation/NoModelType.json"));
+    public void validateModelTypeExceptionTest() throws IOException {
+        ValidationException e = assertThrows(ValidationException.class, () -> validation.validate(
+                setupValidationInformation("src/test/resources/Validation/VpnBondingValidation/NoModelType.json")));
+        assertTrue(e.getMessage().contains("No valid modelType in relatedInstance is specified"));
     }
 
     @Test
-    public void validateInstanceNameVpnBindingExceptionTest() throws IOException, ValidationException {
-        thrown.expect(ValidationException.class);
-        thrown.expectMessage("No valid instanceName in relatedInstance for vpnBinding modelType is specified");
-        validation.validate(setupValidationInformation(
-                "src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json"));
+    public void validateInstanceNameVpnBindingExceptionTest() throws IOException {
+        ValidationException e =
+                assertThrows(ValidationException.class, () -> validation.validate(setupValidationInformation(
+                        "src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json")));
+        assertTrue(e.getMessage()
+                .contains("No valid instanceName in relatedInstance for vpnBinding modelType is specified"));
     }
 
     @Test
-    public void validateInstanceNameNetworkExceptionTest() throws IOException, ValidationException {
-        thrown.expect(ValidationException.class);
-        thrown.expectMessage("No valid instanceName in relatedInstance for network modelType is specified");
-        validation.validate(setupValidationInformation(
-                "src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json"));
+    public void validateInstanceNameNetworkExceptionTest() throws IOException {
+        ValidationException e =
+                assertThrows(ValidationException.class, () -> validation.validate(setupValidationInformation(
+                        "src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json")));
+        assertTrue(
+                e.getMessage().contains("No valid instanceName in relatedInstance for network modelType is specified"));
     }
 
     @Test
-    public void validateInstanceIdExceptionTest() throws IOException, ValidationException {
-        thrown.expect(ValidationException.class);
-        thrown.expectMessage("No valid instanceId in relatedInstance is specified");
-        validation.validate(
-                setupValidationInformation("src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json"));
+    public void validateInstanceIdExceptionTest() throws IOException {
+        ValidationException e = assertThrows(ValidationException.class, () -> validation.validate(
+                setupValidationInformation("src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json")));
+        assertTrue(e.getMessage().contains("No valid instanceId in relatedInstance is specified"));
     }
 
     @Test
-    public void validatemodelInvariantIdExceptionTest() throws IOException, ValidationException {
-        thrown.expect(ValidationException.class);
-        thrown.expectMessage("No valid modelInvariantId in relatedInstance is specified");
-        validation.validate(setupValidationInformation(
-                "src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json"));
+    public void validatemodelInvariantIdExceptionTest() throws IOException {
+        ValidationException e =
+                assertThrows(ValidationException.class, () -> validation.validate(setupValidationInformation(
+                        "src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json")));
+        assertTrue(e.getMessage().contains("No valid modelInvariantId in relatedInstance is specified"));
     }
 
     @Test
@@ -142,13 +139,14 @@ public class RelatedInstancesValidationTest extends BaseTest {
     }
 
     @Test
-    public void validateRelatedInstanceInstanceIdExceptionTest() throws IOException, ValidationException {
-        thrown.expect(ValidationException.class);
-        thrown.expectMessage("serviceInstanceId matching the serviceInstanceId in request URI");
-        ValidationInformation info = setupValidationInformation(
-                "src/test/resources/Validation/UserParamsValidation/RelatedInstanceInstanceId.json");
-        RelatedInstanceList[] instanceList = info.sir.getRequestDetails().getRelatedInstanceList();
-        instanceList[0].getRelatedInstance().setInstanceDirection(InstanceDirection.fromValue("destination"));
-        validation.validate(info);
+    public void validateRelatedInstanceInstanceIdExceptionTest() throws IOException {
+        ValidationException e = assertThrows(ValidationException.class, () -> {
+            ValidationInformation info = setupValidationInformation(
+                    "src/test/resources/Validation/UserParamsValidation/RelatedInstanceInstanceId.json");
+            RelatedInstanceList[] instanceList = info.sir.getRequestDetails().getRelatedInstanceList();
+            instanceList[0].getRelatedInstance().setInstanceDirection(InstanceDirection.fromValue("destination"));
+            validation.validate(info);
+        });
+        assertTrue(e.getMessage().contains("serviceInstanceId matching the serviceInstanceId in request URI"));
     }
 }
index 806d347..baa11dc 100644 (file)
@@ -51,7 +51,6 @@ import org.springframework.core.ParameterizedTypeReference;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.HttpClientErrorException;
 import org.springframework.web.client.RestTemplate;
@@ -163,7 +162,7 @@ public class RequestsDbClient {
     public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(Map<String, String> orchestrationMap) {
         URI uri = getUri(cloudOrchestrationFiltersFromInfraActive);
         HttpHeaders headers = getHttpHeaders();
-        HttpEntity<Map> entity = new HttpEntity<>(orchestrationMap, headers);
+        HttpEntity<Map<String, String>> entity = new HttpEntity<>(orchestrationMap, headers);
         try {
             return restTemplate.exchange(uri, HttpMethod.POST, entity,
                     new ParameterizedTypeReference<List<InfraActiveRequests>>() {}).getBody();
@@ -447,7 +446,7 @@ public class RequestsDbClient {
         String url = UriBuilder.fromUri(getUri(getInfraActiveRequests)).queryParam("from", "0")
                 .queryParam("to", "10000000000000").build().toString();
         HttpHeaders headers = getHttpHeaders();
-        HttpEntity<Map> entity = new HttpEntity<>(filters, headers);
+        HttpEntity<Map<String, String[]>> entity = new HttpEntity<>(filters, headers);
         return restTemplate
                 .exchange(url, HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {})
                 .getBody();
@@ -486,7 +485,7 @@ public class RequestsDbClient {
 
     @Component
     static class ClassURLMapper {
-        private static final Map<Class, String> classURLMap = new HashMap<>();
+        private static final Map<Class<?>, String> classURLMap = new HashMap<>();
 
         ClassURLMapper() {
             classURLMap.put(ArchivedInfraRequests.class, "/archivedInfraRequests/");
@@ -502,7 +501,7 @@ public class RequestsDbClient {
         }
 
         <T> String getURI(Class<T> className) {
-            Class actualClass = classURLMap.keySet().stream()
+            Class<?> actualClass = classURLMap.keySet().stream()
                     .filter(requestdbClass -> requestdbClass.isAssignableFrom(className)).findFirst().get();
             return classURLMap.get(actualClass);
         }
@@ -567,18 +566,4 @@ public class RequestsDbClient {
         }
     }
 
-    private <T> List<T> postMultipleResponse(URI uri, HttpEntity<?> payload, ParameterizedTypeReference<List<T>> type) {
-        try {
-            HttpEntity<?> entity = new HttpEntity<>(payload.getBody(), getHttpHeaders());
-            ResponseEntity<List<T>> result = restTemplate.exchange(uri, HttpMethod.POST, entity, type);
-
-            return result.getBody();
-        } catch (HttpClientErrorException e) {
-            if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
-                return new ArrayList<T>();
-            }
-            throw e;
-        }
-    }
-
 }
index e455fc3..3202e3b 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -27,7 +27,7 @@ import org.junit.Test;
 
 public class CvnfcCustomizationTest {
 
-    private static final Integer ID = new Integer(1);
+    private static final Integer ID = Integer.valueOf(1);
     private static final String DESCRIPTION = "testDescription";
     private static final String MODEL_CUSTOMIZATION_UUID = "testModelCustomizationUUID";
     private static final String MODEL_INSTANCE_NAME = "testModelInstanceName";
@@ -54,11 +54,11 @@ public class CvnfcCustomizationTest {
         cvnfcCustomization.setNfcNamingCode(NFC_NAMING_CODE);
         cvnfcCustomization.setToscaNodeType(TOSCA_NODE_TYPE);
         cvnfcCustomization.setVfModuleCustomization(setupVfModuleCustomization());
-        List<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizationSet = new ArrayList();
+        List<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizationSet = new ArrayList<>();
         cvnfcConfigurationCustomizationSet.add(setupCvnfcConfigurationCustomization());
         cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizationSet);
 
-        assertTrue(cvnfcCustomization.getId().equals(new Integer(1)));
+        assertTrue(cvnfcCustomization.getId().equals(Integer.valueOf(1)));
         assertTrue(cvnfcCustomization.getDescription().equals(DESCRIPTION));
         assertTrue(cvnfcCustomization.getModelCustomizationUUID().equals(MODEL_CUSTOMIZATION_UUID));
         assertTrue(cvnfcCustomization.getModelInstanceName().equals(MODEL_INSTANCE_NAME));
index 6a5daa6..a98f72b 100644 (file)
 package org.onap.so.db.catalog.client;
 
 
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
 import java.util.ArrayList;
-import java.util.List;
 import javax.persistence.EntityNotFoundException;
 import javax.ws.rs.core.UriBuilder;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
 import org.mockito.Spy;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.so.db.catalog.beans.CvnfcCustomization;
 import org.onap.so.db.catalog.beans.VfModuleCustomization;
 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
-import org.onap.so.db.catalog.beans.Workflow;
 import uk.co.blackpepper.bowman.Client;
 
 @RunWith(MockitoJUnitRunner.class)
@@ -48,12 +45,9 @@ public class CatalogDbClientTest {
 
     @Spy
     private CatalogDbClient catalogDbClient;
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
 
     @Test
     public final void testFindVnfResourceCustomizationInListNullInList() {
-        thrown.expect(EntityNotFoundException.class);
         String vnfCustomizationUUID = "a123";
         VnfResourceCustomization vrc = new VnfResourceCustomization();
         vrc.setModelCustomizationUUID("z789J");
@@ -62,13 +56,12 @@ public class CatalogDbClientTest {
         ArrayList<VnfResourceCustomization> vrcs = new ArrayList<VnfResourceCustomization>();
         vrcs.add(vrc);
         vrcs.add(vrc2);
-        catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vrcs);
+        assertThrows(EntityNotFoundException.class,
+                () -> catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vrcs));
     }
 
     @Test
     public final void testFindVnfResourceCustomizationInListNullString() {
-        thrown.expect(EntityNotFoundException.class);
-        thrown.expectMessage("a NULL UUID was provided in query to search for VnfResourceCustomization");
         String vnfCustomizationUUID = null;
         VnfResourceCustomization vrc = new VnfResourceCustomization();
         vrc.setModelCustomizationUUID("z789J");
@@ -77,7 +70,9 @@ public class CatalogDbClientTest {
         ArrayList<VnfResourceCustomization> vrcs = new ArrayList<VnfResourceCustomization>();
         vrcs.add(vrc);
         vrcs.add(vrc2);
-        catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vrcs);
+        EntityNotFoundException e = assertThrows(EntityNotFoundException.class,
+                () -> catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vrcs));
+        assertTrue(e.getMessage().contains("a NULL UUID was provided in query to search for VnfResourceCustomization"));
     }
 
     @Test
@@ -96,7 +91,6 @@ public class CatalogDbClientTest {
 
     @Test
     public final void testFindVfModuleCustomizationInListNullInList() {
-        thrown.expect(EntityNotFoundException.class);
         String vfModuleCustomizationUUID = "a123";
         VfModuleCustomization vmc = new VfModuleCustomization();
         vmc.setModelCustomizationUUID("z789J");
@@ -105,13 +99,12 @@ public class CatalogDbClientTest {
         ArrayList<VfModuleCustomization> vmcs = new ArrayList<VfModuleCustomization>();
         vmcs.add(vmc);
         vmcs.add(vmc2);
-        catalogDbClient.findVfModuleCustomizationInList(vfModuleCustomizationUUID, vmcs);
+        assertThrows(EntityNotFoundException.class,
+                () -> catalogDbClient.findVfModuleCustomizationInList(vfModuleCustomizationUUID, vmcs));
     }
 
     @Test
     public final void testFindVfModuleCustomizationInListNullString() {
-        thrown.expect(EntityNotFoundException.class);
-        thrown.expectMessage("a NULL UUID was provided in query to search for VfModuleCustomization");
         String vfModuleCustomizationUUID = null;
         VfModuleCustomization vmc = new VfModuleCustomization();
         vmc.setModelCustomizationUUID("z789J");
@@ -120,7 +113,9 @@ public class CatalogDbClientTest {
         ArrayList<VfModuleCustomization> vmcs = new ArrayList<VfModuleCustomization>();
         vmcs.add(vmc);
         vmcs.add(vmc2);
-        catalogDbClient.findVfModuleCustomizationInList(vfModuleCustomizationUUID, vmcs);
+        EntityNotFoundException e = assertThrows(EntityNotFoundException.class,
+                () -> catalogDbClient.findVfModuleCustomizationInList(vfModuleCustomizationUUID, vmcs));
+        assertTrue(e.getMessage().contains("a NULL UUID was provided in query to search for VfModuleCustomization"));
     }
 
     @Test
@@ -139,7 +134,6 @@ public class CatalogDbClientTest {
 
     @Test
     public final void testFindCvnfcCustomizationInListNullInList() {
-        thrown.expect(EntityNotFoundException.class);
         String cvnfcCustomizationUuid = "a123";
         CvnfcCustomization cvnfc = new CvnfcCustomization();
         cvnfc.setModelCustomizationUUID("z789J");
@@ -148,13 +142,12 @@ public class CatalogDbClientTest {
         ArrayList<CvnfcCustomization> cvnfcs = new ArrayList<CvnfcCustomization>();
         cvnfcs.add(cvnfc);
         cvnfcs.add(cvnfc2);
-        catalogDbClient.findCvnfcCustomizationInAList(cvnfcCustomizationUuid, cvnfcs);
+        assertThrows(EntityNotFoundException.class,
+                () -> catalogDbClient.findCvnfcCustomizationInAList(cvnfcCustomizationUuid, cvnfcs));
     }
 
     @Test
     public final void testFindCvnfcCustomizationInListNullString() {
-        thrown.expect(EntityNotFoundException.class);
-        thrown.expectMessage("a NULL UUID was provided in query to search for CvnfcCustomization");
         String cvnfcCustomizationUuid = null;
         CvnfcCustomization cvnfc = new CvnfcCustomization();
         cvnfc.setModelCustomizationUUID("z789J");
@@ -163,7 +156,9 @@ public class CatalogDbClientTest {
         ArrayList<CvnfcCustomization> cvnfcs = new ArrayList<CvnfcCustomization>();
         cvnfcs.add(cvnfc);
         cvnfcs.add(cvnfc2);
-        catalogDbClient.findCvnfcCustomizationInAList(cvnfcCustomizationUuid, cvnfcs);
+        EntityNotFoundException e = assertThrows(EntityNotFoundException.class,
+                () -> catalogDbClient.findCvnfcCustomizationInAList(cvnfcCustomizationUuid, cvnfcs));
+        assertTrue(e.getMessage().contains("a NULL UUID was provided in query to search for CvnfcCustomization"));
     }
 
     @Test
@@ -181,11 +176,12 @@ public class CatalogDbClientTest {
     }
 
     @Test
+    @SuppressWarnings("unchecked")
     public final void testFindWorkflowByPnfModelUUID() {
         String pnfResourceModelUUID = "f2d1f2b2-88bb-49da-b716-36ae420ccbff";
 
-        doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any());
-        List<Workflow> results = catalogDbClient.findWorkflowByPnfModelUUID(pnfResourceModelUUID);
+        doReturn(new ArrayList<>()).when(catalogDbClient).getMultipleResources(any(), any());
+        catalogDbClient.findWorkflowByPnfModelUUID(pnfResourceModelUUID);
         verify(catalogDbClient).getMultipleResources(any(Client.class),
                 eq(UriBuilder.fromUri("/findWorkflowByPnfModelUUID")
                         .queryParam(CatalogDbClient.PNF_RESOURCE_MODEL_UUID, pnfResourceModelUUID).build()));
@@ -193,10 +189,11 @@ public class CatalogDbClientTest {
     }
 
     @Test
+    @SuppressWarnings("unchecked")
     public final void testFindWorkflowByResourceTarget() {
         // when
         final String pnf_resource = "pnf";
-        doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any());
+        doReturn(new ArrayList<>()).when(catalogDbClient).getMultipleResources(any(), any());
         catalogDbClient.findWorkflowByResourceTarget(pnf_resource);
 
         // verify
@@ -205,9 +202,10 @@ public class CatalogDbClientTest {
     }
 
     @Test
+    @SuppressWarnings("unchecked")
     public final void testFindWorkFlowByOperationName() {
         final String operationName = "PNFSoftwareUpgrade";
-        doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any());
+        doReturn(new ArrayList<>()).when(catalogDbClient).getMultipleResources(any(), any());
         catalogDbClient.findWorkflowByOperationName(operationName);
 
         // verify