diff options
Diffstat (limited to 'vid-app-common/src/test/java/org')
5 files changed, 143 insertions, 91 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java index 7c08e942a..9629e4634 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java @@ -137,6 +137,23 @@ public class AaiClientTest { }; } + @Test + public void testAaiPutCustomQueryByParams() { + String globalCustomerId = "globalCustomerId1-360-as988q"; + String serviceType = "TEST1-360"; + String nfRole = "test360"; + String queryFormat = "query?format=simple"; + final ResponseWithRequestInfo mockedResponseWithRequestInfo = mockedResponseWithRequestInfo(Response.Status.OK, + TestUtils.readFileAsString("/payload_jsons/changeManagement/get_vnf_data_by_globalid_and_service_type_reduced_response.json"), + "query?format=simple&Mock=True", + HttpMethod.PUT); + when(aaiClientMock.getVnfsByParamsForChangeManagement(anyString(), anyString(),anyString(), nullable(String.class))).thenCallRealMethod(); + when(aaiClientMock.doAaiPut(eq(queryFormat), anyString(), anyBoolean(), anyBoolean())).thenReturn(mockedResponseWithRequestInfo); + AaiResponse response = aaiClientMock.getVnfsByParamsForChangeManagement(globalCustomerId, serviceType, nfRole, null); + verify(aaiClientMock).doAaiPut(anyString(), anyString(),anyBoolean(),anyBoolean()); + response.toString(); + } + @Test(dataProvider = "logicalLinkData") public void getLogicalLink_Link_Is_Empty(String link, String expectedUrl) { @@ -518,7 +535,7 @@ public class AaiClientTest { } @Test(expectedExceptions = GenericUncheckedException.class, expectedExceptionsMessageRegExp = "A&AI has no homing data associated to vfModule 'vfModuleId' of vnf 'vnfInstanceId'") - public void getVfMoudule_Homing_Arguments_Are_Valid_But_Not_Exists() { + public void getVfModule_Homing_Arguments_Are_Valid_But_Not_Exists() { when(aaiClientMock.getHomingDataByVfModule(any(String.class), any(String.class))).thenCallRealMethod(); Response generalEmptyResponse = mock(Response.class); @@ -536,7 +553,7 @@ public class AaiClientTest { } @Test(dataProvider = "invalidDataId", expectedExceptions = GenericUncheckedException.class, expectedExceptionsMessageRegExp = "Failed to retrieve homing data associated to vfModule from A&AI, VNF InstanceId or VF Module Id is missing.") - public void getVfMoudule_Homing_Arguments_Are_Empty_Or_Null(String data) { + public void getVfModule_Homing_Arguments_Are_Empty_Or_Null(String data) { when(aaiClientMock.getHomingDataByVfModule(any(), any())).thenCallRealMethod(); aaiClientMock.getHomingDataByVfModule(data, data); } diff --git a/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpServerTest.java b/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpServerTest.java index b30cf5f32..5a2eb59d2 100644 --- a/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpServerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpServerTest.java @@ -3,6 +3,7 @@ * VID * ================================================================================ * Copyright (C) 2018 - 2019 Nokia. All rights reserved. + * Modifications Copyright (C) 2017 - 2019 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. @@ -26,9 +27,13 @@ import static com.xebialabs.restito.semantics.Action.contentType; import static com.xebialabs.restito.semantics.Action.ok; import static com.xebialabs.restito.semantics.Action.status; import static com.xebialabs.restito.semantics.Action.stringContent; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import static org.testng.Assert.assertEquals; +import com.att.eelf.configuration.EELFLogger; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; @@ -42,6 +47,7 @@ import java.util.Map; import org.glassfish.grizzly.http.Method; import org.glassfish.grizzly.http.util.HttpStatus; import org.onap.vid.utils.Logging; +import org.springframework.http.HttpMethod; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -80,6 +86,8 @@ public class SyncRestClientForHttpServerTest { .get(url, Collections.emptyMap(), Collections.emptyMap()); // then verifyHttp(stubServer).once(Condition.method(Method.GET), Condition.url(url)); + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.GET), eq(url), eq(Collections.emptyMap())); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.GET), eq(url), eq(jsonNodeHttpResponse)); assertEquals(jsonNodeHttpResponse.getStatus(), 200); assertEquals(jsonNodeHttpResponse.getBody().getObject().get("key"), 1); assertEquals(jsonNodeHttpResponse.getBody().getObject().get("value"), "test"); @@ -95,6 +103,8 @@ public class SyncRestClientForHttpServerTest { .get(url, Collections.emptyMap(), Collections.emptyMap(), SyncRestClientModel.TestModel.class); // then verifyHttp(stubServer).once(Condition.method(Method.GET), Condition.url(url)); + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.GET), eq(url), eq(Collections.emptyMap())); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.GET), eq(url), eq(testModelHttpResponse)); assertEquals(testModelHttpResponse.getStatus(), 200); assertEquals(testModelHttpResponse.getBody().getKey(), 1); assertEquals(testModelHttpResponse.getBody().getValue(), "test"); @@ -108,6 +118,8 @@ public class SyncRestClientForHttpServerTest { // when HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient.post(url, Collections.emptyMap(), testObject); // then + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.POST), eq(url), eq(testObject)); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.POST), eq(url), eq(jsonNodeHttpResponse)); verifyHttp(stubServer).once(Condition.method(Method.POST), Condition.url(url)); assertEquals(jsonNodeHttpResponse.getStatus(), 200); assertEquals(jsonNodeHttpResponse.getBody().getObject().get("key"), 1); @@ -123,6 +135,8 @@ public class SyncRestClientForHttpServerTest { HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient .post(url, Collections.emptyMap(), NOT_EXISTING_OBJECT); // then + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.POST), eq(url), eq(NOT_EXISTING_OBJECT)); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.POST), eq(url), eq(jsonNodeHttpResponse)); assertEquals(jsonNodeHttpResponse.getStatus(), 404); assertEquals(jsonNodeHttpResponse.getStatusText(), "Not Found"); } @@ -137,6 +151,8 @@ public class SyncRestClientForHttpServerTest { HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient.post(url, headers, testObject); // then verifyHttp(stubServer).once(Condition.withHeader("Authorization")); + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.POST), eq(url), eq(testObject)); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.POST), eq(url), eq(jsonNodeHttpResponse)); assertEquals(jsonNodeHttpResponse.getStatus(), 200); } @@ -160,6 +176,8 @@ public class SyncRestClientForHttpServerTest { .post(url, Collections.emptyMap(), testObject, SyncRestClientModel.TestModel.class); // then verifyHttp(stubServer).once(Condition.method(Method.POST), Condition.url(url)); + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.POST), eq(url), eq(testObject)); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.POST), eq(url), eq(objectHttpResponse)); assertEquals(objectHttpResponse.getStatus(), 200); assertEquals(objectHttpResponse.getBody().getKey(), 1); assertEquals(objectHttpResponse.getBody().getValue(), "test"); @@ -174,6 +192,8 @@ public class SyncRestClientForHttpServerTest { HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient.put(url, Collections.emptyMap(), testObject); // then verifyHttp(stubServer).once(Condition.method(Method.PUT), Condition.url(url)); + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.PUT), eq(url), eq(testObject)); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.PUT), eq(url), eq(jsonNodeHttpResponse)); assertEquals(jsonNodeHttpResponse.getStatus(), 201); assertEquals(jsonNodeHttpResponse.getBody().getObject().get("key"), 1); assertEquals(jsonNodeHttpResponse.getBody().getObject().get("value"), "test"); @@ -189,6 +209,8 @@ public class SyncRestClientForHttpServerTest { .put(url, Collections.emptyMap(), testObject, SyncRestClientModel.TestModel.class); // then verifyHttp(stubServer).once(Condition.method(Method.PUT), Condition.url(url)); + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.PUT), eq(url), eq(testObject)); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.PUT), eq(url), eq(modelHttpResponse)); assertEquals(modelHttpResponse.getStatus(), 201); assertEquals(modelHttpResponse.getBody().getKey(), 1); assertEquals(modelHttpResponse.getBody().getValue(), "test"); @@ -203,6 +225,8 @@ public class SyncRestClientForHttpServerTest { HttpResponse<JsonNode> jsonNodeHttpResponse = syncRestClient.delete(url, Collections.emptyMap()); // then verifyHttp(stubServer).once(Condition.method(Method.DELETE), Condition.url(url)); + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.DELETE), eq(url)); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.DELETE), eq(url), eq(jsonNodeHttpResponse)); assertEquals(jsonNodeHttpResponse.getStatus(), 200); assertEquals(jsonNodeHttpResponse.getBody().getObject().get("key"), 1); assertEquals(jsonNodeHttpResponse.getBody().getObject().get("value"), "test"); @@ -218,6 +242,8 @@ public class SyncRestClientForHttpServerTest { .delete(url, Collections.emptyMap(), SyncRestClientModel.TestModel.class); // then verifyHttp(stubServer).once(Condition.method(Method.DELETE), Condition.url(url)); + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.DELETE), eq(url)); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.DELETE), eq(url), eq(modelHttpResponse)); assertEquals(modelHttpResponse.getStatus(), 200); assertEquals(modelHttpResponse.getBody().getKey(), 1); assertEquals(modelHttpResponse.getBody().getValue(), "test"); diff --git a/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpsServerTest.java b/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpsServerTest.java index 758dd070b..f4692c564 100644 --- a/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpsServerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/client/SyncRestClientForHttpsServerTest.java @@ -3,6 +3,7 @@ * VID * ================================================================================ * Copyright (C) 2018 - 2019 Nokia. All rights reserved. + * Modifications Copyright (C) 2017 - 2019 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. @@ -26,9 +27,13 @@ import static com.xebialabs.restito.semantics.Action.contentType; import static com.xebialabs.restito.semantics.Action.ok; import static com.xebialabs.restito.semantics.Action.stringContent; import static org.apache.http.client.config.RequestConfig.custom; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import static org.testng.Assert.assertEquals; +import com.att.eelf.configuration.EELFLogger; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.xebialabs.restito.semantics.Action; @@ -50,6 +55,7 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.glassfish.grizzly.http.Method; import org.onap.vid.utils.Logging; +import org.springframework.http.HttpMethod; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -89,6 +95,8 @@ public class SyncRestClientForHttpsServerTest { // then verifyHttp(stubServer) .once(Condition.method(Method.GET), Condition.url(securedUrl), Condition.not(Condition.url(notSecuredUrl))); + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.GET), eq(securedUrl), eq(Collections.emptyMap())); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.GET), eq(securedUrl), eq(jsonNodeHttpResponse)); assertEquals(jsonNodeHttpResponse.getStatus(), 200); assertEquals(jsonNodeHttpResponse.getBody().getObject().get("key"), 1); assertEquals(jsonNodeHttpResponse.getBody().getObject().get("value"), "test"); @@ -107,6 +115,8 @@ public class SyncRestClientForHttpsServerTest { // then verifyHttp(stubServer) .once(Condition.method(Method.GET), Condition.url(securedUrl), Condition.not(Condition.url(notSecuredUrl))); + verify(mockLoggingService).logRequest(any(EELFLogger.class), eq(HttpMethod.GET), eq(securedUrl), eq(Collections.emptyMap())); + verify(mockLoggingService).logResponse(any(EELFLogger.class), eq(HttpMethod.GET), eq(securedUrl), eq(testModelHttpResponse)); assertEquals(testModelHttpResponse.getStatus(), 200); assertEquals(testModelHttpResponse.getBody().getKey(), 1); assertEquals(testModelHttpResponse.getBody().getValue(), "test"); diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java index f9a374948..3e38ba883 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java @@ -88,7 +88,6 @@ public class AaiControllerTest { private RoleProvider roleProvider; @Mock private SystemPropertiesWrapper systemPropertiesWrapper; - @Mock private FeatureManager featureManager; @@ -98,7 +97,7 @@ public class AaiControllerTest { @Before public void setUp() { aaiController = new AaiController(aaiService, aaiRestInterface, roleProvider, systemPropertiesWrapper, - featureManager); + featureManager); mockMvc = MockMvcBuilders.standaloneSetup(aaiController).build(); } @@ -112,12 +111,12 @@ public class AaiControllerTest { given(aaiService.getAicZoneForPnf(globalCustomerId, serviceType, serviceId)).willReturn(aaiResponse); mockMvc.perform( - get("/aai_get_aic_zone_for_pnf/{globalCustomerId}/{serviceType}/{serviceId}", globalCustomerId, serviceType, - serviceId) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody))); + get("/aai_get_aic_zone_for_pnf/{globalCustomerId}/{serviceType}/{serviceId}", globalCustomerId, serviceType, + serviceId) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody))); } @Test @@ -128,10 +127,10 @@ public class AaiControllerTest { given(aaiService.getInstanceGroupsByVnfInstanceId(vnfInstanceId)).willReturn(aaiResponse); mockMvc.perform(get("/aai_get_instance_groups_by_vnf_instance_id/{vnfInstanceId}", vnfInstanceId) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody))); + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody))); } @Test @@ -144,17 +143,17 @@ public class AaiControllerTest { given(response.getStatus()).willReturn(HttpStatus.OK.value()); given(aaiRestInterface.RestGet(eq("VidAaiController"), anyString(), eq(Unchecked.toURI( - "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:" - + serviceInstanceId)), - eq(false)).getResponse()).willReturn(response); + "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:" + + serviceInstanceId)), + eq(false)).getResponse()).willReturn(response); mockMvc - .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId, - serviceInstanceType) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(expectedResponseBody)); + .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId, + serviceInstanceType) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(expectedResponseBody)); } @Test @@ -167,17 +166,17 @@ public class AaiControllerTest { given(response.getStatus()).willReturn(HttpStatus.OK.value()); given(aaiRestInterface.RestGet(eq("VidAaiController"), anyString(), eq(Unchecked.toURI( - "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:" - + serviceInstanceId)), - eq(false)).getResponse()).willReturn(response); + "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:" + + serviceInstanceId)), + eq(false)).getResponse()).willReturn(response); mockMvc - .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId, - serviceInstanceType) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(expectedResponseBody)); + .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId, + serviceInstanceType) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(expectedResponseBody)); } @Test @@ -190,21 +189,21 @@ public class AaiControllerTest { given(response.getStatus()).willReturn(HttpStatus.OK.value()); given(aaiRestInterface.RestGet( - eq("VidAaiController"), - anyString(), - eq(Unchecked.toURI( - "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" - + serviceSubscriptionId + "?depth=0")), - eq(false)).getResponse()).willReturn(response); + eq("VidAaiController"), + anyString(), + eq(Unchecked.toURI( + "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + + serviceSubscriptionId + "?depth=0")), + eq(false)).getResponse()).willReturn(response); mockMvc - .perform( - get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId, - serviceSubscriptionId) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(expectedResponseBody)); + .perform( + get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId, + serviceSubscriptionId) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(expectedResponseBody)); } @Test @@ -213,21 +212,21 @@ public class AaiControllerTest { String serviceSubscriptionId = "testServiceSubscriptionId"; String expectedResponseBody = "Failed to fetch data from A&AI, check server logs for details."; given(aaiRestInterface.RestGet( - eq("VidAaiController"), - anyString(), - eq(Unchecked.toURI( - "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" - + serviceSubscriptionId + "?depth=0")), - eq(false)).getResponse()).willReturn(null); + eq("VidAaiController"), + anyString(), + eq(Unchecked.toURI( + "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + + serviceSubscriptionId + "?depth=0")), + eq(false)).getResponse()).willReturn(null); mockMvc - .perform( - get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId, - serviceSubscriptionId) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isInternalServerError()) - .andExpect(content().string(expectedResponseBody)); + .perform( + get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId, + serviceSubscriptionId) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isInternalServerError()) + .andExpect(content().string(expectedResponseBody)); } @Test @@ -235,18 +234,18 @@ public class AaiControllerTest { PortMirroringConfigDataOk okConfigData = new PortMirroringConfigDataOk("foo"); PortMirroringConfigDataError errorConfigData = new PortMirroringConfigDataError("bar", "{ baz: qux }"); Map<String, PortMirroringConfigData> expectedJson = ImmutableMap.of( - ID_1, okConfigData, - ID_2, errorConfigData); + ID_1, okConfigData, + ID_2, errorConfigData); given(aaiService.getPortMirroringConfigData(ID_1)).willReturn(okConfigData); given(aaiService.getPortMirroringConfigData(ID_2)).willReturn(errorConfigData); mockMvc - .perform(get("/aai_getPortMirroringConfigsData") - .param("configurationIds", ID_1, ID_2) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().json(objectMapper.writeValueAsString(expectedJson))); + .perform(get("/aai_getPortMirroringConfigsData") + .param("configurationIds", ID_1, ID_2) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(objectMapper.writeValueAsString(expectedJson))); } @Test @@ -254,18 +253,18 @@ public class AaiControllerTest { PortDetailsOk portDetailsOk = new PortDetailsOk("foo", "testInterface", true); PortDetailsError portDetailsError = new PortDetailsError("bar", "{ baz: qux }"); Multimap<String, PortDetails> expectedJson = ImmutableMultimap.of( - ID_1, portDetailsOk, - ID_2, portDetailsError); + ID_1, portDetailsOk, + ID_2, portDetailsError); given(aaiService.getPortMirroringSourcePorts(ID_1)).willReturn(Lists.newArrayList(portDetailsOk)); given(aaiService.getPortMirroringSourcePorts(ID_2)).willReturn(Lists.newArrayList(portDetailsError)); mockMvc - .perform(get("/aai_getPortMirroringSourcePorts") - .param("configurationIds", ID_1, ID_2) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().json(objectMapper.writeValueAsString(expectedJson.asMap()))); + .perform(get("/aai_getPortMirroringSourcePorts") + .param("configurationIds", ID_1, ID_2) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(objectMapper.writeValueAsString(expectedJson.asMap()))); } @Test @@ -279,15 +278,15 @@ public class AaiControllerTest { String expectedResponseBody = "myResponse"; AaiResponse<String> aaiResponse = new AaiResponse<>(expectedResponseBody, "", HttpStatus.OK.value()); given(aaiService - .getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion)) - .willReturn(aaiResponse); + .getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion)) + .willReturn(aaiResponse); mockMvc - .perform(get(urlTemplate, globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(expectedResponseBody)); + .perform(get(urlTemplate, globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(expectedResponseBody)); } @Test @@ -306,7 +305,7 @@ public class AaiControllerTest { public void getAicZones_shouldReturnErrorResponse_whenAaiHttpStatusOtherThanOK() throws Exception { String expectedErrorMessage = "Calling AAI Failed"; given(aaiService.getAaiZones()) - .willReturn(new AaiResponse(null, expectedErrorMessage, HttpStatus.INTERNAL_SERVER_ERROR.value())); + .willReturn(new AaiResponse(null, expectedErrorMessage, HttpStatus.INTERNAL_SERVER_ERROR.value())); mockMvc.perform(get("/aai_get_aic_zones") .contentType(MediaType.APPLICATION_JSON) @@ -363,8 +362,8 @@ public class AaiControllerTest { AaiResponse<String> aaiResponse = new AaiResponse<>(expectedResponseBody, "", HttpStatus.OK.value()); given(aaiService - .getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, - equipModel)).willReturn(aaiResponse); + .getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, + equipModel)).willReturn(aaiResponse); mockMvc.perform( get(urlTemplate, globalCustomerId, serviceType, modelVersionId, @@ -383,7 +382,7 @@ public class AaiControllerTest { Response response = mock(Response.class); given(response.readEntity(String.class)).willReturn(expectedResponse); given(aaiService - .getVersionByInvariantId(request.versions)).willReturn(response); + .getVersionByInvariantId(request.versions)).willReturn(response); mockMvc.perform( post("/aai_get_version_by_invariant_id") @@ -396,7 +395,7 @@ public class AaiControllerTest { @Test public void getSubscriberDetails_shouldOmitServiceInstancesFromSubscriberData_whenFeatureEnabled_andOmitFlagIsTrue() - throws Exception { + throws Exception { boolean isFeatureActive = true; boolean omitServiceInstances = true; @@ -405,8 +404,8 @@ public class AaiControllerTest { AaiResponse<String> aaiResponse = new AaiResponse<>(okResponseBody, "", HttpStatus.OK.value()); given(featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH)).willReturn(isFeatureActive); given(aaiService.getSubscriberData(eq(subscriberId), isA(RoleValidatorByRoles.class), - eq(isFeatureActive && omitServiceInstances))) - .willReturn(aaiResponse); + eq(isFeatureActive && omitServiceInstances))) + .willReturn(aaiResponse); mockMvc.perform( get("/aai_sub_details/{subscriberId}", subscriberId) @@ -419,7 +418,7 @@ public class AaiControllerTest { @Test public void getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureEnabled_andOmitFlagIsFalse() - throws Exception { + throws Exception { boolean isFeatureActive = true; boolean omitServiceInstances = false; @@ -428,7 +427,7 @@ public class AaiControllerTest { @Test public void getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureDisabled_andOmitFlagIsTrue() - throws Exception { + throws Exception { boolean isFeatureActive = false; boolean omitServiceInstances = true; diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/ServicePermissionsTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/ServicePermissionsTest.java index 36af92c0c..ac3da50ab 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/ServicePermissionsTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/ServicePermissionsTest.java @@ -55,7 +55,7 @@ public class ServicePermissionsTest { when(roleProvider.getUserRolesValidator(any())).thenReturn(roleValidator); when(roleValidator.isServicePermitted(subscriberId, serviceType)).thenReturn(expected); - AaiController2 aaiController2 = new AaiController2(null, roleProvider, null); + AaiController2 aaiController2 = new AaiController2(null, roleProvider, null, null); Permissions permissions = aaiController2.servicePermissions(unimportantRequest(), subscriberId, serviceType); assertThat(permissions, is(new Permissions(expected))); |