aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/mso
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/mso')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java22
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java14
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/RequestDetailsTest.java63
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java108
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/AsyncRequestStatusTest.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java14
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java14
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestIdTest.java)104
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedModelTest.java93
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java8
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestTest.java2
13 files changed, 172 insertions, 284 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
index 718e22fb4..8a821c27a 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
@@ -22,6 +22,7 @@ package org.onap.vid.mso;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,7 +42,6 @@ import org.togglz.core.manager.FeatureManager;
import java.io.IOException;
import java.net.URL;
-import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
@@ -206,7 +206,7 @@ public class MsoBusinessLogicImplTest {
String vnfEndpoint = String.format(endpointTemplate, serviceInstanceId, vnfInstanceId);
org.onap.vid.changeManagement.RequestDetails requestDetails = readRequest(
"scaleOutVfModulePayload.json");
- org.onap.vid.changeManagement.RequestDetailsWrapper expectedRequest = readExpectedRequest(
+ org.onap.vid.changeManagement.RequestDetailsWrapper<org.onap.vid.changeManagement.RequestDetails> expectedRequest = readExpectedRequest(
"scaleOutVfModulePayloadToMso.json");
MsoResponseWrapper expectedMsoResponseWrapper = createOkResponse();
given(
@@ -229,7 +229,7 @@ public class MsoBusinessLogicImplTest {
return objectMapper.readValue(url, org.onap.vid.changeManagement.RequestDetails.class);
}
- private org.onap.vid.changeManagement.RequestDetailsWrapper readExpectedRequest(String requestJsonFilename)
+ private org.onap.vid.changeManagement.RequestDetailsWrapper<org.onap.vid.changeManagement.RequestDetails> readExpectedRequest(String requestJsonFilename)
throws IOException {
Path path = Paths.get("payload_jsons", requestJsonFilename);
URL url = this.getClass().getClassLoader().getResource(path.toString());
@@ -252,15 +252,15 @@ public class MsoBusinessLogicImplTest {
}
@Test
- public void shouldFilterOutOrchestrationRequestsNotAllowedInDashboard() throws IOException {
+ public void shouldFilterOutOrchestrationRequestsNotAllowedInDashboard() throws Exception {
//given
String vnfModelTypeOrchestrationRequests = getFileContentAsString("mso_model_info_sample_response.json");
String scaleOutActionOrchestrationRequests = getFileContentAsString("mso_action_scaleout_sample_response.json");
MsoResponseWrapper msoResponseWrapperMock = mock(MsoResponseWrapper.class);
given(msoInterface
- .getOrchestrationRequestsForDashboard(any(String.class), any(String.class), any(String.class),
- any(RestObject.class)))
+ .getOrchestrationRequest(any(String.class), any(String.class), any(String.class),
+ any(RestObject.class), anyBoolean()))
.willReturn(msoResponseWrapperMock);
given(msoResponseWrapperMock.getEntity())
.willReturn(vnfModelTypeOrchestrationRequests, scaleOutActionOrchestrationRequests);
@@ -276,14 +276,14 @@ public class MsoBusinessLogicImplTest {
.map(el -> el.getRequestType().toUpperCase())
.collect(Collectors.toList()));
assertThat(filteredOrchestrationReqs)
- .extracting(org.onap.vid.domain.mso.Request::getRequestScope)
+ .extracting(Request::getRequestScope)
.containsOnly("vnf", "vfModule");
}
- private String getFileContentAsString(String resourceName) throws IOException {
- URL url = this.getClass().getClassLoader().getResource(".");
- Path path = Paths.get(url.getPath(), "payload_jsons", resourceName);
- return new String(Files.readAllBytes(path));
+ private String getFileContentAsString(String resourceName) throws Exception {
+ Path path = Paths.get("payload_jsons", resourceName);
+ URL url = this.getClass().getClassLoader().getResource(path.toString());
+ return IOUtils.toString(url.toURI(), "UTF-8");
}
private static class MsoRequestWrapperMatcher implements
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java
index 5c5d6fd41..b396507b8 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoOperationalEnvironmentTest.java
@@ -6,11 +6,11 @@ import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import org.apache.commons.io.IOUtils;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.controllers.OperationalEnvironmentController;
-import org.onap.vid.controllers.OperationalEnvironmentController.OperationalEnvironmentManifest;
-import org.onap.vid.mso.MsoBusinessLogic;
-import org.onap.vid.mso.MsoBusinessLogicImpl;
+import org.onap.vid.controller.OperationalEnvironmentController;
+import org.onap.vid.controller.OperationalEnvironmentController.OperationalEnvironmentManifest;
import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails;
@@ -28,10 +28,10 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-@Test
public class MsoOperationalEnvironmentTest {
private MsoBusinessLogic msoBusinessLogic = new MsoBusinessLogicImpl(null,null);
+ private static final Logger logger = LogManager.getLogger(MsoOperationalEnvironmentTest.class);
@Test(dataProvider = "getOperationalEnvironmentActivationPermutations")
public void testJsonResultOfOperationalEnvironmentActivationRequestDetails(HashMap<String, String> permutation) throws IOException {
@@ -170,8 +170,8 @@ public class MsoOperationalEnvironmentTest {
try {
JSONAssert.assertEquals("built mso request is not ok", expected, requestDetailsAsString, JSONCompareMode.STRICT);
} catch (AssertionError | Exception e) {
- System.out.println("requestDetailsAsString: \n" + requestDetailsAsString);
- System.out.println("expected: \n" + expected);
+ logger.info("requestDetailsAsString: \n" + requestDetailsAsString);
+ logger.info("expected: \n" + expected);
throw e;
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/RequestDetailsTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/RequestDetailsTest.java
new file mode 100644
index 000000000..9d773d73c
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/RequestDetailsTest.java
@@ -0,0 +1,63 @@
+package org.onap.vid.mso;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.onap.vid.exceptions.NotFoundException;
+import org.onap.vid.mso.rest.RequestDetails;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.assertEquals;
+
+public class RequestDetailsTest {
+
+ private static final ImmutableList<String> LCP_CLOUD_REGION_ID_PATH = ImmutableList.of("requestDetails", "cloudConfiguration", "lcpCloudRegionId");
+
+ @DataProvider
+ public static Object[][] extractValueByPathDataProvider() {
+
+ RequestDetails requestDetails1 = new RequestDetails();
+ Map cloudConfiguration = ImmutableMap.of("lcpCloudRegionId", "lcp1");
+ requestDetails1.setAdditionalProperty("requestDetails",
+ ImmutableMap.of("cloudConfiguration", cloudConfiguration));
+
+
+ return new Object[][] {
+ { requestDetails1, LCP_CLOUD_REGION_ID_PATH, String.class, "lcp1" },
+ { requestDetails1, ImmutableList.of("requestDetails", "cloudConfiguration"), Map.class, cloudConfiguration },
+
+ };
+ }
+
+ @Test(dataProvider = "extractValueByPathDataProvider")
+ public void testExtractValueByPath(RequestDetails requestDetails, List<String> keys, Class clz, Object expectedValue) {
+ assertEquals(expectedValue, requestDetails.extractValueByPathUsingAdditionalProperties(keys, clz));
+ }
+
+ @DataProvider
+ public static Object[][] extractValueByPathDataProviderThrowException() {
+ RequestDetails requestDetails1 = new RequestDetails();
+ requestDetails1.setAdditionalProperty("requestDetails",
+ ImmutableMap.of("cloudConfiguration", "notMap"));
+
+ RequestDetails requestDetails2 = new RequestDetails();
+ requestDetails2.setAdditionalProperty("requestDetails",
+ ImmutableMap.of("cloudConfiguration", Collections.EMPTY_MAP));
+
+ return new Object[][] {
+ { new RequestDetails(), LCP_CLOUD_REGION_ID_PATH, String.class},
+ { requestDetails1, LCP_CLOUD_REGION_ID_PATH, String.class},
+ { requestDetails1, ImmutableList.of("requestDetails", "abc"), String.class},
+ { requestDetails2, LCP_CLOUD_REGION_ID_PATH, String.class},
+ };
+ }
+
+ @Test(dataProvider = "extractValueByPathDataProviderThrowException", expectedExceptions = NotFoundException.class)
+ public void testExtractValueByPathThrowException(RequestDetails requestDetails, List<String> keys, Class clz) {
+ requestDetails.extractValueByPathUsingAdditionalProperties(keys, clz);
+ }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java
deleted file mode 100644
index 3bcc01d63..000000000
--- a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.onap.vid.mso;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-
-import java.util.*;
-
-import javax.ws.rs.core.MultivaluedHashMap;
-
-import org.junit.Assert;
-
-public class RestMsoImplementationTest {
-
- private RestMsoImplementation createTestSubject() {
- return new RestMsoImplementation();
- }
-
- @Test
- public void testInitMsoClient() throws Exception {
- RestMsoImplementation testSubject;
- MultivaluedHashMap<String, Object> result;
-
- // default test
- try {
- testSubject = createTestSubject();
- result = testSubject.initMsoClient();
- } catch (Exception e) {
- }
- }
-
-
- @Test
- public void testGetForObject() throws Exception {
- RestMsoImplementation testSubject;
- String sourceID = "";
- String path = "";
-
- // default test
- try {
- testSubject = createTestSubject();
- testSubject.GetForObject(sourceID, path, null);
- } catch (Exception e) {
- }
- }
-
- @Test
- public void testDelete() throws Exception {
- RestMsoImplementation testSubject;
- String sourceID = "";
- String path = "";
-
- // default test
- try {
- testSubject = createTestSubject();
- testSubject.Delete(null, null, sourceID, path, null);
- } catch (Exception e) {
- }
- }
-
- @Test
- public void testPostForObject() throws Exception {
- RestMsoImplementation testSubject;
- Object requestDetails = null;
- String sourceID = "";
- String path = "";
-
- // default test
- try {
- testSubject = createTestSubject();
- testSubject.PostForObject(requestDetails, sourceID, path, null);
- } catch (
-
- Exception e) {
- }
- }
-
-
-
- @Test
- public void testPrepareClient() throws Exception {
- RestMsoImplementation testSubject;
- String path = "";
- String methodName = "";
-
- // default test
- try {
- testSubject = createTestSubject();
- testSubject.prepareClient(path, methodName);
- } catch (
-
- Exception e) {
- }
- }
-
-
-
-
- // @Test
- // public void testInitMsoClient() throws Exception {
- // RestMsoImplementation testSubject;
- //
- // // default test
- // testSubject = createTestSubject();
- // testSubject.initMsoClient();
- // }
-
-} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java
index 9e00a7810..cac6d089e 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java
@@ -1,9 +1,9 @@
package org.onap.vid.mso.model;
import org.junit.Test;
-import org.onap.vid.controllers.OperationalEnvironmentController;
-import org.onap.vid.controllers.OperationalEnvironmentController.OperationalEnvironmentActivateBody;
-import org.onap.vid.controllers.OperationalEnvironmentController.OperationalEnvironmentManifest;
+import org.onap.vid.controller.OperationalEnvironmentController;
+import org.onap.vid.controller.OperationalEnvironmentController.OperationalEnvironmentActivateBody;
+import org.onap.vid.controller.OperationalEnvironmentController.OperationalEnvironmentManifest;
public class OperationalEnvironmentActivateInfoTest {
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/AsyncRequestStatusTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/AsyncRequestStatusTest.java
index 400a34e9b..c855be750 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/AsyncRequestStatusTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/AsyncRequestStatusTest.java
@@ -1,8 +1,6 @@
package org.onap.vid.mso.rest;
import org.junit.Test;
-import org.onap.vid.domain.mso.InstanceIds;
-import org.onap.vid.domain.mso.RequestStatus;
public class AsyncRequestStatusTest {
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 bfc82ce2a..73a3964dd 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
@@ -20,6 +20,7 @@
*/
package org.onap.vid.mso.rest;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.xebialabs.restito.server.StubServer;
import org.glassfish.grizzly.http.util.HttpStatus;
import org.junit.AfterClass;
@@ -28,8 +29,8 @@ import org.junit.Ignore;
import org.junit.Test;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.client.SyncRestClient;
-import org.onap.vid.controllers.MsoController;
-import org.onap.vid.mso.MsoInterface;
+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;
@@ -44,8 +45,8 @@ import java.nio.file.Paths;
import java.util.Properties;
import java.util.UUID;
-import static org.onap.vid.controllers.MsoController.SVC_INSTANCE_ID;
-import static org.onap.vid.controllers.MsoController.VNF_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
@ContextConfiguration(classes = {SystemProperties.class})
public class MsoRestClientNewTest {
@@ -304,7 +305,7 @@ public class MsoRestClientNewTest {
// default test
try {
testSubject = createTestSubject();
- result = testSubject.getOrchestrationRequestsForDashboard(t, sourceId, endpoint, restObject);
+ result = testSubject.getOrchestrationRequest(t, sourceId, endpoint, restObject, true);
} catch (Exception e) {
}
}
@@ -466,7 +467,8 @@ public class MsoRestClientNewTest {
}
private MsoRestClientNew msoRestClient() {
- return new MsoRestClientNew(new SyncRestClient(MsoInterface.objectMapper()), baseUrl());
+ final WebConfig webConfig = new WebConfig();
+ return new MsoRestClientNew(new SyncRestClient(webConfig.unirestFasterxmlObjectMapper(new ObjectMapper())), baseUrl());
}
private MsoRestClientNew createTestSubject() {
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
index 2b067b287..3d1937774 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
@@ -23,21 +23,19 @@ package org.onap.vid.mso.rest;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONObject;
import org.junit.Assert;
+import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.changeManagement.RequestDetails;
import org.onap.vid.client.SyncRestClient;
-import org.onap.vid.domain.mso.CloudConfiguration;
-import org.onap.vid.domain.mso.ModelInfo;
-import org.onap.vid.domain.mso.RequestInfo;
-import org.onap.vid.domain.mso.RequestParameters;
+import org.onap.vid.controller.LocalWebConfig;
import org.onap.vid.mso.MsoBusinessLogic;
import org.onap.vid.mso.MsoBusinessLogicImpl;
-import org.onap.vid.mso.rest.MsoRestClientNew;
-import org.onap.vid.controllers.LocalWebConfig;
-import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.mso.model.CloudConfiguration;
+import org.onap.vid.mso.model.ModelInfo;
+import org.onap.vid.mso.model.RequestInfo;
+import org.onap.vid.mso.model.RequestParameters;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;
import org.testng.annotations.Test;
-import org.togglz.core.manager.FeatureManager;
@ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class})
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestIdTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java
index 197bfe75d..e09ca807b 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestIdTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java
@@ -4,11 +4,11 @@ import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.mockito.*;
import org.onap.vid.aai.util.AAIRestInterface;
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.aai.util.ServletRequestHelper;
+import org.onap.vid.aai.util.SystemPropertyHelper;
import org.onap.vid.controller.filter.PromiseEcompRequestIdFilter;
-import org.onap.vid.mso.RestMsoImplementation;
-import org.onap.vid.mso.RestObject;
import org.onap.vid.testUtils.TestUtils;
+import org.onap.vid.utils.Unchecked;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@@ -22,6 +22,7 @@ import javax.ws.rs.client.Client;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.core.MultivaluedMap;
import java.util.Set;
+import java.util.UUID;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -29,24 +30,31 @@ import java.util.stream.Stream;
import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
+import static org.mockito.Mockito.when;
-public class OutgoingRequestIdTest {
+public class OutgoingRequestHeadersTest {
- @InjectMocks
- private RestMsoImplementation restMsoImplementation;
+// @InjectMocks
+// private RestMsoImplementation restMsoImplementation;
+
+ @Mock
+ private SystemPropertyHelper systemPropertyHelper;
+
+ @Mock
+ private ServletRequestHelper servletRequestHelper;
@InjectMocks
private AAIRestInterface aaiRestInterface;
-
@Captor
private ArgumentCaptor<MultivaluedMap<String, Object>> multivaluedMapArgumentCaptor;
@BeforeClass
public void initMocks() {
MockitoAnnotations.initMocks(this);
+ when(servletRequestHelper.extractOrGenerateRequestId()).thenAnswer(invocation -> UUID.randomUUID().toString());
}
@BeforeMethod
@@ -54,47 +62,62 @@ public class OutgoingRequestIdTest {
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes((HttpServletRequest) PromiseEcompRequestIdFilter.wrapIfNeeded(new MockHttpServletRequest())));
}
- @DataProvider
- public Object[][] msoMethods() {
- return Stream.<ThrowingConsumer<RestMsoImplementation>>of(
-
- client -> client.Get(new Object(), "whatever source id", "/any path", new RestObject<>()),
- client -> client.GetForObject("whatever source id", "/any path", Object.class),
- client -> client.Post(new Object(), "some payload", "whatever source id", "/any path", new RestObject<>()),
- client -> client.PostForObject("some payload", "whatever source id", "/any path", Object.class),
- client -> client.Put(Object.class, new RequestDetailsWrapper(), "whatever source id", "/any path", new RestObject<>())
-
- ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{});
- }
-
- @Test(dataProvider = "msoMethods")
- public void mso(Consumer<RestMsoImplementation> f) throws Exception {
- final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(restMsoImplementation);
-
- f.accept(restMsoImplementation);
-
- verifyRequestIdHeaderWasAdded(mocks.getFakeBuilder());
- }
+// @DataProvider
+// public Object[][] msoMethods() {
+// return Stream.<ThrowingConsumer<RestMsoImplementation>>of(
+//
+// client -> client.Get(new Object(), "/any path", new RestObject<>(), false),
+// client -> client.GetForObject("/any path", Object.class),
+// client -> client.Post("", "some payload", "/any path", new RestObject<>()),
+// client -> client.PostForObject("some payload", "/any path", Object.class),
+// client -> client.Put(Object.class, new RequestDetailsWrapper(), "/any path", new RestObject<>())
+//
+// ).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{});
+// }
+//
+// @Test(dataProvider = "msoMethods")
+// public void mso(Consumer<RestMsoImplementation> f) throws Exception {
+// final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(restMsoImplementation);
+//
+// f.accept(restMsoImplementation);
+//
+// Invocation.Builder fakeBuilder = mocks.getFakeBuilder();
+// Object requestIdValue = verifyXEcompRequestIdHeaderWasAdded(fakeBuilder);
+// assertEquals(requestIdValue, captureHeaderKeyAndReturnItsValue(fakeBuilder, "X-ONAP-RequestID"));
+//
+// assertThat((String) captureHeaderKeyAndReturnItsValue(fakeBuilder, "Authorization"), startsWith("Basic "));
+// assertThat(captureHeaderKeyAndReturnItsValue(fakeBuilder, "X-ONAP-PartnerName"), equalTo("VID"));
+// }
+//
+// @Test
+// public void whenProvideMsoRestCallUserId_builderHasXRequestorIDHeader() throws Exception {
+//
+// final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(restMsoImplementation);
+// String randomUserName = randomAlphabetic(10);
+//
+// restMsoImplementation.restCall(HttpMethod.DELETE, String.class, null, "abc", Optional.of(randomUserName));
+// assertEquals(randomUserName, captureHeaderKeyAndReturnItsValue(mocks.getFakeBuilder(), "X-RequestorID"));
+// }
@DataProvider
public Object[][] aaiMethods() {
return Stream.<ThrowingConsumer<AAIRestInterface>>of(
- client -> client.RestGet("from app id", "some transId", "/any path", false),
+ client -> client.RestGet("from app id", "some transId", Unchecked.toURI("/any path"), false),
client -> client.Delete("whatever source id", "some transId", "/any path"),
client -> client.RestPost("from app id", "/any path", "some payload", false),
- client -> client.RestPut("from app id", "/any path", "some payload", false)
+ client -> client.RestPut("from app id", "/any path", "some payload", false, false)
).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{});
}
- //@Test(dataProvider = "aaiMethods")
+ @Test(dataProvider = "aaiMethods")
public void aai(Consumer<AAIRestInterface> f) throws Exception {
final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(aaiRestInterface);
f.accept(aaiRestInterface);
- verifyRequestIdHeaderWasAdded(mocks.getFakeBuilder());
+ verifyXEcompRequestIdHeaderWasAdded(mocks.getFakeBuilder());
}
// @Test(dataProvider = "schedulerMethods")
@@ -107,10 +130,17 @@ public class OutgoingRequestIdTest {
//
// }
- private void verifyRequestIdHeaderWasAdded(Invocation.Builder fakeBuilder) {
+ private Object verifyXEcompRequestIdHeaderWasAdded(Invocation.Builder fakeBuilder) {
final String requestIdHeader = "x-ecomp-requestid";
final String uuidRegex = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
+ Object requestId = captureHeaderKeyAndReturnItsValue(fakeBuilder, requestIdHeader);
+
+ assertThat("header '" + requestIdHeader + "' should be a uuid", requestId,
+ allOf(instanceOf(String.class), hasToString(matchesPattern(uuidRegex))));
+ return requestId;
+ }
+ private Object captureHeaderKeyAndReturnItsValue(Invocation.Builder fakeBuilder, String headerName) {
// Checks that the builder was called with either one of header("x-ecomp-requestid", uuid)
// or the plural brother: headers(Map.of("x-ecomp-requestid", Set.of(uuid))
@@ -121,7 +151,7 @@ public class OutgoingRequestIdTest {
ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class);
Mockito.verify(fakeBuilder)
.header(
- Matchers.argThat(s -> equalsIgnoreCase(s, requestIdHeader)),
+ Matchers.argThat(s -> equalsIgnoreCase(s, headerName)),
argumentCaptor.capture()
);
requestId = argumentCaptor.getValue();
@@ -130,14 +160,12 @@ public class OutgoingRequestIdTest {
Mockito.verify(fakeBuilder).headers(multivaluedMapArgumentCaptor.capture());
final MultivaluedMap<String, Object> headersMap = multivaluedMapArgumentCaptor.getValue();
- final String thisRequestIdHeader = getFromSetCaseInsensitive(headersMap.keySet(), requestIdHeader);
+ final String thisRequestIdHeader = getFromSetCaseInsensitive(headersMap.keySet(), headerName);
assertThat(headersMap.keySet(), hasItem(thisRequestIdHeader));
requestId = headersMap.getFirst(thisRequestIdHeader);
}
-
- assertThat("header '" + requestIdHeader + "' should be a uuid", requestId,
- allOf(instanceOf(String.class), hasToString(matchesPattern(uuidRegex))));
+ return requestId;
}
private String getFromSetCaseInsensitive(Set<String> set, String key) {
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java
index 4b35430e0..1bedc1918 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java
@@ -1,9 +1,9 @@
package org.onap.vid.mso.rest;
-import java.util.Map;
-
import org.junit.Test;
-import org.onap.vid.domain.mso.ModelInfo;
+import org.onap.vid.mso.model.ModelInfo;
+
+import java.util.Map;
public class RelatedInstanceTest {
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedModelTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedModelTest.java
deleted file mode 100644
index 91d61bd9f..000000000
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedModelTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.onap.vid.mso.rest;
-
-import java.util.Map;
-
-import org.junit.Test;
-import org.onap.vid.domain.mso.ModelInfo;
-
-
-public class RelatedModelTest {
-
- private RelatedModel createTestSubject() {
- return new RelatedModel();
- }
-
-
- @Test
- public void testGetModelInfo() throws Exception {
- RelatedModel testSubject;
- ModelInfo result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModelInfo();
- }
-
-
- @Test
- public void testSetModelInfo() throws Exception {
- RelatedModel testSubject;
- ModelInfo modelInfo = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setModelInfo(modelInfo);
- }
-
-
- @Test
- public void testToString() throws Exception {
- RelatedModel testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-
-
- @Test
- public void testGetAdditionalProperties() throws Exception {
- RelatedModel testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAdditionalProperties();
- }
-
-
- @Test
- public void testSetAdditionalProperty() throws Exception {
- RelatedModel testSubject;
- String name = "";
- Object value = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAdditionalProperty(name, value);
- }
-
-
- @Test
- public void testHashCode() throws Exception {
- RelatedModel testSubject;
- int result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.hashCode();
- }
-
-
- @Test
- public void testEquals() throws Exception {
- RelatedModel testSubject;
- Object other = null;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.equals(other);
- }
-} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java
index e4716d587..f6b7c584f 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java
@@ -1,11 +1,13 @@
package org.onap.vid.mso.rest;
+import org.junit.Test;
+import org.onap.vid.mso.model.CloudConfiguration;
+import org.onap.vid.mso.model.ModelInfo;
+import org.onap.vid.mso.model.RequestInfo;
+
import java.util.List;
import java.util.Map;
-import org.junit.Test;
-import org.onap.vid.domain.mso.*;
-
public class RequestDetailsTest {
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestTest.java
index f07fd1ab2..9250340a6 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestTest.java
@@ -1,8 +1,6 @@
package org.onap.vid.mso.rest;
import org.junit.Test;
-import org.onap.vid.domain.mso.InstanceIds;
-import org.onap.vid.domain.mso.RequestStatus;
public class RequestTest {