From: Fiete Ostkamp Date: Sun, 1 Mar 2026 09:34:45 +0000 (+0100) Subject: Resolve IDE problems and warnings X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F10%2F143410%2F1;p=so.git Resolve IDE problems and warnings Issue-ID: SO-4252 Change-Id: I46c81ba904b013c95a6ab5bb0aa58fe006166eb6 Signed-off-by: Fiete Ostkamp --- diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCServiceResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCServiceResponse.java index 842bcfcc02..92564bf192 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCServiceResponse.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/sdncrest/SDNCServiceResponse.java @@ -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). diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV3ClientImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV3ClientImpl.java index a0c05b4dba..3d8ea8bee7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV3ClientImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV3ClientImpl.java @@ -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; } diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java index 8d02cc99e5..644bacba47 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java @@ -124,6 +124,7 @@ public class ApplicationControllerClient { } } + @SuppressWarnings("rawtypes") public Status vnfCommand(Action action, String requestId, String vnfId, Optional vserverId, Optional 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) { diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java index 3f10df36ab..bd987503a8 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java @@ -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); } } } diff --git a/common/clients/clients-base/src/main/java/org/onap/so/client/CommonObjectMapperProvider.java b/common/clients/clients-base/src/main/java/org/onap/so/client/CommonObjectMapperProvider.java index 5dbe66c990..29616e397d 100644 --- a/common/clients/clients-base/src/main/java/org/onap/so/client/CommonObjectMapperProvider.java +++ b/common/clients/clients-base/src/main/java/org/onap/so/client/CommonObjectMapperProvider.java @@ -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 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); diff --git a/common/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java b/common/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java index 9a25d6fea3..a47b80fe68 100644 --- a/common/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java +++ b/common/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java @@ -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; + } } diff --git a/common/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java b/common/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java index cc6c9bbb82..bac041d138 100644 --- a/common/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java +++ b/common/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java @@ -21,11 +21,7 @@ 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; } } - diff --git a/common/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java b/common/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java index 026db1e644..91b05f4477 100644 --- a/common/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java +++ b/common/common/src/main/java/org/onap/so/serviceinstancebeans/RequestInfo.java @@ -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() { diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java index ddadb2701c..98b917ca28 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java @@ -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]); } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java index 99a231a385..6c172641c9 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java @@ -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 getRestProperties() { if (props == null) { throw new IllegalStateException("No RestProperty implementation found on classpath"); diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java index 2814bd6f9e..dd795f258d 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java @@ -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 diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java index 2b08d1130f..60356b91ba 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java @@ -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)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java index 7c9005299e..5a79458cad 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java @@ -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) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java index 6b50eecbe6..69100a2b82 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java @@ -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>() {}); } catch (Exception e) { logger.debug("Exception while reading subnet capability value from json", e); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java index 6464aca90f..df51364b80 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java @@ -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}") diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java index 61d31b3a55..b4e9ff6df0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java @@ -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; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java index fab42515d5..0c8b94b582 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java @@ -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; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java index b30140cd68..badee84f57 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java @@ -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 diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java index 6ffd9dcef8..e5ecc75fae 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java @@ -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; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java index 55a68ff7df..6e84fcc170 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java @@ -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)); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java index ef160e9c4c..9bbe4b4afb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java @@ -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. @@ -21,13 +21,13 @@ 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")); } } diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 806d347582..baa11dccfc 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -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 getCloudOrchestrationFiltersFromInfraActive(Map orchestrationMap) { URI uri = getUri(cloudOrchestrationFiltersFromInfraActive); HttpHeaders headers = getHttpHeaders(); - HttpEntity entity = new HttpEntity<>(orchestrationMap, headers); + HttpEntity> entity = new HttpEntity<>(orchestrationMap, headers); try { return restTemplate.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference>() {}).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 entity = new HttpEntity<>(filters, headers); + HttpEntity> entity = new HttpEntity<>(filters, headers); return restTemplate .exchange(url, HttpMethod.POST, entity, new ParameterizedTypeReference>() {}) .getBody(); @@ -486,7 +485,7 @@ public class RequestsDbClient { @Component static class ClassURLMapper { - private static final Map classURLMap = new HashMap<>(); + private static final Map, String> classURLMap = new HashMap<>(); ClassURLMapper() { classURLMap.put(ArchivedInfraRequests.class, "/archivedInfraRequests/"); @@ -502,7 +501,7 @@ public class RequestsDbClient { } String getURI(Class 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 List postMultipleResponse(URI uri, HttpEntity payload, ParameterizedTypeReference> type) { - try { - HttpEntity entity = new HttpEntity<>(payload.getBody(), getHttpHeaders()); - ResponseEntity> 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(); - } - throw e; - } - } - } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java index e455fc3f02..3202e3be8e 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java @@ -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 cvnfcConfigurationCustomizationSet = new ArrayList(); + List 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)); diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index 6a5daa601a..a98f72b5ff 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -22,25 +22,22 @@ 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 vrcs = new ArrayList(); 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 vrcs = new ArrayList(); 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 vmcs = new ArrayList(); 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 vmcs = new ArrayList(); 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 cvnfcs = new ArrayList(); 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 cvnfcs = new ArrayList(); 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 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