summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/test')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java21
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java31
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java175
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/ServicePermissionsTest.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/utils/LoggingUtilsTest.java49
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/changeManagement/get_vnf_data_by_globalid_and_service_type_reduced_response.json295
7 files changed, 446 insertions, 133 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/aai/AaiOverTLSClientServerTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java
index a9fe256c1..2b9521121 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiOverTLSClientServerTest.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2018 - 2019 Nokia Intellectual Property. 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.
@@ -22,11 +23,11 @@ package org.onap.vid.aai;
import static org.mockito.Mockito.mock;
import static org.mockito.MockitoAnnotations.initMocks;
+import static org.onap.vid.utils.KotlinUtilsKt.JOSHWORKS_JACKSON_OBJECT_MAPPER;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.xebialabs.restito.semantics.Action;
import io.joshworks.restclient.http.HttpResponse;
-import io.joshworks.restclient.http.mapper.ObjectMapper;
import java.io.IOException;
import org.assertj.core.api.Assertions;
import org.glassfish.grizzly.http.util.HttpStatus;
@@ -122,7 +123,7 @@ public class AaiOverTLSClientServerTest {
@NotNull
private AaiOverTLSClient createAaiOverTLSClient() {
return new AaiOverTLSClient(
- new SyncRestClient(getFasterXmlObjectMapper(), mock(Logging.class)),
+ new SyncRestClient(JOSHWORKS_JACKSON_OBJECT_MAPPER, mock(Logging.class)),
propertySupplier,
serverUtil.constructTargetUrl("http", "")
);
@@ -130,7 +131,6 @@ public class AaiOverTLSClientServerTest {
@Test
public void shouldGetSubscribers() throws ParseException, JsonProcessingException {
- ObjectMapper objectMapper = getFasterXmlObjectMapper();
AaiOverTLSClient aaiOverTLSClient = createAaiOverTLSClient();
serverUtil.prepareGetCall("/business/customers", new JSONParser().parse(subscribersResponsePayload), Action.status(HttpStatus.OK_200));
@@ -142,29 +142,4 @@ public class AaiOverTLSClientServerTest {
Assertions.assertThat(allSubscribers.getStatus()).isEqualTo(200);
}
- private ObjectMapper getFasterXmlObjectMapper() {
- return new ObjectMapper() {
-
- com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper();
-
- @Override
- public <T> T readValue(String s, Class<T> aClass) {
- try {
- return om.readValue(s, aClass);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public String writeValue(Object o) {
- try {
- return om.writeValueAsString(o);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- };
- }
-
}
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)));
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
index f89eae25e..457007500 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
@@ -29,8 +29,8 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
+import static org.onap.vid.utils.KotlinUtilsKt.JOSHWORKS_JACKSON_OBJECT_MAPPER;
-import com.fasterxml.jackson.databind.ObjectMapper;
import com.xebialabs.restito.server.StubServer;
import io.joshworks.restclient.http.HttpResponse;
import java.io.IOException;
@@ -48,7 +48,6 @@ import org.junit.Test;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.controller.MsoController;
-import org.onap.vid.controller.WebConfig;
import org.onap.vid.mso.MsoProperties;
import org.onap.vid.mso.MsoResponseWrapper;
import org.onap.vid.mso.MsoResponseWrapperInterface;
@@ -474,8 +473,7 @@ public class MsoRestClientNewTest {
}
private MsoRestClientNew msoRestClient() {
- final WebConfig webConfig = new WebConfig();
- return new MsoRestClientNew(new SyncRestClient(webConfig.unirestFasterxmlObjectMapper(new ObjectMapper()), mock(Logging.class)),
+ return new MsoRestClientNew(new SyncRestClient(JOSHWORKS_JACKSON_OBJECT_MAPPER, mock(Logging.class)),
baseUrl(), null, new SystemPropertiesWrapper(), mock(Logging.class));
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/utils/LoggingUtilsTest.java b/vid-app-common/src/test/java/org/onap/vid/utils/LoggingUtilsTest.java
index ae769a322..c22b59c69 100644
--- a/vid-app-common/src/test/java/org/onap/vid/utils/LoggingUtilsTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/utils/LoggingUtilsTest.java
@@ -20,27 +20,56 @@
package org.onap.vid.utils;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.ArgumentMatchers.contains;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.onap.vid.testUtils.RegExMatcher.matchesRegEx;
+import static org.testng.AssertJUnit.assertEquals;
+
+import com.att.eelf.configuration.EELFLogger;
import com.fasterxml.jackson.core.JsonLocation;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import javax.crypto.BadPaddingException;
+import javax.net.ssl.SSLHandshakeException;
+import javax.ws.rs.ProcessingException;
+import org.mockito.ArgumentCaptor;
import org.onap.vid.exceptions.GenericUncheckedException;
+import org.springframework.http.HttpMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import sun.security.provider.certpath.SunCertPathBuilderException;
import sun.security.validator.ValidatorException;
-import javax.crypto.BadPaddingException;
-import javax.net.ssl.SSLHandshakeException;
-import javax.ws.rs.ProcessingException;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
+public class LoggingUtilsTest {
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.onap.vid.testUtils.RegExMatcher.matchesRegEx;
+ private EELFLogger loggerMock;
-public class LoggingUtilsTest {
+ private Logging logginService = new Logging();
+
+ @BeforeMethod
+ public void setUp() {
+ loggerMock = mock(EELFLogger.class);
+ }
+
+ @Test
+ public void whenLogRequest_thenLoggedInDebug() {
+ //when
+ String url = "someUrl";
+ logginService.logRequest(loggerMock, HttpMethod.GET, url);
+
+ //then
+ ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class);
+ verify(loggerMock).debug(contains("Sending"), argumentCaptor.capture());
+ assertEquals("GET", argumentCaptor.getAllValues().get(0));
+ assertEquals(url, argumentCaptor.getAllValues().get(1));
+ }
@DataProvider
public static Object[][] exceptions() {
diff --git a/vid-app-common/src/test/resources/payload_jsons/changeManagement/get_vnf_data_by_globalid_and_service_type_reduced_response.json b/vid-app-common/src/test/resources/payload_jsons/changeManagement/get_vnf_data_by_globalid_and_service_type_reduced_response.json
new file mode 100644
index 000000000..d9a120a49
--- /dev/null
+++ b/vid-app-common/src/test/resources/payload_jsons/changeManagement/get_vnf_data_by_globalid_and_service_type_reduced_response.json
@@ -0,0 +1,295 @@
+{
+ "results": [
+ {
+ "service-instance": {
+ "service-instance-id": "serviceInstanceID1-369-as988q",
+ "service-instance-name": "EUd8Test",
+ "service-type": "xBoJHJbWTest",
+ "service-role": "sc7OWTest",
+ "environment-context": "O7OVp5Test",
+ "workload-context": "VmnxNeJIgWq7HTest",
+ "model-invariant-id": "modelInvariantValue2-369 -as988q",
+ "model-version-id": "modelVersionKey2-369-as988q",
+ "widget-model-id": "HT7KA2FoRKH3cTest",
+ "widget-model-version": "CsGp5Test",
+ "bandwidth-total": "1Yijkk1Test",
+ "vhn-portal-url": "40PzTest",
+ "service-instance-location-id": "zcAaHJTAt5Hj8Test",
+ "resource-version": "1563820653329",
+ "selflink": "mZP2EVvwwHnlTest",
+ "orchestration-status": "6QvhzNgLudLBTest",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v17/network/generic-vnfs/generic-vnf/test-gvnf2-369-as988q",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "test-gvnf2-369-as988q"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "test-name2-gvnf-369"
+ }
+ ]
+ },
+ {
+ "related-to": "generic-vnf",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v17/network/generic-vnfs/generic-vnf/test-gvnf1-369-as988q",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "test-gvnf1-369-as988q"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "test-name-gvnf-369"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "model-ver": {
+ "model-version-id": "modelVersionKey2-369-as988q",
+ "model-name": "vnfc8",
+ "model-version": "1.1",
+ "resource-version": "1563820653007"
+ }
+ },
+ {
+ "model": {
+ "model-invariant-id": "modelInvariantValue2-369-as988q",
+ "model-type": "widget3",
+ "resource-version": "1563820652703",
+ "model-vers": {
+ "model-ver": [
+ {
+ "model-version-id": "modelVersionKey2-369-as988q",
+ "model-name": "vnfc8",
+ "model-version": "1.1",
+ "resource-version": "1563820653007"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "generic-vnf": {
+ "vnf-id": "test-gvnf2-369-as988q",
+ "vnf-name": "test-name2-gvnf-369",
+ "vnf-type": "SW",
+ "service-id": "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4",
+ "equipment-role": "UCPE",
+ "orchestration-status": "created",
+ "ipv4-oam-address": "12.80.1.18",
+ "nm-lan-v6-address": "2001:1890:e00e:fffe::33c4",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1563820654611",
+ "model-invariant-id": "modelInvariantValue-369-as988q",
+ "model-version-id": "modelVersionKey-369-as988q",
+ "nf-role": "test360",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v17/business/customers/customer/globalCustomerId1-369-as988q/service-subscriptions/service-subscription/TEST1-369/service-instances/service-instance/serviceInstanceID1-369-as988q",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "globalCustomerId1-369-as988q"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "TEST1-369"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "serviceInstanceID1-369-as988q"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "EUd8Test"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "model-ver": {
+ "model-version-id": "modelVersionKey-369-as988q",
+ "model-name": "vnfc8",
+ "model-version": "1.1",
+ "resource-version": "1563820652380"
+ }
+ },
+ {
+ "model": {
+ "model-invariant-id": "modelInvariantValue-369-as988q",
+ "model-type": "service",
+ "resource-version": "1563820652072",
+ "model-vers": {
+ "model-ver": [
+ {
+ "model-version-id": "modelVersionKey-369-as988q",
+ "model-name": "vnfc8",
+ "model-version": "1.1",
+ "resource-version": "1563820652380"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "generic-vnf": {
+ "vnf-id": "test-gvnf1-369-as988q",
+ "vnf-name": "test-name-gvnf-369",
+ "vnf-type": "SW",
+ "service-id": "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4",
+ "equipment-role": "UCPE",
+ "orchestration-status": "created",
+ "ipv4-oam-address": "12.80.1.18",
+ "nm-lan-v6-address": "2001:1890:e00e:fffe::33c4",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1563820654296",
+ "model-invariant-id": "modelInvariantValue-369-as988q",
+ "model-version-id": "modelVersionKey-369-as988q",
+ "nf-role": "test360",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v17/business/customers/customer/globalCustomerId1-369-as988q/service-subscriptions/service-subscription/TEST1-369/service-instances/service-instance/serviceInstanceID1-369-as988q",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "globalCustomerId1-369-as988q"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "TEST1-369"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "serviceInstanceID1-369-as988q"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "EUd8Test"
+ }
+ ]
+ },
+ {
+ "related-to": "vserver",
+ "relationship-label": "tosca.relationships.HostedOn",
+ "related-link": "/aai/v17/cloud-infrastructure/cloud-regions/cloud-region/cloudOwnerKeyValue1-369-as988q/cloudRegionIdKeyValue1-369-as988q/tenants/tenant/tenantID1-369-as988q/vservers/vserver/vserver1-369-test-as988q",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "cloudOwnerKeyValue1-369-as988q"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "cloudRegionIdKeyValue1-369-as988q"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "tenantID1-369-as988q"
+ },
+ {
+ "relationship-key": "vserver.vserver-id",
+ "relationship-value": "vserver1-369-test-as988q"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vserver.vserver-name",
+ "property-value": "vserver-name11-369-as988q"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ {
+ "tenant": {
+ "tenant-id": "tenantID1-369-as988q",
+ "tenant-name": "tenant-name1-369-as988q",
+ "resource-version": "1563820651384",
+ "vservers": {
+ "vserver": [
+ {
+ "vserver-id": "vserver1-369-test-as988q",
+ "vserver-name": "vserver-name11-369-as988q",
+ "vserver-name2": "vserver-name22-360-as988q",
+ "prov-status": "ACTIVE",
+ "vserver-selflink": "TRINITY vserverLink",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1563820654917",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "relationship-label": "tosca.relationships.HostedOn",
+ "related-link": "/aai/v17/network/generic-vnfs/generic-vnf/test-gvnf1-369-as988q",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "test-gvnf1-369-as988q"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "test-name-gvnf-369"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "cloud-region": {
+ "cloud-owner": "cloudOwnerKeyValue1-369-as988q",
+ "cloud-region-id": "cloudRegionIdKeyValue1-369-as988q",
+ "resource-version": "1563820651058",
+ "orchestration-disabled": false,
+ "in-maint": false,
+ "tenants": {
+ "tenant": [
+ {
+ "tenant-id": "tenantID1-369-as988q",
+ "tenant-name": "tenant-name1-369-as988q",
+ "resource-version": "1563820651384"
+ }
+ ]
+ }
+ }
+ }
+ ]
+} \ No newline at end of file