aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-sdnc-adapter/src/test/java
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-30 15:56:09 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-31 11:09:25 -0400
commit5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch)
tree59a968f27b4b603aacc9d5e7b51fb598aeec5321 /adapters/mso-sdnc-adapter/src/test/java
parentb6dc38501f3b746426b42d9de4cc883d894149e8 (diff)
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-sdnc-adapter/src/test/java')
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java52
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/FileUtil.java76
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/ObjectFactoryTest.java (renamed from adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/ObjectFactoryTest.java)6
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/SDNCAdapterRequestTest.java (renamed from adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java)6
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/CallbackHeaderTest.java (renamed from adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java)34
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java (renamed from adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java)6
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/MapRequestTunablesTest.java128
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImplTest.java111
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCResponseTest.java49
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java54
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java64
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/ObjectMappingTest.java (renamed from adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/ObjectMappingTest.java)43
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java63
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnectorTest.java (renamed from adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallbackTest.java)23
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/util/SDNCRequestIdUtilTest.java (renamed from adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtilTest.java)5
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/InvestigationTest.java114
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java86
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java79
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponseTest.java49
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java52
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/TypedRequestTunablesTest.java48
21 files changed, 660 insertions, 488 deletions
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
new file mode 100644
index 0000000000..29a1db89aa
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/BaseTest.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.sdnc;
+
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.onap.so.cloud.Application;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+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;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+@AutoConfigureWireMock(port = 0)
+public abstract class BaseTest {
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ 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
new file mode 100644
index 0000000000..f2fba5900f
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/FileUtil.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.sdnc;
+
+import org.onap.so.logger.MsoLogger;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * file utility class
+ */
+public class FileUtil {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, FileUtil.class);
+
+ /**
+ * Read the specified resource file and return the contents as a String.
+ *
+ * @param fileName Name of the resource file
+ * @return the contents of the resource file as a String
+ * @throws IOException if there is a problem reading the file
+ */
+ public static String readResourceFile(String fileName) {
+ InputStream stream;
+ try {
+ stream = getResourceAsStream(fileName);
+ byte[] bytes;
+ bytes = new byte[stream.available()];
+ if(stream.read(bytes) > 0) {
+ stream.close();
+ return new String(bytes);
+ } else {
+ stream.close();
+ return "";
+ }
+ } catch (IOException e) {
+ LOGGER.debug("Exception:", e);
+ return "";
+ }
+ }
+
+ /**
+ * Get an InputStream for the resource specified.
+ *
+ * @param resourceName Name of resource for which to get InputStream.
+ * @return an InputStream for the resource specified.
+ * @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);
+ if (stream == null) {
+ throw new IOException("Can't access resource '" + resourceName + "'");
+ }
+ return stream;
+ }
+}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/ObjectFactoryTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/ObjectFactoryTest.java
index c3949a6a79..7a9b039089 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/ObjectFactoryTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/ObjectFactoryTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.sdnc;
+package org.onap.so.adapters.sdnc;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.containsString;
@@ -45,7 +45,7 @@ public class ObjectFactoryTest {
private Unmarshaller jaxbUnmarshaller;
/**
- * Test method for {@link org.openecomp.mso.adapters.sdnc.ObjectFactory#createRequestHeader()}.
+ * Test method for {@link org.onap.so.adapters.sdnc.ObjectFactory#createRequestHeader()}.
*/
@Test
public final void testCreateRequestHeader () {
@@ -94,7 +94,7 @@ public class ObjectFactoryTest {
}
/**
- * Test method for {@link org.openecomp.mso.adapters.sdnc.ObjectFactory#createSDNCAdapterResponse()}.
+ * Test method for {@link org.onap.so.adapters.sdnc.ObjectFactory#createSDNCAdapterResponse()}.
*/
@Test
public final void testCreateSDNCAdapterResponse () {
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/SDNCAdapterRequestTest.java
index b9d88406f9..e0a1982db1 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/SDNCAdapterRequestTest.java
@@ -19,15 +19,15 @@
*/
-package org.openecomp.mso.adapters.sdnc;
+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.openecomp.mso.adapters.sdnc.SDNCAdapterRequest;
-import org.openecomp.mso.adapters.sdnc.RequestHeader;
+import org.onap.so.adapters.sdnc.SDNCAdapterRequest;
+import org.onap.so.adapters.sdnc.RequestHeader;
public class SDNCAdapterRequestTest {
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/CallbackHeaderTest.java
index 39518e2081..dbb5c9aa44 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/CallbackHeaderTest.java
@@ -1,24 +1,24 @@
/*
* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 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
-*
-* 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=========================================================
+ * 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
+ *
+ * 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.openecomp.mso.adapters.sdnc.client;
+package org.onap.so.adapters.sdnc.client;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java
index ecffd1c5ad..d7f4f8e6f7 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java
@@ -19,14 +19,14 @@
*/
-package org.openecomp.mso.adapters.sdnc.client;
+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.openecomp.mso.adapters.sdnc.client.CallbackHeader;
-import org.openecomp.mso.adapters.sdnc.client.SDNCAdapterCallbackRequest;
+import org.onap.so.adapters.sdnc.client.CallbackHeader;
+import org.onap.so.adapters.sdnc.client.SDNCAdapterCallbackRequest;
public class SDNCAdapterCallbackRequestTest {
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
new file mode 100644
index 0000000000..cd93f6e71b
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/MapRequestTunablesTest.java
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.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;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@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));
+ }
+
+}
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
new file mode 100644
index 0000000000..8f73c02285
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImplTest.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.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;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+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;
+import org.onap.so.adapters.sdnc.SDNCAdapterApplication;
+import org.onap.so.adapters.sdnc.SDNCAdapterPortType;
+import org.onap.so.adapters.sdnc.SDNCAdapterRequest;
+import org.onap.so.adapters.sdnc.SDNCAdapterResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SDNCAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles({"test","non-async"})
+public class SDNCAdapterPortTypeImplTest {
+
+ @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();
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer transformer = tf.newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ 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"));
+ }
+}
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
new file mode 100644
index 0000000000..498fa3fa6d
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCResponseTest.java
@@ -0,0 +1,49 @@
+/*
+* ============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
+ *
+ * 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");
+ }
+
+ @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
new file mode 100644
index 0000000000..076a9f3c6a
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/SDNCRestClientTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.sdnc.impl;
+
+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;
+import org.springframework.beans.factory.annotation.Autowired;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+
+
+public class SDNCRestClientTest extends BaseTest {
+
+ @Autowired
+ private SDNCRestClient sdncClient;
+
+ @Test
+ public void getSdncRespTestException() {
+
+ RequestTunables rt = new RequestTunables("", "", "", "");
+ rt.setTimeout("1000");
+ rt.setReqMethod("POST");
+ rt.setSdncUrl("http://localhost:" + wireMockPort + "/sdnc");
+
+ 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
new file mode 100644
index 0000000000..596f26caa6
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.sdnc.impl;
+
+import static org.junit.Assert.assertEquals;
+import java.io.File;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import org.junit.Test;
+import org.onap.so.adapters.sdnc.SDNCAdapterRequest;
+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 {
+
+ 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);
+
+ 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);
+
+ } catch (JAXBException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/ObjectMappingTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/ObjectMappingTest.java
index 1746360af0..88849015e0 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/ObjectMappingTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/ObjectMappingTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.sdnc.sdncrest;
+
+package org.onap.so.adapters.sdnc.sdncrest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@@ -30,10 +31,10 @@ import java.io.Serializable;
import java.util.Arrays;
import org.junit.Test;
-import org.openecomp.mso.adapters.sdncrest.SDNCEvent;
-import org.openecomp.mso.adapters.sdncrest.SDNCServiceError;
-import org.openecomp.mso.adapters.sdncrest.SDNCServiceRequest;
-import org.openecomp.mso.adapters.sdncrest.SDNCServiceResponse;
+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;
@@ -125,11 +126,11 @@ public class ObjectMappingTest {
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>"));
+ 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
@@ -153,11 +154,11 @@ public class ObjectMappingTest {
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>"));
+ 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
@@ -222,7 +223,7 @@ public class ObjectMappingTest {
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("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
assertEquals("200", object.getResponseCode());
assertEquals("OK", object.getResponseMessage());
assertEquals("Y", object.getAckFinalIndicator());
@@ -244,7 +245,7 @@ public class ObjectMappingTest {
json = json.replace("((RESPONSE-PARAMS))", "");
SDNCServiceResponse object = mapper.readValue(json, SDNCServiceResponse.class);
- assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSDNCRequestId());
+ assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
assertEquals("200", object.getResponseCode());
assertNull(object.getResponseMessage());
assertEquals("Y", object.getAckFinalIndicator());
@@ -314,7 +315,7 @@ public class ObjectMappingTest {
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("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
assertEquals("500", object.getResponseCode());
assertEquals("SOMETHING BAD", object.getResponseMessage());
assertEquals("Y", object.getAckFinalIndicator());
@@ -332,7 +333,7 @@ public class ObjectMappingTest {
json = json.replace("((RESPONSE-MESSAGE))", "");
SDNCServiceError object = mapper.readValue(json, SDNCServiceError.class);
- assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSDNCRequestId());
+ assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", object.getSdncRequestId());
assertEquals("500", object.getResponseCode());
assertNull(object.getResponseMessage());
assertEquals("Y", object.getAckFinalIndicator());
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
new file mode 100644
index 0000000000..23830ae3f3
--- /dev/null
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnectorTest.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.sdnc.sdncrest;
+
+import org.apache.http.HttpStatus;
+import org.junit.Test;
+import org.onap.so.adapters.sdnc.BaseTest;
+import org.onap.so.adapters.sdncrest.SDNCResponseCommon;
+import org.springframework.beans.factory.annotation.Autowired;
+
+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 static com.github.tomakehurst.wiremock.client.WireMock.*;
+
+public class SDNCConnectorTest extends BaseTest {
+
+ @Autowired
+ private SDNCConnector sdncConnector;
+
+ @Test
+ 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>";
+
+ TypedRequestTunables rt = new TypedRequestTunables("", "");
+ rt.setTimeout("1000");
+ rt.setReqMethod("POST");
+ rt.setSdncUrl("http://localhost:" + wireMockPort + "/sdnc");
+
+ 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/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallbackTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnectorTest.java
index 91cf2c91c7..eddd74b213 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/BPRestCallbackTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnectorTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *l
+ *
* 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.
@@ -18,21 +18,22 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.sdnc.sdncrest;
+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 junit.framework.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
-
-public class BPRestCallbackTest {
+public class SDNCServiceRequestConnectorTest {
@Test
- public void testBPRestCallbackException() {
+ public void parseResponseContentTest() throws Exception {
- BPRestCallback test = new BPRestCallback();
- test.send("workflow/","messageType","correlator","message");
- assertFalse(test.send("workflowMessageUrl/", "messageType", "correlator", "message"));
+ String content = FileUtil.readResourceFile("SdncServiceResponse.xml");
+ SDNCResponseCommon responseCommon = SDNCServiceRequestConnector.parseResponseContent(content);
+ assertNotNull(responseCommon);
}
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtilTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/util/SDNCRequestIdUtilTest.java
index 77d22e44df..7ba8b68602 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtilTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/util/SDNCRequestIdUtilTest.java
@@ -18,18 +18,19 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.sdnc.util;
+package org.onap.so.adapters.sdnc.util;
import static org.junit.Assert.assertEquals;
import java.util.UUID;
+
import org.junit.Test;
public class SDNCRequestIdUtilTest {
/**
- * Test method for {@link org.openecomp.mso.adapters.sdnc.SDNCRequestIdUtil#getSDNCOriginalRequestId()}.
+ * Test method for {@link org.onap.so.adapters.sdnc.SDNCRequestIdUtil#getSDNCOriginalRequestId()}.
*/
@Test
public final void testGetSDNCOriginalRequestId () {
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/InvestigationTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/InvestigationTest.java
deleted file mode 100644
index 234a9d2272..0000000000
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/InvestigationTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.adapters.sdnc.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.Scanner;
-import java.util.UUID;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesException;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-public class InvestigationTest {
-
- private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
-
- public static final String SDNC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.sdnc.properties").toString().substring(5);
-
- @Before
- public final void initBeforeEachTest() throws MsoPropertiesException {
- msoPropertiesFactory.removeAllMsoProperties();
- msoPropertiesFactory.initializeMsoProperties("MSO_PROP_SDNC_ADAPTER", SDNC_PROP);
- }
-
- @AfterClass
- public static final void kill () throws MsoPropertiesException {
-
- msoPropertiesFactory.removeMsoProperties("MSO_PROP_SDNC_ADAPTER");
- }
-
- @Test
- public void run() throws ParserConfigurationException, IOException, SAXException {
-
- RequestTunables rt = new RequestTunables("reqid","","svc-topology-operation","delete", msoPropertiesFactory);
- rt.setTunables();
- /*Document reqDoc = parse();
- NodeList nodeList = reqDoc.getElementsByTagName("sdncadapterworkflow:SDNCRequestData");
- Node node = null;
- System.out.println("nodeList length: "+ nodeList.getLength());
- for (int i =0; i<nodeList.getLength();i++){
- node = nodeList.item(i);
- }
-
- Document doc = nodeToDocument(node);
- */
- Scanner scanner = new Scanner( new File("src/test/resources/sdnc_adapter_request.xml") );
- String input = scanner.useDelimiter("\\A").next();
- System.out.println("input: "+input);
- scanner.close();
- try {
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- InputSource is = new InputSource();
- is.setCharacterStream(new StringReader(input));
- Document reqDoc = db.parse(is);
- String sdncReqBody = Utils.genSdncReq(reqDoc, rt);
- System.out.println(sdncReqBody);
- String uuid = UUID.randomUUID().toString();
- System.out.println("uuid: "+uuid);
- }catch(Exception ex) {
- throw new IllegalStateException();
- }
-
- }
- public static Document parse() throws ParserConfigurationException, IOException, SAXException {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setValidating(true);
- factory.setIgnoringElementContentWhitespace(true);
- DocumentBuilder builder = factory.newDocumentBuilder();
- File file = new File("src/test/resources/sdnc_adapter_request.xml");
- Document doc = builder.parse(file);
- return doc;
- }
- public static Document nodeToDocument (Node node) throws ParserConfigurationException {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document newDocument = builder.newDocument();
- Node importedNode = newDocument.importNode(node, true);
- newDocument.appendChild(importedNode);
- return newDocument;
- }
-}
-
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java
deleted file mode 100644
index 72b11708e6..0000000000
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.adapters.sdnc.impl;
-
-import static org.junit.Assert.*;
-
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesException;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-public class RequestTunablesTest {
-
- private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
-
- public static final String SDNC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.sdnc.properties").toString().substring(5);
-
- @Before
- public final void initBeforeEachTest() throws MsoPropertiesException {
- msoPropertiesFactory.removeAllMsoProperties();
- msoPropertiesFactory.initializeMsoProperties("MSO_PROP_SDNC_ADAPTER", SDNC_PROP);
- }
-
- @AfterClass
- public static final void kill () throws MsoPropertiesException {
-
- msoPropertiesFactory.removeMsoProperties("MSO_PROP_SDNC_ADAPTER");
- }
-
- /**
- * Test method for
- * {@link org.openecomp.mso.adapters.sdnc.impl.RequestTunables#RequestTunables(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}
- * .
- */
- @Test
- public final void testRequestTunables () {
- RequestTunables rt = new RequestTunables (null, null, "op", null,msoPropertiesFactory);
- assertEquals(0, rt.getReqId ().length ());
- rt = new RequestTunables ("reqId", "msoAction", null, "query",msoPropertiesFactory);
- rt.setTunables ();
- System.out.println(rt.toString ());
- // assert (rt.getReqMethod ().equals ("toto"));
- assertNotNull(rt.getTimeout ());
- assertEquals("query", rt.getAction ());
- assertEquals("msoAction", rt.getMsoAction ());
- assertEquals("sdnc-request-header", rt.getHeaderName ());
- assertEquals(0, rt.getOperation ().length ());
- assertEquals("N", rt.getAsyncInd ());
- assertEquals("reqId", rt.getReqId ());
- }
-
- @Test
- public final void testRequestTunablesSet() {
- RequestTunables rt = new RequestTunables("reqId", "gammainternet", "service-configuration-operation", "changeactivate", msoPropertiesFactory);
- rt.setTunables ();
- assertNotNull(rt.getTimeout ());
- assertEquals("changeactivate", rt.getAction ());
- assertEquals("gammainternet", rt.getMsoAction ());
- assertEquals("sdnc-request-header", rt.getHeaderName ());
- assertEquals("service-configuration-operation", rt.getOperation ());
- assertEquals("N", rt.getAsyncInd ());
- assertEquals("reqId", rt.getReqId ());
- }
-
-}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java
deleted file mode 100644
index 98b368f5fa..0000000000
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.adapters.sdnc.impl;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.openecomp.mso.HealthCheckUtils;
-import org.openecomp.mso.logger.MsoLogger;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import javax.ws.rs.core.Response;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(SDNCAdapterRestImpl.class)
-public class SDNCAdapterRestImplTest {
-
- SDNCAdapterRestImpl test;
-
- @Before
- public void init(){
-
- test = new SDNCAdapterRestImpl();
- }
-
- @Test
- public void testBadReqNoServiceRsp() {
-
- HealthCheckUtils hCU = PowerMockito.mock(HealthCheckUtils.class);
- try {
- PowerMockito.whenNew(HealthCheckUtils.class).withNoArguments().thenReturn(hCU);
- when(hCU.siteStatusCheck(any(MsoLogger.class))).thenReturn(true);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- String reqXML = "<xml>test</xml>";
-
- Response response = test.MSORequest(reqXML);
- assertEquals(400,response.getStatus());
-
- response = test.healthcheck("1a25a7c0-4c91-4f74-9a78-8c11b7a57f1a");
- assertEquals(503,response.getStatus());
-
- response = test.globalHealthcheck(true);
- assertEquals(503,response.getStatus());
-
- response = test.nodeHealthcheck();
- assertEquals(503,response.getStatus());
-
- }
-
-}
-
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponseTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponseTest.java
deleted file mode 100644
index f9c885f0eb..0000000000
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponseTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 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
-*
-* 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.openecomp.mso.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");
- }
-
- @Test
- public void testtoString()
- {
- assertNotNull(sdncresponse.toString());
- }
-}
- \ No newline at end of file
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java
deleted file mode 100644
index 75cd360663..0000000000
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *l
- * 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.openecomp.mso.adapters.sdnc.notify;
-
-import org.junit.Test;
-import org.mockito.Mock;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Response;
-
-import static org.junit.Assert.assertEquals;
-
-public class SDNCNotifyResourceTest {
-
- @Mock
- HttpServletRequest httpServletRequest;
-
- SDNCNotifyResource test = new SDNCNotifyResource();
-
- @Test
- public void testPrintMessage() {
-
- Response response = test.printMessage();
- assertEquals(200, response.getStatus());
-
- response = test.printMessageParam("msg");
- assertEquals(200, response.getStatus());
-
- String reqXML = "<xml>test</xml>";
- response = test.SDNCNotify(reqXML, httpServletRequest);
- assertEquals(400, response.getStatus());
-
- }
-}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/TypedRequestTunablesTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/TypedRequestTunablesTest.java
deleted file mode 100644
index 5651f8adab..0000000000
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/sdncrest/TypedRequestTunablesTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.adapters.sdnc.sdncrest;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import static junit.framework.Assert.assertEquals;
-
-public class TypedRequestTunablesTest {
-
- @Test
- public void testTypedRequestTunables() {
-
- TypedRequestTunables test = new TypedRequestTunables("reqId","myUrlSuffix");
- test.setServiceKey("service","operation");
- assertEquals(test.getReqId(),"reqId");
- Assert.assertNull(test.getError());
- Assert.assertNull(test.getReqMethod());
- Assert.assertNull(test.getTimeout());
- Assert.assertNull(test.getSdncUrl());
- Assert.assertNull(test.getHeaderName());
- Assert.assertNull(test.getNamespace());
- Assert.assertNull(test.getMyUrl());
- Assert.assertFalse(test.setTunables());
-
- }
-
-}
-