summaryrefslogtreecommitdiffstats
path: root/adapters/mso-sdnc-adapter/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-sdnc-adapter/src/test')
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java6
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java7
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/FileUtil.java6
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/ObjectFactoryTest.java62
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/SDNCAdapterRequestTest.java39
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/CallbackHeaderTest.java26
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java43
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/MapRequestTunablesTest.java179
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImplTest.java94
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCResponseTest.java66
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java6
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java46
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java22
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/ObjectMappingTest.java835
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java18
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnectorTest.java1
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/util/SDNCRequestIdUtilTest.java12
17 files changed, 702 insertions, 766 deletions
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java
index 50a661a695..a15163bbcb 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/AllTestsTestSuite.java
@@ -19,14 +19,14 @@
*/
package org.onap.so.adapters.sdnc;
-import org.junit.runner.RunWith;
+import org.junit.runner.RunWith;
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
@RunWith(WildcardPatternSuite.class)
@SuiteClasses("**/*Test.class")
public class AllTestsTestSuite {
- // the class remains empty,
- // used only as a holder for the above annotations
+ // the class remains empty,
+ // used only as a holder for the above annotations
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java
index 29921934dd..a65ddc5bb8 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java
@@ -31,7 +31,6 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
-
import com.github.tomakehurst.wiremock.WireMockServer;
@RunWith(SpringRunner.class)
@@ -41,15 +40,15 @@ import com.github.tomakehurst.wiremock.WireMockServer;
public abstract class BaseTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
-
+
@Autowired
protected WireMockServer wireMockServer;
-
+
protected TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
@Value("${wiremock.server.port}")
protected String wireMockPort;
-
+
@After
public void after() {
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/FileUtil.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/FileUtil.java
index d72775399f..114618f0b4 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/FileUtil.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/FileUtil.java
@@ -24,7 +24,6 @@ package org.onap.so.adapters.sdnc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.io.InputStream;
@@ -48,7 +47,7 @@ public class FileUtil {
stream = getResourceAsStream(fileName);
byte[] bytes;
bytes = new byte[stream.available()];
- if(stream.read(bytes) > 0) {
+ if (stream.read(bytes) > 0) {
stream.close();
return new String(bytes);
} else {
@@ -69,8 +68,7 @@ public class FileUtil {
* @throws IOException If we can't get the InputStream for whatever reason.
*/
private static InputStream getResourceAsStream(String resourceName) throws IOException {
- InputStream stream =
- FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
+ InputStream stream = FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
if (stream == null) {
throw new IOException("Can't access resource '" + resourceName + "'");
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/ObjectFactoryTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/ObjectFactoryTest.java
index 7a9b039089..4a6eb61287 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/ObjectFactoryTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/ObjectFactoryTest.java
@@ -26,17 +26,14 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
-
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.StringWriter;
import java.nio.charset.Charset;
-
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
-
import org.junit.Test;
public class ObjectFactoryTest {
@@ -48,45 +45,44 @@ public class ObjectFactoryTest {
* Test method for {@link org.onap.so.adapters.sdnc.ObjectFactory#createRequestHeader()}.
*/
@Test
- public final void testCreateRequestHeader () {
- ObjectFactory of = new ObjectFactory ();
- RequestHeader rh = of.createRequestHeader ();
- rh.setCallbackUrl ("callback");
- rh.setMsoAction ("action");
- rh.setRequestId ("reqid");
- rh.setSvcAction ("svcAction");
- rh.setSvcInstanceId ("svcId");
- rh.setSvcOperation ("op");
-
+ public final void testCreateRequestHeader() {
+ ObjectFactory of = new ObjectFactory();
+ RequestHeader rh = of.createRequestHeader();
+ rh.setCallbackUrl("callback");
+ rh.setMsoAction("action");
+ rh.setRequestId("reqid");
+ rh.setSvcAction("svcAction");
+ rh.setSvcInstanceId("svcId");
+ rh.setSvcOperation("op");
+
try {
JAXBContext jaxbContext = JAXBContext.newInstance(RequestHeader.class);
jaxbMarshaller = jaxbContext.createMarshaller();
-
+
JAXBContext jaxbContext2 = JAXBContext.newInstance(RequestHeader.class);
jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
- }
- catch (JAXBException e) {
- e.printStackTrace ();
+ } catch (JAXBException e) {
+ e.printStackTrace();
fail();
return;
}
StringWriter writer = new StringWriter();
try {
- jaxbMarshaller.marshal (rh, writer);
+ jaxbMarshaller.marshal(rh, writer);
} catch (JAXBException e) {
e.printStackTrace();
- fail ();
+ fail();
}
- String marshalled = writer.toString ();
+ String marshalled = writer.toString();
assertThat(marshalled, containsString("<RequestId>reqid</RequestId>"));
-
+
InputStream inputStream = new ByteArrayInputStream(marshalled.getBytes(Charset.forName("UTF-8")));
try {
- RequestHeader res2 = (RequestHeader) jaxbUnmarshaller.unmarshal (inputStream);
- assertEquals("callback", res2.getCallbackUrl ());
- assertEquals("action", res2.getMsoAction ());
- assertEquals("op", res2.getSvcOperation ());
+ RequestHeader res2 = (RequestHeader) jaxbUnmarshaller.unmarshal(inputStream);
+ assertEquals("callback", res2.getCallbackUrl());
+ assertEquals("action", res2.getMsoAction());
+ assertEquals("op", res2.getSvcOperation());
} catch (JAXBException e) {
e.printStackTrace();
fail();
@@ -97,17 +93,17 @@ public class ObjectFactoryTest {
* Test method for {@link org.onap.so.adapters.sdnc.ObjectFactory#createSDNCAdapterResponse()}.
*/
@Test
- public final void testCreateSDNCAdapterResponse () {
- ObjectFactory of = new ObjectFactory ();
- SDNCAdapterResponse ar = of.createSDNCAdapterResponse ();
+ public final void testCreateSDNCAdapterResponse() {
+ ObjectFactory of = new ObjectFactory();
+ SDNCAdapterResponse ar = of.createSDNCAdapterResponse();
assertNotNull(ar);
}
-
+
@Test
- public final void testCreateSDNCAdapterRequest () {
- ObjectFactory of = new ObjectFactory ();
- SDNCAdapterRequest ar = of.createSDNCAdapterRequest ();
+ public final void testCreateSDNCAdapterRequest() {
+ ObjectFactory of = new ObjectFactory();
+ SDNCAdapterRequest ar = of.createSDNCAdapterRequest();
assertNotNull(ar);
}
-
+
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/SDNCAdapterRequestTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/SDNCAdapterRequestTest.java
index e0a1982db1..ce3a55470b 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/SDNCAdapterRequestTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/SDNCAdapterRequestTest.java
@@ -23,7 +23,6 @@ package org.onap.so.adapters.sdnc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.so.adapters.sdnc.SDNCAdapterRequest;
@@ -32,26 +31,26 @@ import org.onap.so.adapters.sdnc.RequestHeader;
public class SDNCAdapterRequestTest {
- static Object sd= new SDNCAdapterRequest();
- static RequestHeader rh=new RequestHeader();
-
- @BeforeClass
- public static final void RHeader()
- {
- rh.setCallbackUrl("callback");
- rh.setMsoAction ("action");
- rh.setRequestId ("reqid");
- rh.setSvcAction ("svcAction");
- rh.setSvcInstanceId ("svcId");
- rh.setSvcOperation ("op");
- }
- @Test
- public final void testtoString(){
- ((SDNCAdapterRequest) sd).setRequestData("data");
- ((SDNCAdapterRequest) sd).setRequestHeader(rh);
- assertNotNull(((SDNCAdapterRequest) sd).getRequestData()) ;
+ static Object sd = new SDNCAdapterRequest();
+ static RequestHeader rh = new RequestHeader();
+
+ @BeforeClass
+ public static final void RHeader() {
+ rh.setCallbackUrl("callback");
+ rh.setMsoAction("action");
+ rh.setRequestId("reqid");
+ rh.setSvcAction("svcAction");
+ rh.setSvcInstanceId("svcId");
+ rh.setSvcOperation("op");
+ }
+
+ @Test
+ public final void testtoString() {
+ ((SDNCAdapterRequest) sd).setRequestData("data");
+ ((SDNCAdapterRequest) sd).setRequestHeader(rh);
+ assertNotNull(((SDNCAdapterRequest) sd).getRequestData());
assertEquals("data", ((SDNCAdapterRequest) sd).getRequestData());
assertEquals(rh, ((SDNCAdapterRequest) sd).getRequestHeader());
- }
+ }
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/CallbackHeaderTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/CallbackHeaderTest.java
index dbb5c9aa44..6ad340921f 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/CallbackHeaderTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/CallbackHeaderTest.java
@@ -1,28 +1,22 @@
/*
-* ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 TechMahindra
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright (C) 2018 TechMahindra
+ * ================================================================================ Licensed under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy
+ * of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
* ============LICENSE_END=========================================================
-*/
+ */
package org.onap.so.adapters.sdnc.client;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import org.junit.Test;
public class CallbackHeaderTest {
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java
index d7f4f8e6f7..35a505d844 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java
@@ -23,35 +23,32 @@ package org.onap.so.adapters.sdnc.client;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import org.junit.Test;
import org.onap.so.adapters.sdnc.client.CallbackHeader;
import org.onap.so.adapters.sdnc.client.SDNCAdapterCallbackRequest;
public class SDNCAdapterCallbackRequestTest {
- static SDNCAdapterCallbackRequest sdc = new SDNCAdapterCallbackRequest();
- static CallbackHeader ch = new CallbackHeader("413658f4-7f42-482e-b834-23a5c15657da-1474471336781","200","OK");
-
- @Test
- public void testSDNCAdapterCallbackRequest()
- {
- sdc.setCallbackHeader(ch);
- sdc.setRequestData("data");
- assertNotNull(sdc.getCallbackHeader());
- assertNotNull(sdc.getRequestData());
- assertEquals(ch, sdc.getCallbackHeader());
- assertEquals("data", sdc.getRequestData());
-
- }
-
- @Test
- public void testtoString()
- {
- assertNotNull(ch.toString());
- assertNotNull(sdc.toString());
- }
-
+ static SDNCAdapterCallbackRequest sdc = new SDNCAdapterCallbackRequest();
+ static CallbackHeader ch = new CallbackHeader("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", "200", "OK");
+
+ @Test
+ public void testSDNCAdapterCallbackRequest() {
+ sdc.setCallbackHeader(ch);
+ sdc.setRequestData("data");
+ assertNotNull(sdc.getCallbackHeader());
+ assertNotNull(sdc.getRequestData());
+ assertEquals(ch, sdc.getCallbackHeader());
+ assertEquals("data", sdc.getRequestData());
+
+ }
+
+ @Test
+ public void testtoString() {
+ assertNotNull(ch.toString());
+ assertNotNull(sdc.toString());
+ }
+
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/MapRequestTunablesTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/MapRequestTunablesTest.java
index cd93f6e71b..cab2e27252 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/MapRequestTunablesTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/MapRequestTunablesTest.java
@@ -22,7 +22,6 @@ package org.onap.so.adapters.sdnc.impl;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.sdnc.SDNCAdapterApplication;
@@ -35,94 +34,94 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest(classes = SDNCAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
public class MapRequestTunablesTest {
-
- @Autowired
- private MapRequestTunables tunableMapper;
-
- @Test
- public void test_setTunables(){
- RequestTunables expectedResult = new RequestTunables("testReqId", "","vnf-topology-operation","assign");
- expectedResult.setAsyncInd("N");
- expectedResult.setSdncUrl("https://localhost:8443/restconf/operations/VNF-API:vnf-topology-operation");
- expectedResult.setTimeout("270000");
- expectedResult.setReqMethod("POST");
- expectedResult.setHeaderName("sdnc-request-header");
- expectedResult.setNamespace("org:openecomp:sdnctl:vnf");
-
- RequestTunables testMapper = new RequestTunables("testReqId", "","vnf-topology-operation","assign");
-
- RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
-
- assertThat(mappedTunable, sameBeanAs(expectedResult));
- }
-
- @Test
- public void test_setTunables_EmptyOperation_EmptyMSOAction(){
- RequestTunables expectedResult = new RequestTunables("testReqId", "","","query");
- expectedResult.setAsyncInd("N");
- expectedResult.setSdncUrl("http://localhost:8443/restconf/operations/GENERIC-RESOURCE-API:");
- expectedResult.setTimeout("60000");
- expectedResult.setReqMethod("GET");
- expectedResult.setHeaderName("sdnc-request-header");
- expectedResult.setNamespace("");
-
- RequestTunables testMapper = new RequestTunables("testReqId", "","","query");
-
- RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
-
- assertThat(mappedTunable, sameBeanAs(expectedResult));
- }
-
- @Test
- public void test_setTunables_EmptyOperation(){
- RequestTunables expectedResult = new RequestTunables("testReqId", "infra","","query");
- expectedResult.setAsyncInd("N");
- expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
- expectedResult.setTimeout("60000");
- expectedResult.setReqMethod("GET");
- expectedResult.setHeaderName("sdnc-request-header");
- expectedResult.setNamespace("");
-
- RequestTunables testMapper = new RequestTunables("testReqId", "infra","","query");
-
- RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
-
- assertThat(mappedTunable, sameBeanAs(expectedResult));
- }
-
- @Test
- public void test_setTunables_EmptyOperation_EmptyMSOActionPUT(){
- RequestTunables expectedResult = new RequestTunables("testReqId", "","","put");
- expectedResult.setAsyncInd("N");
- expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
- expectedResult.setTimeout("60000");
- expectedResult.setReqMethod("PUT");
- expectedResult.setHeaderName("sdnc-request-header");
- expectedResult.setNamespace("");
-
- RequestTunables testMapper = new RequestTunables("testReqId", "","","put");
-
- RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
-
- assertThat(mappedTunable, sameBeanAs(expectedResult));
- }
-
-
- @Test
- public void test_setTunables_EmptyOperation_EmptyMSOActionRESTDELETE(){
- RequestTunables expectedResult = new RequestTunables("testReqId", "","","restdelete");
- expectedResult.setAsyncInd("N");
- expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
- expectedResult.setTimeout("60000");
- expectedResult.setReqMethod("DELETE");
- expectedResult.setHeaderName("sdnc-request-header");
- expectedResult.setNamespace("");
-
- RequestTunables testMapper = new RequestTunables("testReqId", "","","restdelete");
-
- RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
-
- assertThat(mappedTunable, sameBeanAs(expectedResult));
- }
+
+ @Autowired
+ private MapRequestTunables tunableMapper;
+
+ @Test
+ public void test_setTunables() {
+ RequestTunables expectedResult = new RequestTunables("testReqId", "", "vnf-topology-operation", "assign");
+ expectedResult.setAsyncInd("N");
+ expectedResult.setSdncUrl("https://localhost:8443/restconf/operations/VNF-API:vnf-topology-operation");
+ expectedResult.setTimeout("270000");
+ expectedResult.setReqMethod("POST");
+ expectedResult.setHeaderName("sdnc-request-header");
+ expectedResult.setNamespace("org:openecomp:sdnctl:vnf");
+
+ RequestTunables testMapper = new RequestTunables("testReqId", "", "vnf-topology-operation", "assign");
+
+ RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
+
+ assertThat(mappedTunable, sameBeanAs(expectedResult));
+ }
+
+ @Test
+ public void test_setTunables_EmptyOperation_EmptyMSOAction() {
+ RequestTunables expectedResult = new RequestTunables("testReqId", "", "", "query");
+ expectedResult.setAsyncInd("N");
+ expectedResult.setSdncUrl("http://localhost:8443/restconf/operations/GENERIC-RESOURCE-API:");
+ expectedResult.setTimeout("60000");
+ expectedResult.setReqMethod("GET");
+ expectedResult.setHeaderName("sdnc-request-header");
+ expectedResult.setNamespace("");
+
+ RequestTunables testMapper = new RequestTunables("testReqId", "", "", "query");
+
+ RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
+
+ assertThat(mappedTunable, sameBeanAs(expectedResult));
+ }
+
+ @Test
+ public void test_setTunables_EmptyOperation() {
+ RequestTunables expectedResult = new RequestTunables("testReqId", "infra", "", "query");
+ expectedResult.setAsyncInd("N");
+ expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
+ expectedResult.setTimeout("60000");
+ expectedResult.setReqMethod("GET");
+ expectedResult.setHeaderName("sdnc-request-header");
+ expectedResult.setNamespace("");
+
+ RequestTunables testMapper = new RequestTunables("testReqId", "infra", "", "query");
+
+ RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
+
+ assertThat(mappedTunable, sameBeanAs(expectedResult));
+ }
+
+ @Test
+ public void test_setTunables_EmptyOperation_EmptyMSOActionPUT() {
+ RequestTunables expectedResult = new RequestTunables("testReqId", "", "", "put");
+ expectedResult.setAsyncInd("N");
+ expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
+ expectedResult.setTimeout("60000");
+ expectedResult.setReqMethod("PUT");
+ expectedResult.setHeaderName("sdnc-request-header");
+ expectedResult.setNamespace("");
+
+ RequestTunables testMapper = new RequestTunables("testReqId", "", "", "put");
+
+ RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
+
+ assertThat(mappedTunable, sameBeanAs(expectedResult));
+ }
+
+
+ @Test
+ public void test_setTunables_EmptyOperation_EmptyMSOActionRESTDELETE() {
+ RequestTunables expectedResult = new RequestTunables("testReqId", "", "", "restdelete");
+ expectedResult.setAsyncInd("N");
+ expectedResult.setSdncUrl("https://localhost:8443/restconf/config");
+ expectedResult.setTimeout("60000");
+ expectedResult.setReqMethod("DELETE");
+ expectedResult.setHeaderName("sdnc-request-header");
+ expectedResult.setNamespace("");
+
+ RequestTunables testMapper = new RequestTunables("testReqId", "", "", "restdelete");
+
+ RequestTunables mappedTunable = tunableMapper.setTunables(testMapper);
+
+ assertThat(mappedTunable, sameBeanAs(expectedResult));
+ }
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImplTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImplTest.java
index 8f73c02285..6370bb4831 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImplTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImplTest.java
@@ -21,11 +21,9 @@
package org.onap.so.adapters.sdnc.impl;
import static org.junit.Assert.fail;
-
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -36,7 +34,6 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.sdnc.RequestHeader;
@@ -53,26 +50,28 @@ import org.xml.sax.SAXException;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SDNCAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles({"test","non-async"})
+@ActiveProfiles({"test", "non-async"})
public class SDNCAdapterPortTypeImplTest {
- @Autowired
- private SDNCAdapterPortType sdncAdapter;
-
-
- SDNCAdapterRequest sdncAdapterRequest;
-
- public void setupTestEntities() throws ParserConfigurationException, SAXException, IOException, TransformerException {
- buildTestRequest();
- }
+ @Autowired
+ private SDNCAdapterPortType sdncAdapter;
+
+
+ SDNCAdapterRequest sdncAdapterRequest;
+
+ public void setupTestEntities()
+ throws ParserConfigurationException, SAXException, IOException, TransformerException {
+ buildTestRequest();
+ }
- private void buildTestRequest() throws ParserConfigurationException, SAXException, IOException, TransformerException {
- sdncAdapterRequest= new SDNCAdapterRequest();
- File fXmlFile = new File("src/test/resources/sdncTestPayload.xml");
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
- Document doc = dBuilder.parse(fXmlFile);
- StringWriter sw = new StringWriter();
+ private void buildTestRequest()
+ throws ParserConfigurationException, SAXException, IOException, TransformerException {
+ sdncAdapterRequest = new SDNCAdapterRequest();
+ File fXmlFile = new File("src/test/resources/sdncTestPayload.xml");
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+ Document doc = dBuilder.parse(fXmlFile);
+ StringWriter sw = new StringWriter();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
@@ -81,31 +80,32 @@ public class SDNCAdapterPortTypeImplTest {
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.transform(new DOMSource(doc), new StreamResult(sw));
- System.out.println(sw.toString());
- sdncAdapterRequest.setRequestData(sw.toString());
- RequestHeader requestHeader = new RequestHeader();
- requestHeader.setCallbackUrl("http://localhost:9090/callback");
- requestHeader.setMsoAction("gammainternet");
- requestHeader.setRequestId("testReqId");
- requestHeader.setSvcAction("assign");
- requestHeader.setSvcInstanceId("servInstanceId");
- requestHeader.setSvcOperation("svc-topology-operation");
- sdncAdapterRequest.setRequestHeader(requestHeader );
- }
-
-
-
- @Test
- public void sendRequest() throws ParserConfigurationException, SAXException, IOException, TransformerException {
- // Given
- setupTestEntities();
-
- // When
- SDNCAdapterResponse response = sdncAdapter.sdncAdapter(sdncAdapterRequest);
- if(response ==null)
- fail("Null infraRequest");
-
- // Then
- //assertThat(infraRequest, sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime"));
- }
+ System.out.println(sw.toString());
+ sdncAdapterRequest.setRequestData(sw.toString());
+ RequestHeader requestHeader = new RequestHeader();
+ requestHeader.setCallbackUrl("http://localhost:9090/callback");
+ requestHeader.setMsoAction("gammainternet");
+ requestHeader.setRequestId("testReqId");
+ requestHeader.setSvcAction("assign");
+ requestHeader.setSvcInstanceId("servInstanceId");
+ requestHeader.setSvcOperation("svc-topology-operation");
+ sdncAdapterRequest.setRequestHeader(requestHeader);
+ }
+
+
+
+ @Test
+ public void sendRequest() throws ParserConfigurationException, SAXException, IOException, TransformerException {
+ // Given
+ setupTestEntities();
+
+ // When
+ SDNCAdapterResponse response = sdncAdapter.sdncAdapter(sdncAdapterRequest);
+ if (response == null)
+ fail("Null infraRequest");
+
+ // Then
+ // assertThat(infraRequest,
+ // sameBeanAs(testRequest).ignoring("requestBody").ignoring("endTime").ignoring("startTime").ignoring("modifyTime"));
+ }
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCResponseTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCResponseTest.java
index 498fa3fa6d..a69589ac28 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCResponseTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCResponseTest.java
@@ -1,49 +1,41 @@
/*
-* ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 TechMahindra
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright (C) 2018 TechMahindra
+ * ================================================================================ Licensed under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy
+ * of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
* ============LICENSE_END=========================================================
-*/
+ */
package org.onap.so.adapters.sdnc.impl;
import static org.junit.Assert.*;
-
import org.junit.Test;
public class SDNCResponseTest {
-
- private SDNCResponse sdncresponse = new SDNCResponse(null, 0, null);
-
- @Test
- public void testSDNCResponse()
- {
- sdncresponse.setReqId("reqId");
- sdncresponse.setRespCode(0);
- sdncresponse.setRespMsg("respMsg");
- sdncresponse.setSdncRespXml("sdncRespXml");
- assertEquals(sdncresponse.getReqId(), "reqId");
- assertEquals(sdncresponse.getRespCode(), 0);
- assertEquals(sdncresponse.getRespMsg(), "respMsg");
- assertEquals(sdncresponse.getSdncRespXml(),"sdncRespXml");
+
+ private SDNCResponse sdncresponse = new SDNCResponse(null, 0, null);
+
+ @Test
+ public void testSDNCResponse() {
+ sdncresponse.setReqId("reqId");
+ sdncresponse.setRespCode(0);
+ sdncresponse.setRespMsg("respMsg");
+ sdncresponse.setSdncRespXml("sdncRespXml");
+ assertEquals(sdncresponse.getReqId(), "reqId");
+ assertEquals(sdncresponse.getRespCode(), 0);
+ assertEquals(sdncresponse.getRespMsg(), "respMsg");
+ assertEquals(sdncresponse.getSdncRespXml(), "sdncRespXml");
+ }
+
+ @Test
+ public void testtoString() {
+ assertNotNull(sdncresponse.toString());
}
-
- @Test
- public void testtoString()
- {
- assertNotNull(sdncresponse.toString());
- }
}
-
+
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java
index 76dd003883..b9d8d8df63 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java
@@ -27,7 +27,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.adapters.sdnc.BaseTest;
@@ -47,8 +46,9 @@ public class SDNCRestClientTest extends BaseTest {
rt.setReqMethod("POST");
rt.setSdncUrl("http://localhost:" + wireMockPort + "/sdnc");
- wireMockServer.stubFor(post(urlPathEqualTo("/sdnc"))
- .willReturn(aResponse().withHeader("Content-Type", "application/xml").withBody("").withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
+ wireMockServer.stubFor(
+ post(urlPathEqualTo("/sdnc")).willReturn(aResponse().withHeader("Content-Type", "application/xml")
+ .withBody("").withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
SDNCResponse response = sdncClient.getSdncResp("", rt);
assertNotNull(response);
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java
index 596f26caa6..4a3db26443 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java
@@ -31,34 +31,34 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
public class UtilsTest {
-
+
@Test
- public final void testUnmarshal () {
-
- String expectedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><feature-list xmlns=\"com:att:sdnctl:l3api\"><feature-type>FIREWALL-LITE</feature-type><feature-instance-id>mtjnj40evbc0eceb</feature-instance-id><feature-sub-type>SHARED</feature-sub-type><feature-instance-xpath>/restconf/config/Firewall-API:feature-model/feature-list/FIREWALL-LITE/mtjnj40evbc0eceb/</feature-instance-xpath> </feature-list>";
-
- try {
+ public final void testUnmarshal() {
+
+ String expectedXml =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><feature-list xmlns=\"com:att:sdnctl:l3api\"><feature-type>FIREWALL-LITE</feature-type><feature-instance-id>mtjnj40evbc0eceb</feature-instance-id><feature-sub-type>SHARED</feature-sub-type><feature-instance-xpath>/restconf/config/Firewall-API:feature-model/feature-list/FIREWALL-LITE/mtjnj40evbc0eceb/</feature-instance-xpath> </feature-list>";
+
+ try {
+
+ File file = new File("src/test/resources/sdncBpmnAdiodFirewallRequest.xml");
+ JAXBContext jaxbContext = JAXBContext.newInstance(SDNCAdapterRequest.class);
+
+ Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
+ SDNCAdapterRequest request = (SDNCAdapterRequest) jaxbUnmarshaller.unmarshal(file);
- File file = new File("src/test/resources/sdncBpmnAdiodFirewallRequest.xml");
- JAXBContext jaxbContext = JAXBContext.newInstance(SDNCAdapterRequest.class);
+ RequestTunables rt = new RequestTunables("0460ba40-60c8-4b07-8878-c8e8d87cde04-1527983610512", "",
+ "/L3SDN-API:services/layer3-service-list/MIS%2F1806%2F25057%2FSW_INTERNET/service-data/feature-list/FIREWALL-LITE/",
+ "put");
- Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
- SDNCAdapterRequest request = (SDNCAdapterRequest) jaxbUnmarshaller.unmarshal(file);
-
- RequestTunables rt = new RequestTunables("0460ba40-60c8-4b07-8878-c8e8d87cde04-1527983610512",
- "",
- "/L3SDN-API:services/layer3-service-list/MIS%2F1806%2F25057%2FSW_INTERNET/service-data/feature-list/FIREWALL-LITE/",
- "put");
+ Node node = (Node) request.getRequestData();
+ Document reqDoc = node.getOwnerDocument();
+ String sdncReqBody = Utils.genSdncPutReq(reqDoc, rt);
+ assertEquals(sdncReqBody.replaceAll("[\\t\\n\\r]+", ""), expectedXml);
- Node node = (Node) request.getRequestData();
- Document reqDoc = node.getOwnerDocument();
- String sdncReqBody = Utils.genSdncPutReq(reqDoc, rt);
- assertEquals(sdncReqBody.replaceAll("[\\t\\n\\r]+", ""), expectedXml);
+ } catch (JAXBException e) {
+ e.printStackTrace();
+ }
- } catch (JAXBException e) {
- e.printStackTrace();
- }
-
}
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java
index f8685738e0..c1bbb9ae9a 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackTest.java
@@ -25,7 +25,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.adapters.sdnc.BaseTest;
@@ -37,20 +36,19 @@ public class BPRestCallbackTest extends BaseTest {
private BPRestCallback bpRestCallback;
@Test
- public void sendTest(){
- String response = "<errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n" +
- "\t\t// <error>\n" +
- "\t\t// <error-type>protocol</error-type>\n" +
- "\t\t// <error-tag>malformed-message</error-tag>\n" +
- "\t\t// <error-message>Error parsing input: The element type \"input\" must be terminated by the matching end-tag \"&lt;/input&gt;\".</error-message>\n" +
- "\t\t// </error>\n" +
- "\t\t// </errors>";
+ public void sendTest() {
+ String response = "<errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n" + "\t\t// <error>\n"
+ + "\t\t// <error-type>protocol</error-type>\n"
+ + "\t\t// <error-tag>malformed-message</error-tag>\n"
+ + "\t\t// <error-message>Error parsing input: The element type \"input\" must be terminated by the matching end-tag \"&lt;/input&gt;\".</error-message>\n"
+ + "\t\t// </error>\n" + "\t\t// </errors>";
- wireMockServer.stubFor(post(urlPathEqualTo("/sdnc"))
- .willReturn(aResponse().withHeader("Content-Type", "application/xml").withBody(response).withStatus(HttpStatus.SC_MULTIPLE_CHOICES)));
+ wireMockServer.stubFor(
+ post(urlPathEqualTo("/sdnc")).willReturn(aResponse().withHeader("Content-Type", "application/xml")
+ .withBody(response).withStatus(HttpStatus.SC_MULTIPLE_CHOICES)));
boolean responseCommon = bpRestCallback.send("http://localhost:" + wireMockPort + "/sdnc", "Test");
assertNotNull(responseCommon);
- assertEquals(true,responseCommon);
+ assertEquals(true, responseCommon);
}
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/ObjectMappingTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/ObjectMappingTest.java
index 88849015e0..521d2bc80f 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/ObjectMappingTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/ObjectMappingTest.java
@@ -23,19 +23,16 @@ package org.onap.so.adapters.sdnc.sdncrest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
-
import org.junit.Test;
import org.onap.so.adapters.sdncrest.SDNCEvent;
import org.onap.so.adapters.sdncrest.SDNCServiceError;
import org.onap.so.adapters.sdncrest.SDNCServiceRequest;
import org.onap.so.adapters.sdncrest.SDNCServiceResponse;
-
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -46,434 +43,406 @@ import com.fasterxml.jackson.databind.SerializationFeature;
* JSON object mapping tests.
*/
public class ObjectMappingTest {
- private static final String EOL = "\n";
-
- private final String SDNC_SERVICE_REQUEST =
- "{" + EOL +
- " \"SDNCServiceRequest\": {" + EOL +
- " \"requestInformation\": {" + EOL +
- " \"requestId\": \"413658f4-7f42-482e-b834-23a5c15657da\"," + EOL +
- " \"source\": \"CCD\"," + EOL +
- " \"notificationUrl\": \"https://ccd-host:8080/notifications\"" + EOL +
- " }," + EOL +
- " \"serviceInformation\": {" + EOL +
- " \"serviceType\": \"vHNFaaS\"," + EOL +
- " \"serviceInstanceId\": \"74e65b2b637441bca078e63e44bb511b\"," + EOL +
- " \"subscriberName\": \"IST_SG_0902_3003\"," + EOL +
- " \"subscriberGlobalId\": \"IST15_0902_3003\"" + EOL +
- " }," + EOL +
- " \"bpNotificationUrl\": \"http://localhost:8080/mso/SDNCAdapterCallbackService\"," + EOL +
- "((BP-TIMEOUT))" +
- " \"sdncRequestId\": \"413658f4-7f42-482e-b834-23a5c15657da-1474471336781\"," + EOL +
- " \"sdncService\": \"vhnf\"," + EOL +
- " \"sdncOperation\": \"service-topology-cust-assign-operation\"," + EOL +
- " \"sdncServiceDataType\": \"XML\"," + EOL +
- " \"sdncServiceData\": \"<vhnf-cust-stage-information><dhv-service-instance-id>c26dfed652164d60a17461734422b085</dhv-service-instance-id><hnportal-primary-vnf-host-name>HOSTNAME</hnportal-primary-vnf-host-name></vhnf-cust-stage-information>\"" + EOL +
- " }" + EOL +
- "}" + EOL;
-
- private final String SDNC_SERVICE_RESPONSE =
- "{" + EOL +
- " \"SDNCServiceResponse\": {" + EOL +
- " \"sdncRequestId\": \"413658f4-7f42-482e-b834-23a5c15657da-1474471336781\"," + EOL +
- " \"responseCode\": \"200\"," + EOL +
- "((RESPONSE-MESSAGE))" +
- " \"ackFinalIndicator\": \"Y\"" + EOL +
- "((RESPONSE-PARAMS))" +
- " }" + EOL +
- "}" + EOL;
-
- private final String SDNC_SERVICE_ERROR =
- "{" + EOL +
- " \"SDNCServiceError\": {" + EOL +
- " \"sdncRequestId\": \"413658f4-7f42-482e-b834-23a5c15657da-1474471336781\"," + EOL +
- " \"responseCode\": \"500\"," + EOL +
- "((RESPONSE-MESSAGE))" +
- " \"ackFinalIndicator\": \"Y\"" + EOL +
- " }" + EOL +
- "}" + EOL;
-
- private final String SDNC_EVENT =
- "{" + EOL +
- " \"SDNCEvent\": {" + EOL +
- " \"eventType\": \"ACTIVATION\"," + EOL +
- " \"eventCorrelatorType\": \"HOST-NAME\"," + EOL +
- " \"eventCorrelator\": \"USOSTCDALTX0101UJZZ31\"" + EOL +
- "((EVENT-PARAMS))" +
- " }" + EOL +
- "}" + EOL;
-
- private final String PARAMS =
- "{\"P1\":\"V1\",\"P2\":\"V2\",\"P3\":\"V3\"}";
-
- @Test
- public final void jsonToSDNCServiceRequest() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- String json = SDNC_SERVICE_REQUEST;
- json = json.replace("((BP-TIMEOUT))", "\"bpTimeout\": \"" + "PT5M" + "\"," + EOL);
-
- SDNCServiceRequest object = mapper.readValue(json, SDNCServiceRequest.class);
- assertEquals("413658f4-7f42-482e-b834-23a5c15657da", object.getRequestInformation().getRequestId());
- assertEquals("CCD", object.getRequestInformation().getSource());
- assertEquals("https://ccd-host:8080/notifications", object.getRequestInformation().getNotificationUrl());
- assertEquals("vHNFaaS", object.getServiceInformation().getServiceType());
- assertEquals("74e65b2b637441bca078e63e44bb511b", object.getServiceInformation().getServiceInstanceId());
- assertEquals("IST_SG_0902_3003", object.getServiceInformation().getSubscriberName());
- assertEquals("IST15_0902_3003", object.getServiceInformation().getSubscriberGlobalId());
- assertEquals("http://localhost:8080/mso/SDNCAdapterCallbackService", object.getBPNotificationUrl());
- assertEquals("PT5M", object.getBPTimeout());
- assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
- assertEquals("vhnf", object.getSdncService());
- assertEquals("service-topology-cust-assign-operation", object.getSdncOperation());
- assertEquals("XML", object.getSdncServiceDataType());
- assertTrue(object.getSdncServiceData().startsWith("<vhnf-cust-stage-information>"));
- }
-
- @Test
- public final void jsonToSDNCServiceRequestWithoutOptionalFields() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- // bpTimeout is optional.
- String json = SDNC_SERVICE_REQUEST;
- json = json.replace("((BP-TIMEOUT))", "");
-
- SDNCServiceRequest object = mapper.readValue(json, SDNCServiceRequest.class);
- assertEquals("413658f4-7f42-482e-b834-23a5c15657da", object.getRequestInformation().getRequestId());
- assertEquals("CCD", object.getRequestInformation().getSource());
- assertEquals("https://ccd-host:8080/notifications", object.getRequestInformation().getNotificationUrl());
- assertEquals("vHNFaaS", object.getServiceInformation().getServiceType());
- assertEquals("74e65b2b637441bca078e63e44bb511b", object.getServiceInformation().getServiceInstanceId());
- assertEquals("IST_SG_0902_3003", object.getServiceInformation().getSubscriberName());
- assertEquals("IST15_0902_3003", object.getServiceInformation().getSubscriberGlobalId());
- assertEquals("http://localhost:8080/mso/SDNCAdapterCallbackService", object.getBPNotificationUrl());
- assertNull(object.getBPTimeout());
- assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
- assertEquals("vhnf", object.getSdncService());
- assertEquals("service-topology-cust-assign-operation", object.getSdncOperation());
- assertEquals("XML", object.getSdncServiceDataType());
- assertTrue(object.getSdncServiceData().startsWith("<vhnf-cust-stage-information>"));
- }
-
- @Test
- public final void jsonFromSDNCServiceRequest() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- // Convert source json string to object.
- String json1 = SDNC_SERVICE_REQUEST;
- json1 = json1.replace("((BP-TIMEOUT))", "\"bpTimeout\": \"" + "PT5M" + "\"," + EOL);
- SDNCServiceRequest object1 = mapper.readValue(json1, SDNCServiceRequest.class);
-
- // Convert resulting object back to json.
- String json2 = object1.toJson();
- System.out.println("Generated JSON for " + object1.getClass().getSimpleName()
- + ":" + System.lineSeparator() + json2);
- assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceRequest\":{"));
-
- // Convert generated json string to another object.
- SDNCServiceRequest object2 = mapper.readValue(json2, SDNCServiceRequest.class);
-
- // Compare the first object to the second object.
- assertTrue(serializedEquals(object1, object2));
- }
-
- @Test
- public final void jsonFromSDNCServiceRequestWithoutOptionalFields() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- // Convert source json string to object.
- String json1 = SDNC_SERVICE_REQUEST;
- json1 = json1.replace("((BP-TIMEOUT))", "");
- SDNCServiceRequest object1 = mapper.readValue(json1, SDNCServiceRequest.class);
-
- // Convert resulting object back to json.
- String json2 = object1.toJson();
- System.out.println("Generated JSON for " + object1.getClass().getSimpleName()
- + ":" + System.lineSeparator() + json2);
- assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceRequest\":{"));
-
- // Convert generated json string to another object.
- SDNCServiceRequest object2 = mapper.readValue(json2, SDNCServiceRequest.class);
-
- // Compare the first object to the second object.
- assertTrue(serializedEquals(object1, object2));
- }
-
- @Test
- public final void jsonToSDNCServiceResponse() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- String json = SDNC_SERVICE_RESPONSE;
- json = json.replace("((RESPONSE-MESSAGE))", " \"responseMessage\": \"" + "OK" + "\"," + EOL);
- json = json.replace(EOL + "((RESPONSE-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL);
-
- SDNCServiceResponse object = mapper.readValue(json, SDNCServiceResponse.class);
- assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
- assertEquals("200", object.getResponseCode());
- assertEquals("OK", object.getResponseMessage());
- assertEquals("Y", object.getAckFinalIndicator());
- assertEquals("V1", object.getParams().get("P1"));
- assertEquals("V2", object.getParams().get("P2"));
- assertEquals("V3", object.getParams().get("P3"));
- }
-
- @Test
- public final void jsonToSDNCServiceResponseWithoutOptionalFields() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- // responseMessage is optional.
- String json = SDNC_SERVICE_RESPONSE;
- json = json.replace("((RESPONSE-MESSAGE))", "");
- json = json.replace("((RESPONSE-PARAMS))", "");
-
- SDNCServiceResponse object = mapper.readValue(json, SDNCServiceResponse.class);
- assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
- assertEquals("200", object.getResponseCode());
- assertNull(object.getResponseMessage());
- assertEquals("Y", object.getAckFinalIndicator());
- assertNull(object.getParams());
- }
-
- @Test
- public final void jsonFromSDNCServiceResponse() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- // Convert source json string to object.
- String json1 = SDNC_SERVICE_RESPONSE;
- json1 = json1.replace("((RESPONSE-MESSAGE))", "\"responseMessage\": \"" + "OK" + "\"," + EOL);
- json1 = json1.replace(EOL + "((RESPONSE-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL);
- SDNCServiceResponse object1 = mapper.readValue(json1, SDNCServiceResponse.class);
-
- // Convert resulting object back to json.
- String json2 = object1.toJson();
- System.out.println("Generated JSON for " + object1.getClass().getSimpleName()
- + ":" + System.lineSeparator() + json2);
- assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceResponse\":{"));
-
- // Convert generated json string to another object.
- SDNCServiceResponse object2 = mapper.readValue(json2, SDNCServiceResponse.class);
-
- // Compare the first object to the second object.
- assertTrue(serializedEquals(object1, object2));
- }
-
- @Test
- public final void jsonFromSDNCServiceResponseWithoutOptionalFields() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- // Convert source json string to object.
- String json1 = SDNC_SERVICE_RESPONSE;
- json1 = json1.replace("((RESPONSE-MESSAGE))", "");
- json1 = json1.replace("((RESPONSE-PARAMS))", "");
- SDNCServiceResponse object1 = mapper.readValue(json1, SDNCServiceResponse.class);
-
- // Convert resulting object back to json.
- String json2 = object1.toJson();
- System.out.println("Generated JSON for " + object1.getClass().getSimpleName()
- + ":" + System.lineSeparator() + json2);
- assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceResponse\":{"));
-
- // Convert generated json string to another object.
- SDNCServiceResponse object2 = mapper.readValue(json2, SDNCServiceResponse.class);
-
- // Compare the first object to the second object.
- assertTrue(serializedEquals(object1, object2));
- }
-
- @Test
- public final void jsonToSDNCServiceError() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- String json = SDNC_SERVICE_ERROR;
- json = json.replace("((RESPONSE-MESSAGE))", "\"responseMessage\": \"" + "SOMETHING BAD" + "\"," + EOL);
-
- SDNCServiceError object = mapper.readValue(json, SDNCServiceError.class);
- assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
- assertEquals("500", object.getResponseCode());
- assertEquals("SOMETHING BAD", object.getResponseMessage());
- assertEquals("Y", object.getAckFinalIndicator());
- }
-
- @Test
- public final void jsonToSDNCServiceErrorWithoutOptionalFields() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- // responseMessage is optional.
- String json = SDNC_SERVICE_ERROR;
- json = json.replace("((RESPONSE-MESSAGE))", "");
-
- SDNCServiceError object = mapper.readValue(json, SDNCServiceError.class);
- assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
- assertEquals("500", object.getResponseCode());
- assertNull(object.getResponseMessage());
- assertEquals("Y", object.getAckFinalIndicator());
- }
-
- @Test
- public final void jsonFromSDNCServiceError() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- // Convert source json string to object.
- String json1 = SDNC_SERVICE_ERROR;
- json1 = json1.replace("((RESPONSE-MESSAGE))", "\"responseMessage\": \"" + "OK" + "\"," + EOL);
- SDNCServiceError object1 = mapper.readValue(json1, SDNCServiceError.class);
-
- // Convert resulting object back to json.
- String json2 = object1.toJson();
- System.out.println("Generated JSON for " + object1.getClass().getSimpleName()
- + ":" + System.lineSeparator() + json2);
- assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceError\":{"));
-
- // Convert generated json string to another object.
- SDNCServiceError object2 = mapper.readValue(json2, SDNCServiceError.class);
-
- // Compare the first object to the second object.
- assertTrue(serializedEquals(object1, object2));
- }
-
- @Test
- public final void jsonFromSDNCServiceErrorWithoutOptionalFields() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- // Convert source json string to object.
- String json1 = SDNC_SERVICE_ERROR;
- json1 = json1.replace("((RESPONSE-MESSAGE))", "");
- SDNCServiceError object1 = mapper.readValue(json1, SDNCServiceError.class);
-
- // Convert resulting object back to json.
- String json2 = object1.toJson();
- System.out.println("Generated JSON for " + object1.getClass().getSimpleName()
- + ":" + System.lineSeparator() + json2);
- assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCServiceError\":{"));
-
- // Convert generated json string to another object.
- SDNCServiceError object2 = mapper.readValue(json2, SDNCServiceError.class);
-
- // Compare the first object to the second object.
- assertTrue(serializedEquals(object1, object2));
- }
-
- @Test
- public final void jsonToSDNCEvent() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- String json = SDNC_EVENT;
- json = json.replace(EOL + "((EVENT-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL);
-
- SDNCEvent object = mapper.readValue(json, SDNCEvent.class);
- assertEquals("ACTIVATION", object.getEventType());
- assertEquals("HOST-NAME", object.getEventCorrelatorType());
- assertEquals("USOSTCDALTX0101UJZZ31", object.getEventCorrelator());
- assertEquals("V1", object.getParams().get("P1"));
- assertEquals("V2", object.getParams().get("P2"));
- assertEquals("V3", object.getParams().get("P3"));
- }
-
- @Test
- public final void jsonToSDNCEventWithoutOptionalFields() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- // params are optional.
- String json = SDNC_EVENT;
- json = json.replace("((EVENT-PARAMS))", "");
-
- SDNCEvent object = mapper.readValue(json, SDNCEvent.class);
- assertEquals("ACTIVATION", object.getEventType());
- assertEquals("HOST-NAME", object.getEventCorrelatorType());
- assertEquals("USOSTCDALTX0101UJZZ31", object.getEventCorrelator());
- assertNull(object.getParams());
- }
-
- @Test
- public final void jsonFromSDNCEvent() throws Exception {
- logTest();
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
- mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
-
- // Convert source json string to object.
- String json1 = SDNC_EVENT;
- json1 = json1.replace(EOL + "((EVENT-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL);
- SDNCEvent object1 = mapper.readValue(json1, SDNCEvent.class);
-
- // Convert resulting object back to json.
- String json2 = object1.toJson();
- System.out.println("Generated JSON for " + object1.getClass().getSimpleName()
- + ":" + System.lineSeparator() + json2);
- assertTrue(json2.replaceAll("\\s+","").startsWith("{\"SDNCEvent\":{"));
-
- // Convert generated json string to another object.
- SDNCEvent object2 = mapper.readValue(json2, SDNCEvent.class);
-
- // Compare the first object to the second object.
- assertTrue(serializedEquals(object1, object2));
- }
-
- /**
- * Tests equality of two objects by comparing their serialized form.
- * WARNING: this works pretty well as long as the objects don't contain
- * collections like maps and sets that are semantically equal, but have
- * different internal ordering of elements.
- */
- private boolean serializedEquals(Serializable object1, Serializable object2) throws IOException {
- ByteArrayOutputStream byteStream1 = new ByteArrayOutputStream();
- ObjectOutputStream objectStream1 = new ObjectOutputStream(byteStream1);
- objectStream1.writeObject(object1);
- objectStream1.close();
-
- ByteArrayOutputStream byteStream2 = new ByteArrayOutputStream();
- ObjectOutputStream objectStream2 = new ObjectOutputStream(byteStream2);
- objectStream2.writeObject(object2);
- objectStream2.close();
-
- return Arrays.equals(byteStream1.toByteArray(), byteStream2.toByteArray());
- }
-
- private void logTest() {
- StackTraceElement[] st = Thread.currentThread().getStackTrace();
- String method = st[2].getMethodName();
- System.out.println("RUNNING TEST: " + method);
- }
+ private static final String EOL = "\n";
+
+ private final String SDNC_SERVICE_REQUEST = "{" + EOL + " \"SDNCServiceRequest\": {" + EOL
+ + " \"requestInformation\": {" + EOL + " \"requestId\": \"413658f4-7f42-482e-b834-23a5c15657da\","
+ + EOL + " \"source\": \"CCD\"," + EOL
+ + " \"notificationUrl\": \"https://ccd-host:8080/notifications\"" + EOL + " }," + EOL
+ + " \"serviceInformation\": {" + EOL + " \"serviceType\": \"vHNFaaS\"," + EOL
+ + " \"serviceInstanceId\": \"74e65b2b637441bca078e63e44bb511b\"," + EOL
+ + " \"subscriberName\": \"IST_SG_0902_3003\"," + EOL + " \"subscriberGlobalId\": \"IST15_0902_3003\""
+ + EOL + " }," + EOL + " \"bpNotificationUrl\": \"http://localhost:8080/mso/SDNCAdapterCallbackService\","
+ + EOL + "((BP-TIMEOUT))" + " \"sdncRequestId\": \"413658f4-7f42-482e-b834-23a5c15657da-1474471336781\","
+ + EOL + " \"sdncService\": \"vhnf\"," + EOL
+ + " \"sdncOperation\": \"service-topology-cust-assign-operation\"," + EOL
+ + " \"sdncServiceDataType\": \"XML\"," + EOL
+ + " \"sdncServiceData\": \"<vhnf-cust-stage-information><dhv-service-instance-id>c26dfed652164d60a17461734422b085</dhv-service-instance-id><hnportal-primary-vnf-host-name>HOSTNAME</hnportal-primary-vnf-host-name></vhnf-cust-stage-information>\""
+ + EOL + " }" + EOL + "}" + EOL;
+
+ private final String SDNC_SERVICE_RESPONSE = "{" + EOL + " \"SDNCServiceResponse\": {" + EOL
+ + " \"sdncRequestId\": \"413658f4-7f42-482e-b834-23a5c15657da-1474471336781\"," + EOL
+ + " \"responseCode\": \"200\"," + EOL + "((RESPONSE-MESSAGE))" + " \"ackFinalIndicator\": \"Y\"" + EOL
+ + "((RESPONSE-PARAMS))" + " }" + EOL + "}" + EOL;
+
+ private final String SDNC_SERVICE_ERROR = "{" + EOL + " \"SDNCServiceError\": {" + EOL
+ + " \"sdncRequestId\": \"413658f4-7f42-482e-b834-23a5c15657da-1474471336781\"," + EOL
+ + " \"responseCode\": \"500\"," + EOL + "((RESPONSE-MESSAGE))" + " \"ackFinalIndicator\": \"Y\"" + EOL
+ + " }" + EOL + "}" + EOL;
+
+ private final String SDNC_EVENT = "{" + EOL + " \"SDNCEvent\": {" + EOL + " \"eventType\": \"ACTIVATION\","
+ + EOL + " \"eventCorrelatorType\": \"HOST-NAME\"," + EOL
+ + " \"eventCorrelator\": \"USOSTCDALTX0101UJZZ31\"" + EOL + "((EVENT-PARAMS))" + " }" + EOL + "}" + EOL;
+
+ private final String PARAMS = "{\"P1\":\"V1\",\"P2\":\"V2\",\"P3\":\"V3\"}";
+
+ @Test
+ public final void jsonToSDNCServiceRequest() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ String json = SDNC_SERVICE_REQUEST;
+ json = json.replace("((BP-TIMEOUT))", "\"bpTimeout\": \"" + "PT5M" + "\"," + EOL);
+
+ SDNCServiceRequest object = mapper.readValue(json, SDNCServiceRequest.class);
+ assertEquals("413658f4-7f42-482e-b834-23a5c15657da", object.getRequestInformation().getRequestId());
+ assertEquals("CCD", object.getRequestInformation().getSource());
+ assertEquals("https://ccd-host:8080/notifications", object.getRequestInformation().getNotificationUrl());
+ assertEquals("vHNFaaS", object.getServiceInformation().getServiceType());
+ assertEquals("74e65b2b637441bca078e63e44bb511b", object.getServiceInformation().getServiceInstanceId());
+ assertEquals("IST_SG_0902_3003", object.getServiceInformation().getSubscriberName());
+ assertEquals("IST15_0902_3003", object.getServiceInformation().getSubscriberGlobalId());
+ assertEquals("http://localhost:8080/mso/SDNCAdapterCallbackService", object.getBPNotificationUrl());
+ assertEquals("PT5M", object.getBPTimeout());
+ assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
+ assertEquals("vhnf", object.getSdncService());
+ assertEquals("service-topology-cust-assign-operation", object.getSdncOperation());
+ assertEquals("XML", object.getSdncServiceDataType());
+ assertTrue(object.getSdncServiceData().startsWith("<vhnf-cust-stage-information>"));
+ }
+
+ @Test
+ public final void jsonToSDNCServiceRequestWithoutOptionalFields() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ // bpTimeout is optional.
+ String json = SDNC_SERVICE_REQUEST;
+ json = json.replace("((BP-TIMEOUT))", "");
+
+ SDNCServiceRequest object = mapper.readValue(json, SDNCServiceRequest.class);
+ assertEquals("413658f4-7f42-482e-b834-23a5c15657da", object.getRequestInformation().getRequestId());
+ assertEquals("CCD", object.getRequestInformation().getSource());
+ assertEquals("https://ccd-host:8080/notifications", object.getRequestInformation().getNotificationUrl());
+ assertEquals("vHNFaaS", object.getServiceInformation().getServiceType());
+ assertEquals("74e65b2b637441bca078e63e44bb511b", object.getServiceInformation().getServiceInstanceId());
+ assertEquals("IST_SG_0902_3003", object.getServiceInformation().getSubscriberName());
+ assertEquals("IST15_0902_3003", object.getServiceInformation().getSubscriberGlobalId());
+ assertEquals("http://localhost:8080/mso/SDNCAdapterCallbackService", object.getBPNotificationUrl());
+ assertNull(object.getBPTimeout());
+ assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
+ assertEquals("vhnf", object.getSdncService());
+ assertEquals("service-topology-cust-assign-operation", object.getSdncOperation());
+ assertEquals("XML", object.getSdncServiceDataType());
+ assertTrue(object.getSdncServiceData().startsWith("<vhnf-cust-stage-information>"));
+ }
+
+ @Test
+ public final void jsonFromSDNCServiceRequest() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ // Convert source json string to object.
+ String json1 = SDNC_SERVICE_REQUEST;
+ json1 = json1.replace("((BP-TIMEOUT))", "\"bpTimeout\": \"" + "PT5M" + "\"," + EOL);
+ SDNCServiceRequest object1 = mapper.readValue(json1, SDNCServiceRequest.class);
+
+ // Convert resulting object back to json.
+ String json2 = object1.toJson();
+ System.out.println(
+ "Generated JSON for " + object1.getClass().getSimpleName() + ":" + System.lineSeparator() + json2);
+ assertTrue(json2.replaceAll("\\s+", "").startsWith("{\"SDNCServiceRequest\":{"));
+
+ // Convert generated json string to another object.
+ SDNCServiceRequest object2 = mapper.readValue(json2, SDNCServiceRequest.class);
+
+ // Compare the first object to the second object.
+ assertTrue(serializedEquals(object1, object2));
+ }
+
+ @Test
+ public final void jsonFromSDNCServiceRequestWithoutOptionalFields() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ // Convert source json string to object.
+ String json1 = SDNC_SERVICE_REQUEST;
+ json1 = json1.replace("((BP-TIMEOUT))", "");
+ SDNCServiceRequest object1 = mapper.readValue(json1, SDNCServiceRequest.class);
+
+ // Convert resulting object back to json.
+ String json2 = object1.toJson();
+ System.out.println(
+ "Generated JSON for " + object1.getClass().getSimpleName() + ":" + System.lineSeparator() + json2);
+ assertTrue(json2.replaceAll("\\s+", "").startsWith("{\"SDNCServiceRequest\":{"));
+
+ // Convert generated json string to another object.
+ SDNCServiceRequest object2 = mapper.readValue(json2, SDNCServiceRequest.class);
+
+ // Compare the first object to the second object.
+ assertTrue(serializedEquals(object1, object2));
+ }
+
+ @Test
+ public final void jsonToSDNCServiceResponse() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ String json = SDNC_SERVICE_RESPONSE;
+ json = json.replace("((RESPONSE-MESSAGE))", " \"responseMessage\": \"" + "OK" + "\"," + EOL);
+ json = json.replace(EOL + "((RESPONSE-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL);
+
+ SDNCServiceResponse object = mapper.readValue(json, SDNCServiceResponse.class);
+ assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
+ assertEquals("200", object.getResponseCode());
+ assertEquals("OK", object.getResponseMessage());
+ assertEquals("Y", object.getAckFinalIndicator());
+ assertEquals("V1", object.getParams().get("P1"));
+ assertEquals("V2", object.getParams().get("P2"));
+ assertEquals("V3", object.getParams().get("P3"));
+ }
+
+ @Test
+ public final void jsonToSDNCServiceResponseWithoutOptionalFields() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ // responseMessage is optional.
+ String json = SDNC_SERVICE_RESPONSE;
+ json = json.replace("((RESPONSE-MESSAGE))", "");
+ json = json.replace("((RESPONSE-PARAMS))", "");
+
+ SDNCServiceResponse object = mapper.readValue(json, SDNCServiceResponse.class);
+ assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
+ assertEquals("200", object.getResponseCode());
+ assertNull(object.getResponseMessage());
+ assertEquals("Y", object.getAckFinalIndicator());
+ assertNull(object.getParams());
+ }
+
+ @Test
+ public final void jsonFromSDNCServiceResponse() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ // Convert source json string to object.
+ String json1 = SDNC_SERVICE_RESPONSE;
+ json1 = json1.replace("((RESPONSE-MESSAGE))", "\"responseMessage\": \"" + "OK" + "\"," + EOL);
+ json1 = json1.replace(EOL + "((RESPONSE-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL);
+ SDNCServiceResponse object1 = mapper.readValue(json1, SDNCServiceResponse.class);
+
+ // Convert resulting object back to json.
+ String json2 = object1.toJson();
+ System.out.println(
+ "Generated JSON for " + object1.getClass().getSimpleName() + ":" + System.lineSeparator() + json2);
+ assertTrue(json2.replaceAll("\\s+", "").startsWith("{\"SDNCServiceResponse\":{"));
+
+ // Convert generated json string to another object.
+ SDNCServiceResponse object2 = mapper.readValue(json2, SDNCServiceResponse.class);
+
+ // Compare the first object to the second object.
+ assertTrue(serializedEquals(object1, object2));
+ }
+
+ @Test
+ public final void jsonFromSDNCServiceResponseWithoutOptionalFields() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ // Convert source json string to object.
+ String json1 = SDNC_SERVICE_RESPONSE;
+ json1 = json1.replace("((RESPONSE-MESSAGE))", "");
+ json1 = json1.replace("((RESPONSE-PARAMS))", "");
+ SDNCServiceResponse object1 = mapper.readValue(json1, SDNCServiceResponse.class);
+
+ // Convert resulting object back to json.
+ String json2 = object1.toJson();
+ System.out.println(
+ "Generated JSON for " + object1.getClass().getSimpleName() + ":" + System.lineSeparator() + json2);
+ assertTrue(json2.replaceAll("\\s+", "").startsWith("{\"SDNCServiceResponse\":{"));
+
+ // Convert generated json string to another object.
+ SDNCServiceResponse object2 = mapper.readValue(json2, SDNCServiceResponse.class);
+
+ // Compare the first object to the second object.
+ assertTrue(serializedEquals(object1, object2));
+ }
+
+ @Test
+ public final void jsonToSDNCServiceError() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ String json = SDNC_SERVICE_ERROR;
+ json = json.replace("((RESPONSE-MESSAGE))", "\"responseMessage\": \"" + "SOMETHING BAD" + "\"," + EOL);
+
+ SDNCServiceError object = mapper.readValue(json, SDNCServiceError.class);
+ assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
+ assertEquals("500", object.getResponseCode());
+ assertEquals("SOMETHING BAD", object.getResponseMessage());
+ assertEquals("Y", object.getAckFinalIndicator());
+ }
+
+ @Test
+ public final void jsonToSDNCServiceErrorWithoutOptionalFields() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ // responseMessage is optional.
+ String json = SDNC_SERVICE_ERROR;
+ json = json.replace("((RESPONSE-MESSAGE))", "");
+
+ SDNCServiceError object = mapper.readValue(json, SDNCServiceError.class);
+ assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
+ assertEquals("500", object.getResponseCode());
+ assertNull(object.getResponseMessage());
+ assertEquals("Y", object.getAckFinalIndicator());
+ }
+
+ @Test
+ public final void jsonFromSDNCServiceError() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ // Convert source json string to object.
+ String json1 = SDNC_SERVICE_ERROR;
+ json1 = json1.replace("((RESPONSE-MESSAGE))", "\"responseMessage\": \"" + "OK" + "\"," + EOL);
+ SDNCServiceError object1 = mapper.readValue(json1, SDNCServiceError.class);
+
+ // Convert resulting object back to json.
+ String json2 = object1.toJson();
+ System.out.println(
+ "Generated JSON for " + object1.getClass().getSimpleName() + ":" + System.lineSeparator() + json2);
+ assertTrue(json2.replaceAll("\\s+", "").startsWith("{\"SDNCServiceError\":{"));
+
+ // Convert generated json string to another object.
+ SDNCServiceError object2 = mapper.readValue(json2, SDNCServiceError.class);
+
+ // Compare the first object to the second object.
+ assertTrue(serializedEquals(object1, object2));
+ }
+
+ @Test
+ public final void jsonFromSDNCServiceErrorWithoutOptionalFields() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ // Convert source json string to object.
+ String json1 = SDNC_SERVICE_ERROR;
+ json1 = json1.replace("((RESPONSE-MESSAGE))", "");
+ SDNCServiceError object1 = mapper.readValue(json1, SDNCServiceError.class);
+
+ // Convert resulting object back to json.
+ String json2 = object1.toJson();
+ System.out.println(
+ "Generated JSON for " + object1.getClass().getSimpleName() + ":" + System.lineSeparator() + json2);
+ assertTrue(json2.replaceAll("\\s+", "").startsWith("{\"SDNCServiceError\":{"));
+
+ // Convert generated json string to another object.
+ SDNCServiceError object2 = mapper.readValue(json2, SDNCServiceError.class);
+
+ // Compare the first object to the second object.
+ assertTrue(serializedEquals(object1, object2));
+ }
+
+ @Test
+ public final void jsonToSDNCEvent() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ String json = SDNC_EVENT;
+ json = json.replace(EOL + "((EVENT-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL);
+
+ SDNCEvent object = mapper.readValue(json, SDNCEvent.class);
+ assertEquals("ACTIVATION", object.getEventType());
+ assertEquals("HOST-NAME", object.getEventCorrelatorType());
+ assertEquals("USOSTCDALTX0101UJZZ31", object.getEventCorrelator());
+ assertEquals("V1", object.getParams().get("P1"));
+ assertEquals("V2", object.getParams().get("P2"));
+ assertEquals("V3", object.getParams().get("P3"));
+ }
+
+ @Test
+ public final void jsonToSDNCEventWithoutOptionalFields() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ // params are optional.
+ String json = SDNC_EVENT;
+ json = json.replace("((EVENT-PARAMS))", "");
+
+ SDNCEvent object = mapper.readValue(json, SDNCEvent.class);
+ assertEquals("ACTIVATION", object.getEventType());
+ assertEquals("HOST-NAME", object.getEventCorrelatorType());
+ assertEquals("USOSTCDALTX0101UJZZ31", object.getEventCorrelator());
+ assertNull(object.getParams());
+ }
+
+ @Test
+ public final void jsonFromSDNCEvent() throws Exception {
+ logTest();
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
+ mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
+
+ // Convert source json string to object.
+ String json1 = SDNC_EVENT;
+ json1 = json1.replace(EOL + "((EVENT-PARAMS))", "," + EOL + " \"params\": " + PARAMS + EOL);
+ SDNCEvent object1 = mapper.readValue(json1, SDNCEvent.class);
+
+ // Convert resulting object back to json.
+ String json2 = object1.toJson();
+ System.out.println(
+ "Generated JSON for " + object1.getClass().getSimpleName() + ":" + System.lineSeparator() + json2);
+ assertTrue(json2.replaceAll("\\s+", "").startsWith("{\"SDNCEvent\":{"));
+
+ // Convert generated json string to another object.
+ SDNCEvent object2 = mapper.readValue(json2, SDNCEvent.class);
+
+ // Compare the first object to the second object.
+ assertTrue(serializedEquals(object1, object2));
+ }
+
+ /**
+ * Tests equality of two objects by comparing their serialized form. WARNING: this works pretty well as long as the
+ * objects don't contain collections like maps and sets that are semantically equal, but have different internal
+ * ordering of elements.
+ */
+ private boolean serializedEquals(Serializable object1, Serializable object2) throws IOException {
+ ByteArrayOutputStream byteStream1 = new ByteArrayOutputStream();
+ ObjectOutputStream objectStream1 = new ObjectOutputStream(byteStream1);
+ objectStream1.writeObject(object1);
+ objectStream1.close();
+
+ ByteArrayOutputStream byteStream2 = new ByteArrayOutputStream();
+ ObjectOutputStream objectStream2 = new ObjectOutputStream(byteStream2);
+ objectStream2.writeObject(object2);
+ objectStream2.close();
+
+ return Arrays.equals(byteStream1.toByteArray(), byteStream2.toByteArray());
+ }
+
+ private void logTest() {
+ StackTraceElement[] st = Thread.currentThread().getStackTrace();
+ String method = st[2].getMethodName();
+ System.out.println("RUNNING TEST: " + method);
+ }
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java
index 1de281bde4..e5b439228d 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java
@@ -24,7 +24,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.Assert.assertNotNull;
-
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.adapters.sdnc.BaseTest;
@@ -40,21 +39,20 @@ public class SDNCConnectorTest extends BaseTest {
public void sendTest() {
String content = "<dummy><service-instance-id>1234</service-instance-id></dummy>";
- String response = "<errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n" +
- "\t\t// <error>\n" +
- "\t\t// <error-type>protocol</error-type>\n" +
- "\t\t// <error-tag>malformed-message</error-tag>\n" +
- "\t\t// <error-message>Error parsing input: The element type \"input\" must be terminated by the matching end-tag \"&lt;/input&gt;\".</error-message>\n" +
- "\t\t// </error>\n" +
- "\t\t// </errors>";
+ String response = "<errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n" + "\t\t// <error>\n"
+ + "\t\t// <error-type>protocol</error-type>\n"
+ + "\t\t// <error-tag>malformed-message</error-tag>\n"
+ + "\t\t// <error-message>Error parsing input: The element type \"input\" must be terminated by the matching end-tag \"&lt;/input&gt;\".</error-message>\n"
+ + "\t\t// </error>\n" + "\t\t// </errors>";
TypedRequestTunables rt = new TypedRequestTunables("", "");
rt.setTimeout("1000");
rt.setReqMethod("POST");
rt.setSdncUrl("http://localhost:" + wireMockPort + "/sdnc");
- wireMockServer.stubFor(post(urlPathEqualTo("/sdnc"))
- .willReturn(aResponse().withHeader("Content-Type", "application/xml").withBody(response).withStatus(HttpStatus.SC_MULTIPLE_CHOICES)));
+ wireMockServer.stubFor(
+ post(urlPathEqualTo("/sdnc")).willReturn(aResponse().withHeader("Content-Type", "application/xml")
+ .withBody(response).withStatus(HttpStatus.SC_MULTIPLE_CHOICES)));
SDNCResponseCommon responseCommon = sdncConnector.send(content, rt);
assertNotNull(responseCommon);
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnectorTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnectorTest.java
index eddd74b213..9911cae677 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnectorTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnectorTest.java
@@ -23,7 +23,6 @@ package org.onap.so.adapters.sdnc.sdncrest;
import org.junit.Test;
import org.onap.so.adapters.sdnc.FileUtil;
import org.onap.so.adapters.sdncrest.SDNCResponseCommon;
-
import static org.junit.Assert.assertNotNull;
public class SDNCServiceRequestConnectorTest {
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/util/SDNCRequestIdUtilTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/util/SDNCRequestIdUtilTest.java
index 7ba8b68602..aa856acd2e 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/util/SDNCRequestIdUtilTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/util/SDNCRequestIdUtilTest.java
@@ -21,9 +21,7 @@
package org.onap.so.adapters.sdnc.util;
import static org.junit.Assert.assertEquals;
-
import java.util.UUID;
-
import org.junit.Test;
@@ -33,14 +31,14 @@ public class SDNCRequestIdUtilTest {
* Test method for {@link org.onap.so.adapters.sdnc.SDNCRequestIdUtil#getSDNCOriginalRequestId()}.
*/
@Test
- public final void testGetSDNCOriginalRequestId () {
- String originalRequestId = UUID.randomUUID().toString();
- String postfixedRequestId = originalRequestId + "-1466203712068";
- String postfixedRequestId2 = originalRequestId + "-1466203712068-2";
+ public final void testGetSDNCOriginalRequestId() {
+ String originalRequestId = UUID.randomUUID().toString();
+ String postfixedRequestId = originalRequestId + "-1466203712068";
+ String postfixedRequestId2 = originalRequestId + "-1466203712068-2";
assertEquals(originalRequestId, SDNCRequestIdUtil.getSDNCOriginalRequestId(postfixedRequestId));
assertEquals(postfixedRequestId2, SDNCRequestIdUtil.getSDNCOriginalRequestId(postfixedRequestId2));
-
+
}
}