diff options
author | Boslet, Cory <cory.boslet@att.com> | 2019-08-26 10:09:09 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2019-08-26 10:09:10 -0400 |
commit | a83fa219608559e1c9a82e4cfc5a345d6c3ec636 (patch) | |
tree | 95259d1199130d4fa722a0f4e10a26705bd48a6c /mso-api-handlers/mso-api-handler-infra | |
parent | 392930581c3c981af482f006a11ac82ab2385ba1 (diff) |
Added default value for when ErrorCode is null in
Added default value for when ErrorCode is null in mdc
test to see if 404 log gets enhanced by change.
Removed test id from class that was put to test via docker.
Removed setting of partner name and tested with using try/catch
Reverted change to request uri filter per comments
Removed the request filter uri class that rerouted old uri orders
Removed request filter from jersey config files
Updated junit test that were pointing to the old uri to be failure test
corrected formatting issues on ServiceInstancesTest
Issue-ID: SO-2259
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: Id8f9daef139a82ee9e934d4d37906ffb7a7aadff
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra')
4 files changed, 9 insertions, 130 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/filters/RequestUriFilter.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/filters/RequestUriFilter.java deleted file mode 100644 index a3ff1ab95d..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/filters/RequestUriFilter.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============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.apihandler.filters; - -import java.io.IOException; -import java.net.URI; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.container.ContainerRequestFilter; -import javax.ws.rs.container.PreMatching; -import javax.ws.rs.core.UriInfo; -import org.onap.so.apihandlerinfra.Constants; - - -@PreMatching -public class RequestUriFilter implements ContainerRequestFilter { - - private String requestURI; - - @Override - public void filter(ContainerRequestContext context) throws IOException { - UriInfo uriInfo = context.getUriInfo(); - URI baseURI = uriInfo.getBaseUri(); - requestURI = uriInfo.getPath(); - - if (requestURI.contains("onap/so/infra/serviceInstances")) { - requestURI = requestURI.replaceFirst("serviceInstances", "serviceInstantiation"); - if (!requestURI.contains(Constants.SERVICE_INSTANCE_PATH)) { - // Adds /serviceInstances after the version provided in the URI - requestURI = new StringBuilder(requestURI) - .insert(requestURI.indexOf(Constants.SERVICE_INSTANTIATION_PATH) + 24, - Constants.SERVICE_INSTANCE_PATH) - .toString(); - } - requestURI = baseURI + requestURI; - URI uri = URI.create(requestURI); - context.setRequestUri(uri); - } - } - - public String getRequestUri() { - return requestURI; - } -} 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 00d36b3ff9..e162a67680 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 @@ -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,7 +25,6 @@ import javax.ws.rs.ApplicationPath; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.servlet.ServletProperties; import org.onap.so.apihandler.filters.RequestIdFilter; -import org.onap.so.apihandler.filters.RequestUriFilter; import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper; import org.onap.so.apihandlerinfra.infra.rest.Network; import org.onap.so.apihandlerinfra.infra.rest.ServiceInstance; @@ -72,7 +71,6 @@ public class JerseyConfiguration extends ResourceConfig { register(SwaggerSerializers.class); register(ApiExceptionMapper.class); register(RuntimeExceptionMapper.class); - register(RequestUriFilter.class); register(RequestIdFilter.class); register(E2EServiceInstances.class); register(WorkflowSpecificationsHandler.class); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/filters/RequestUriFilterTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/filters/RequestUriFilterTest.java deleted file mode 100644 index 276b438529..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandler/filters/RequestUriFilterTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 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.apihandler.filters; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import java.io.IOException; -import java.net.URI; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.core.UriInfo; -import org.junit.Test; -import org.onap.so.apihandlerinfra.BaseTest; - - - -public class RequestUriFilterTest extends BaseTest { - - @Test - public void filterTest() throws IOException { - RequestUriFilter URIFilter = new RequestUriFilter(); - URI baseURI = URI.create("http://localhost:58879/"); - String requestURI = "onap/so/infra/serviceInstances/v5"; - - ContainerRequestContext mockContext = mock(ContainerRequestContext.class); - UriInfo mockInfo = mock(UriInfo.class); - - when(mockContext.getUriInfo()).thenReturn(mockInfo); - when(mockInfo.getBaseUri()).thenReturn(baseURI); - when(mockInfo.getPath()).thenReturn(requestURI); - - - URIFilter.filter(mockContext); - assertEquals("http://localhost:58879/onap/so/infra/serviceInstantiation/v5/serviceInstances", - URIFilter.getRequestUri()); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index a79aeb2bd7..48a5343104 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.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. @@ -285,14 +285,13 @@ public class ServiceInstancesTest extends BaseTest { requestReferences.setInstanceId("1882939"); requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d")); expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceUriPrev7 + "v5"; + uri = servInstanceuri + "v5"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers); // then - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + assertEquals(404, response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test @@ -896,7 +895,7 @@ public class ServiceInstancesTest extends BaseTest { ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals(404, response.getStatusCode().value()); } @Test @@ -2248,14 +2247,12 @@ public class ServiceInstancesTest extends BaseTest { requestReferences.setInstanceId("1882939"); requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d")); expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceUriPrev7 + "v5"; + uri = servInstanceuri + "v5"; ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers); // then - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + assertEquals(404, response.getStatusCode().value()); } @Test |