* 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.adapters.sdncrest;
-import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.xml.bind.annotation.XmlElement;
@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).
* 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.
/**
* {@inheritDoc}
*/
+ @SuppressWarnings("rawtypes")
protected OSClient getClient() {
return client;
}
}
}
+ @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 {
}
+ @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) {
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);
}
}
}
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;
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);
public void setAllocateAnNssi(AllocateAnNssi allocateAnNssi) {
this.allocateAnNssi = allocateAnNssi;
}
+
+ public ServiceInfo getServiceInfo() {
+ return serviceInfo;
+ }
+
+ public void setServiceInfo(ServiceInfo serviceInfo) {
+ this.serviceInfo = serviceInfo;
+ }
}
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;
this.serviceProfile = serviceProfile;
}
}
-
* 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.
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)
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;
/**
* Required for Marshalers to send the fields.
- *
+ *
* @return
*/
public boolean getSuppressRollback() {
@Override
public URI buildNoNetwork() {
- return super.build(new String[] {"NONE", "NONE", (String) this.values[0]});
+ return super.build("NONE", "NONE", (String) this.values[0]);
}
}
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();
}
+ @SuppressWarnings("unchecked")
public <T extends RestProperties> T getRestProperties() {
if (props == null) {
throw new IllegalStateException("No RestProperty implementation found on classpath");
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;
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;
@Rule
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Spy
public AAIClient client;
@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
* 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.
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;
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));
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) {
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;
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;
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;
@Autowired
private ResponseBuilder builder;
- @Autowired
- private CamundaClient camundaClient;
-
@Autowired
private ResponseHandler responseHandler;
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);
}
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;
public class TasksHandler {
- private static Logger logger = LoggerFactory.getLogger(TasksHandler.class);
private static final ObjectMapper mapper = new ObjectMapper();
@Value("${mso.camunda.rest.task.uri}")
* 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.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;
* 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.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;
* 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.
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
* 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.
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;
}
* 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.
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));
}
* 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;
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();
}
@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
}
@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"));
}
}
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;
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();
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();
@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/");
}
<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);
}
}
}
- 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;
- }
- }
-
}
* 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.
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";
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));
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)
@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");
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");
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
@Test
public final void testFindVfModuleCustomizationInListNullInList() {
- thrown.expect(EntityNotFoundException.class);
String vfModuleCustomizationUUID = "a123";
VfModuleCustomization vmc = new VfModuleCustomization();
vmc.setModelCustomizationUUID("z789J");
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");
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
@Test
public final void testFindCvnfcCustomizationInListNullInList() {
- thrown.expect(EntityNotFoundException.class);
String cvnfcCustomizationUuid = "a123";
CvnfcCustomization cvnfc = new CvnfcCustomization();
cvnfc.setModelCustomizationUUID("z789J");
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");
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
}
@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()));
}
@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
}
@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