summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-03-19 13:04:48 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-19 13:04:48 +0000
commitc1fcea306877deed8ec05e3608b2a7534b345900 (patch)
treec8432ff804fdd923631bba995c4d6b83fe490846
parent8eae882cfb0219fb73536660f4d565ac4656cd54 (diff)
parentd0b46ad269c870c72e228a9617615b0a828a940c (diff)
Merge "Correct object provider for jersey"
-rw-r--r--common/src/main/java/org/onap/so/client/RestClient.java3
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIVersion.java11
-rw-r--r--common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java11
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/AAIDeserializeTest.java84
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/AAI.json132
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/aai/UnknownProperty.json1
7 files changed, 239 insertions, 6 deletions
diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java
index 077ba24c2b..30389de742 100644
--- a/common/src/main/java/org/onap/so/client/RestClient.java
+++ b/common/src/main/java/org/onap/so/client/RestClient.java
@@ -188,8 +188,7 @@ public abstract class RestClient {
client.register(new PayloadLoggingClientFilter(this.getMaxPayloadSize()));
}
CommonObjectMapperProvider provider = this.getCommonObjectMapperProvider();
- client.register(new JacksonJsonProvider(provider.getMapper()));
-
+ client.register(provider).register(new JacksonJsonProvider(provider.getMapper()));
metricLogClientFilter = new SOMetricLogClientFilter();
mdcSetup.setTargetEntity(getTargetEntity());
client.register(metricLogClientFilter);
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIVersion.java b/common/src/main/java/org/onap/so/client/aai/AAIVersion.java
index 4f06b787f7..42887884db 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIVersion.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIVersion.java
@@ -23,7 +23,16 @@ package org.onap.so.client.aai;
import org.onap.so.client.graphinventory.GraphInventoryVersion;
public enum AAIVersion implements GraphInventoryVersion {
- V13("v13"), V14("v14"), V15("v15"), V16("v16"), V17("v17"), V18("v18"), V19("v19");
+ V10("V10"),
+ V11("V11"),
+ V12("V12"),
+ V13("v13"),
+ V14("v14"),
+ V15("v15"),
+ V16("v16"),
+ V17("v17"),
+ V18("v18"),
+ V19("v19");
public static final AAIVersion LATEST = AAIVersion.values()[AAIVersion.values().length - 1];
private final String value;
diff --git a/common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java b/common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java
index c55370f7dc..334e0f7231 100644
--- a/common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java
+++ b/common/src/main/java/org/onap/so/client/policy/CommonObjectMapperProvider.java
@@ -20,13 +20,16 @@
package org.onap.so.client.policy;
+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;
-public class CommonObjectMapperProvider {
+@Provider
+public class CommonObjectMapperProvider implements ContextResolver<ObjectMapper> {
protected ObjectMapper mapper;
@@ -43,4 +46,10 @@ public class CommonObjectMapperProvider {
public ObjectMapper getMapper() {
return mapper;
}
+
+ @Override
+ public ObjectMapper getContext(Class<?> type) {
+
+ return mapper;
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
index 0afc272b0a..168f82bdf3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
@@ -23,9 +23,7 @@ package org.onap.so.apihandlerinfra;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.PostConstruct;
-import javax.servlet.ServletConfig;
import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.core.Context;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletProperties;
import org.onap.logging.filter.base.Constants;
@@ -96,6 +94,7 @@ public class JerseyConfiguration extends ResourceConfig {
// this registration seems to be needed to get predictable
// execution behavior for the above JSON Exception Mappers
register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class);
+
register(ModelDistributionRequest.class);
property(ServletProperties.FILTER_FORWARD_ON_404, true);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/AAIDeserializeTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/AAIDeserializeTest.java
new file mode 100644
index 0000000000..e6409fab87
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/AAIDeserializeTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static org.junit.Assert.assertEquals;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import javax.ws.rs.core.MediaType;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.domain.yang.Tenant;
+import org.onap.so.client.aai.AAIVersion;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpHeaders;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class AAIDeserializeTest extends BaseTest {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ @Autowired
+ private MsoRequest msoReq;
+
+ @Value("${wiremock.server.port}")
+ private String wiremockPort;
+
+ @Before
+ public void beforeClass() {
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ }
+
+ public String inputStream(String JsonInput) throws IOException {
+ JsonInput = "src/test/resources/MsoRequestTest" + JsonInput;
+ return new String(Files.readAllBytes(Paths.get(JsonInput)));
+ }
+
+ @Test
+ public void doNotFailOnUnknownPropertiesTest() throws JsonParseException, JsonMappingException, IOException {
+ wireMockServer.stubFor(get(("/aai/" + AAIVersion.LATEST
+ + "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("aai/UnknownProperty.json")
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+ ServiceInstancesRequest sir = mapper.readValue(inputStream("/AAI.json"), ServiceInstancesRequest.class);
+ String tenantId = "88a6ca3ee0394ade9403f075db23167e";
+ String tenantNameFromAAI = "testTenantName";
+ String cloudOwner = "cloudOwner";
+ sir.getRequestDetails().getCloudConfiguration().setCloudOwner(cloudOwner);
+ Tenant tenant = new Tenant();
+ tenant.setTenantId(tenantId);
+ tenant.setTenantName(tenantNameFromAAI);
+ String tenantName = msoReq.getTenantNameFromAAI(sir);
+ assertEquals(tenantNameFromAAI, tenantName);
+ }
+
+}
+
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/AAI.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/AAI.json
new file mode 100644
index 0000000000..455d73a13b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/AAI.json
@@ -0,0 +1,132 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelName": "model-name",
+ "modelVersion": "10"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "{some project name}"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "{some subscriber id}"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "xxxxxx"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "type",
+ "aLaCarte": false,
+ "userParams": [
+ {
+ "service": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelName": "model-name",
+ "modelVersion": "10"
+ },
+ "instanceParams": [],
+ "resources": {
+ "vnfs": [
+ {
+ "modelInfo": {
+ "modelCustomizationName": "model-name 0",
+ "modelName": "model-name",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "platform": {
+ "platformName": "someValue"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "someValue"
+ },
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "instanceParams": [
+ {
+ "instanceName": "someVnfInstanceName"
+ }
+ ],
+ "vfModules": [
+ {
+ "modelInfo": {
+ "modelName": "name._base__BV..module-0",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelCustomizationId": "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"
+ },
+ "instanceParams": [
+ {
+ "vmx_int_net_len": "24",
+ "asn": "someValue"
+ }
+ ]
+ },
+ {
+ "modelInfo": {
+ "modelName": "name._vRE_BV..module-1",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8",
+ "modelType": "vfModule"
+ },
+ "instanceParams": [
+ {
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vre_a_volume_size_0": "100"
+ }
+ ]
+ },
+ {
+ "modelInfo": {
+ "modelName": "name._vRE_BV..module-1",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8"
+ },
+ "instanceParams": [
+ {
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vre_a_volume_size_0": "50"
+ }
+ ]
+ },
+ {
+ "modelInfo": {
+ "modelName": "name.BV..module-2",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelCustomizationId": "da4d4327-fb7d-4311-ac7a-be7ba60cf969"
+ },
+ "instanceParams": [
+ {
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vmx_vpfe_int_ip_0": "192.168.0.16"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/aai/UnknownProperty.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/aai/UnknownProperty.json
new file mode 100644
index 0000000000..e606f8aa30
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/aai/UnknownProperty.json
@@ -0,0 +1 @@
+{"tenant-id":"78491aac74be4fab9873db114774b475","tenant-name":"testTenantName", "test":"test", "parent-id": "25239", "tenant-context":"Development","resource-version":"1581690782612"} \ No newline at end of file