summaryrefslogtreecommitdiffstats
path: root/common/src/test
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-03-14 02:07:32 -0400
committerRob Daugherty <rd472p@att.com>2018-03-14 04:08:41 -0400
commit38f720752af4d4aad8c4e467a288d9048659f688 (patch)
treee81066a8b5c77272e30fb57a64999573c4db4d86 /common/src/test
parentaee3d223f92a6f250f43e17558a2dfd576ff7294 (diff)
AT&T 1712 and 1802 release code
This is code from AT&T's 1712 and 1802 releases. Change-Id: Ie1e85851e94bc66c4d9514a0226c221939531a04 Issue-ID: SO-425 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'common/src/test')
-rw-r--r--common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoLoggerTest.java334
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/AAIConfigurationTest.java75
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/AAIExceptionMapperTest.java63
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/AAIObjectTypeTest.java39
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.java57
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/AAIResourcesClientTest.java96
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/AAITransactionalClientTest.java83
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/AAIURITest.java44
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java98
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/entities/RelationshipsTest.java61
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactoryTest.java40
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUriTest.java194
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriFromUriTest.java59
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriTest.java69
-rw-r--r--common/src/test/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImplTest.java47
-rw-r--r--common/src/test/java/org/openecomp/mso/client/dmaap/DmaapClientTest.java41
-rw-r--r--common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java59
-rw-r--r--common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java185
-rw-r--r--common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java75
-rw-r--r--common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java90
-rw-r--r--common/src/test/java/org/openecomp/mso/client/policy/PolicyClientImplTest.java75
-rw-r--r--common/src/test/java/org/openecomp/mso/client/ruby/RubyCheckClientTest.java106
-rw-r--r--common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java94
-rw-r--r--common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java116
-rw-r--r--common/src/test/java/org/openecomp/mso/jsonpath/JsonPathUtilTest.java49
-rw-r--r--common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequestTest.java44
-rw-r--r--common/src/test/resources/__files/Policy/policyAbortResponse.json1
-rw-r--r--common/src/test/resources/__files/Policy/policySkipResponse.json1
-rw-r--r--common/src/test/resources/__files/aai/bulkprocess/response-failure.json32
-rw-r--r--common/src/test/resources/__files/aai/bulkprocess/response-success.json32
-rw-r--r--common/src/test/resources/__files/aai/bulkprocess/test-request.json22
-rw-r--r--common/src/test/resources/__files/aai/pserver.json14
-rw-r--r--common/src/test/resources/__files/aai/resources/e2e-complex.json660
-rw-r--r--common/src/test/resources/__files/aai/resources/empty-query-result.json3
-rw-r--r--common/src/test/resources/__files/aai/resources/mockObject.json10
-rw-r--r--common/src/test/resources/__files/aai/resources/service-instance-pathed-query.json8
-rw-r--r--common/src/test/resources/__files/grm/endpoints.json145
-rw-r--r--common/src/test/resources/aai.properties1
-rw-r--r--common/src/test/resources/dmaap.properties7
-rw-r--r--common/src/test/resources/mso-bad.json20
-rw-r--r--common/src/test/resources/mso2.json59
-rw-r--r--common/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json15
-rw-r--r--common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json26
-rw-r--r--common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json26
-rw-r--r--common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json22
-rw-r--r--common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json22
-rw-r--r--common/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json25
-rw-r--r--common/src/test/resources/org/openecomp/mso/client/sdno/output-success.json22
-rw-r--r--common/src/test/resources/org/openecomp/mso/client/sdno/response.json17
-rw-r--r--common/src/test/resources/policy.properties4
50 files changed, 3256 insertions, 231 deletions
diff --git a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoLoggerTest.java b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoLoggerTest.java
index 473f5320df..1122c90438 100644
--- a/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoLoggerTest.java
+++ b/common/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoLoggerTest.java
@@ -27,11 +27,13 @@ import org.openecomp.mso.logger.MsoLogger.ErrorCode;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.MDC;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -40,6 +42,7 @@ import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
+
/**
* This class implements all test methods of the MsoLogger features.
*
@@ -49,249 +52,238 @@ public class MsoLoggerTest {
static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
- /**
- * This method is called before any test occurs.
- * It creates a fake tree from scratch
- */
- @BeforeClass
- public static final void prepare () {
-
- }
-
- @Before
- public final void cleanErrorLogFile() throws FileNotFoundException {
- URL url = this.getClass().getClassLoader().getResource("logback-test.xml");
- String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) + "/MSO/Test/errorjboss.server.name_IS_UNDEFINED.log";
- PrintWriter asdcConfigFileWriter = new PrintWriter(logFile);
+ /**
+ * This method is called before any test occurs. It creates a fake tree from
+ * scratch
+ */
+ @BeforeClass
+ public static final void prepare() {
+
+ }
+
+ @Before
+ public final void cleanErrorLogFile() throws FileNotFoundException {
+ URL url = this.getClass().getClassLoader().getResource("logback-test.xml");
+ String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes"))
+ + "/MSO/Test/errorjboss.server.name_IS_UNDEFINED.log";
+ PrintWriter asdcConfigFileWriter = new PrintWriter(logFile);
asdcConfigFileWriter.print("");
asdcConfigFileWriter.flush();
asdcConfigFileWriter.close();
- }
-
- @Before
- public final void cleanMetricLogFile() throws FileNotFoundException {
- URL url = this.getClass().getClassLoader().getResource("logback-test.xml");
- String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) + "/MSO/Test/metricsjboss.server.name_IS_UNDEFINED.log";
- PrintWriter asdcConfigFileWriter = new PrintWriter(logFile);
+ }
+
+ @Before
+ public final void cleanMetricLogFile() throws FileNotFoundException {
+ URL url = this.getClass().getClassLoader().getResource("logback-test.xml");
+ String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes"))
+ + "/MSO/Test/metricsjboss.server.name_IS_UNDEFINED.log";
+ PrintWriter asdcConfigFileWriter = new PrintWriter(logFile);
asdcConfigFileWriter.print("");
asdcConfigFileWriter.flush();
asdcConfigFileWriter.close();
- }
-
- @Before
- public final void cleanAuditLogFile() throws FileNotFoundException {
- URL url = this.getClass().getClassLoader().getResource("logback-test.xml");
- String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) + "/MSO/Test/auditjbo ss.server.name_IS_UNDEFINED.log";
- PrintWriter asdcConfigFileWriter = new PrintWriter(logFile);
+ }
+
+ @Before
+ public final void cleanAuditLogFile() throws FileNotFoundException {
+ URL url = this.getClass().getClassLoader().getResource("logback-test.xml");
+ String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes"))
+ + "/MSO/Test/auditjbo ss.server.name_IS_UNDEFINED.log";
+ PrintWriter asdcConfigFileWriter = new PrintWriter(logFile);
asdcConfigFileWriter.print("");
asdcConfigFileWriter.flush();
asdcConfigFileWriter.close();
- }
+ }
-
-
- /**
- * This method implements a test of getSeverifyLevel method.
- */
+ /**
+ * This method implements a test of getSeverifyLevel method.
+ */
@Test
- public final void testGetSeverityLevel () {
+ public final void testGetSeverityLevel() {
try {
- String levelInfo = (String)invokePriveMethod("getSeverityLevel", "INFO");
- Assert.assertEquals (levelInfo, "0");
+ String levelInfo = (String) invokePriveMethod("getSeverityLevel", "INFO");
+ Assert.assertEquals(levelInfo, "0");
- String levelWarn = (String)invokePriveMethod("getSeverityLevel", "WARN");
- Assert.assertEquals (levelWarn, "1");
+ String levelWarn = (String) invokePriveMethod("getSeverityLevel", "WARN");
+ Assert.assertEquals(levelWarn, "1");
- String levelERROR = (String)invokePriveMethod("getSeverityLevel", "ERROR");
- Assert.assertEquals (levelERROR, "2");
+ String levelERROR = (String) invokePriveMethod("getSeverityLevel", "ERROR");
+ Assert.assertEquals(levelERROR, "2");
- String levelDEBUG = (String)invokePriveMethod("getSeverityLevel", "DEBUG");
- Assert.assertEquals (levelDEBUG, "0");
+ String levelDEBUG = (String) invokePriveMethod("getSeverityLevel", "DEBUG");
+ Assert.assertEquals(levelDEBUG, "0");
- String levelFATAL = (String)invokePriveMethod("getSeverityLevel", "FATAL");
- Assert.assertEquals (levelFATAL, "3");
+ String levelFATAL = (String) invokePriveMethod("getSeverityLevel", "FATAL");
+ Assert.assertEquals(levelFATAL, "3");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- }
+ }
- /**
- * This method implements a test of getFinalServiceName method.
- */
+ /**
+ * This method implements a test of getFinalServiceName method.
+ */
@Test
- public final void testGetFinalServiceName () {
+ public final void testGetFinalServiceName() {
try {
- String serviceName1 = (String)invokePriveMethod("getFinalServiceName", "testServiceName1");
+ String serviceName1 = (String) invokePriveMethod("getFinalServiceName", "testServiceName1");
Assert.assertEquals(serviceName1, "testServiceName1");
MsoLogger.setServiceName("testServiceName2");
- String serviceName2 = (String)invokePriveMethod("getFinalServiceName", "testServiceName1");
+ String serviceName2 = (String) invokePriveMethod("getFinalServiceName", "testServiceName1");
Assert.assertEquals(serviceName2, "testServiceName1");
String msgNull = null;
- String serviceName3 = (String)invokePriveMethod("getFinalServiceName", msgNull);
+ String serviceName3 = (String) invokePriveMethod("getFinalServiceName", msgNull);
Assert.assertEquals(serviceName3, "testServiceName2");
MsoLogger.resetServiceName();
- String serviceName4 = (String)invokePriveMethod("getFinalServiceName", msgNull);
+ String serviceName4 = (String) invokePriveMethod("getFinalServiceName", msgNull);
Assert.assertEquals(serviceName4, "invoke0");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- }
+ }
@Test
- public final void testPrepareMsg () {
+ public final void testPrepareMsg() {
try {
String msgNull = null;
MDC.clear();
invokePrepareMsg("INFO", null, null);
- Assert.assertTrue (MDC.get(MsoLogger.REQUEST_ID).equals("trace-#") && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("trace-#") && MDC.get(MsoLogger.SERVICE_NAME).equals("invoke0")
- && MDC.get(MsoLogger.TIMER) == null && MDC.get(MsoLogger.ALERT_SEVERITY).equals("0"));
+ Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("trace-#")
+ && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("trace-#")
+ && MDC.get(MsoLogger.SERVICE_NAME).equals("invoke0") && MDC.get(MsoLogger.TIMER) == null
+ && MDC.get(MsoLogger.ALERT_SEVERITY).equals("0"));
MsoLogger.setLoggerParameters("testRemoteIp", "testUser");
MsoLogger.setLogContext("testReqId", "testSvcId");
invokePrepareMsg("ERROR", "testServiceName3", null);
- Assert.assertTrue (MDC.get(MsoLogger.REQUEST_ID).equals("testReqId") && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("testSvcId") && MDC.get(MsoLogger.SERVICE_NAME).equals("testServiceName3")
- && MDC.get(MsoLogger.TIMER) == null && MDC.get(MsoLogger.ALERT_SEVERITY).equals("2") );
+ Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("testReqId")
+ && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("testSvcId")
+ && MDC.get(MsoLogger.SERVICE_NAME).equals("testServiceName3") && MDC.get(MsoLogger.TIMER) == null
+ && MDC.get(MsoLogger.ALERT_SEVERITY).equals("2"));
MsoLogger.setServiceName("testServiceName2");
invokePrepareMsg("WARN", msgNull, msgNull);
- Assert.assertTrue (MDC.get(MsoLogger.REQUEST_ID).equals("testReqId") && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("testSvcId") && MDC.get(MsoLogger.SERVICE_NAME).equals("testServiceName2")
- && MDC.get(MsoLogger.TIMER) == null && MDC.get(MsoLogger.ALERT_SEVERITY).equals("1"));
+ Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("testReqId")
+ && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("testSvcId")
+ && MDC.get(MsoLogger.SERVICE_NAME).equals("testServiceName2") && MDC.get(MsoLogger.TIMER) == null
+ && MDC.get(MsoLogger.ALERT_SEVERITY).equals("1"));
- MDC.clear ();
- MsoRequest msoRequest = new MsoRequest ();
- msoRequest.setRequestId ("reqId2");
- msoRequest.setServiceInstanceId ("servId2");
- MsoLogger.setLogContext (msoRequest);
- invokePrepareMsg("FATAL", null, "123");
- Assert.assertTrue (MDC.get(MsoLogger.REQUEST_ID).equals("reqId2") && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("servId2") && MDC.get(MsoLogger.TIMER).equals("123") && MDC.get(MsoLogger.ALERT_SEVERITY).equals("3"));
+ MDC.clear();
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("reqId2");
+ msoRequest.setServiceInstanceId("servId2");
+ MsoLogger.setLogContext(msoRequest);
+ invokePrepareMsg("FATAL", null, "123");
+ Assert.assertTrue(MDC.get(MsoLogger.REQUEST_ID).equals("reqId2")
+ && MDC.get(MsoLogger.SERVICE_INSTANCE_ID).equals("servId2")
+ && MDC.get(MsoLogger.TIMER).equals("123") && MDC.get(MsoLogger.ALERT_SEVERITY).equals("3"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- }
- /**
- * This method implements a test of log methods
- */
+ }
+
+ /**
+ * This method implements a test of log methods
+ */
@Test
- public final void testLogMethods () {
+ @Ignore
+ public final void testLogMethods() {
try {
MDC.clear();
MsoLogger.setLogContext("reqId2", "servId2");
MsoLogger.setServiceName("MSO.testServiceName");
- msoLogger.info (MessageEnum.LOGGER_UPDATE_SUC, "testLogger", "INFO", "DEBUG", "target entity", "target service");
- msoLogger.warn (MessageEnum.GENERAL_WARNING, "warning test", "", "", MsoLogger.ErrorCode.UnknownError, "warning test");
- msoLogger.error (MessageEnum.GENERAL_EXCEPTION, "target entity", "target service", MsoLogger.ErrorCode.UnknownError, "error test");
-
- //Fetch from the error log
+ msoLogger.info(MessageEnum.LOGGER_UPDATE_SUC, "testLogger", "INFO", "DEBUG", "target entity",
+ "target service");
+ msoLogger.warn(MessageEnum.GENERAL_WARNING, "warning test", "", "", MsoLogger.ErrorCode.UnknownError,
+ "warning test");
+ msoLogger.error(MessageEnum.GENERAL_EXCEPTION, "target entity", "target service",
+ MsoLogger.ErrorCode.UnknownError, "error test");
+
+ // Fetch from the error log
URL url = this.getClass().getClassLoader().getResource("logback-test.xml");
- String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) + "/MSO/Test/errorjboss.server.name_IS_UNDEFINED.log";
+ String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes"))
+ + "/MSO/Test/errorjboss.server.name_IS_UNDEFINED.log";
Path filePath = new File(logFile).toPath();
Charset charset = Charset.defaultCharset();
List<String> stringList = Files.readAllLines(filePath, charset);
- String[] stringArray = stringList.toArray(new String[]{});
+ String[] stringArray = stringList.toArray(new String[] {});
int size = stringArray.length;
- Assert.assertTrue(stringArray[size-3].contains("|reqId2|main|MSO.testServiceName||target entity|target service|INFO|null||") && stringArray[size-3].contains("||MSO-GENERAL-5408I Successfully update Logger: testLogger from level INFO to level DEBUG"));
- Assert.assertTrue(stringArray[size-2].contains("|reqId2|main|MSO.testServiceName||||WARN|UnknownError|warning test|") && stringArray[size-2].contains("|MSO-GENERAL-5401W WARNING: warning test"));
- Assert.assertTrue(stringArray[size-1].contains("|reqId2|main|MSO.testServiceName||target entity|target service|ERROR|UnknownError|error test|") && stringArray[size-1].contains("|MSO-GENERAL-9401E Exception encountered"));
-
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- /**
- * This method implements a test of recordMetricEvent method.
- */
- @Test
- public final void testRecordMetricEvent () {
- try {
- MDC.clear();
- MsoLogger.setLogContext("reqId", "servId");
- msoLogger.recordMetricEvent(123456789L, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful", "VNF" , "createVNF", null);
- MDC.put (MsoLogger.REMOTE_HOST, "127.0.0.1");
- MDC.put (MsoLogger.PARTNERNAME, "testUser");
- msoLogger.recordMetricEvent(123456789L, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable, "Exception", "SDNC", "removeSDNC", "testVNF");
-
- //Fetch from the metric log
- URL url = this.getClass().getClassLoader().getResource("logback-test.xml");
- String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) + "/MSO/Test/metricsjboss.server.name_IS_UNDEFINED.log";
-
- Path filePath = new File(logFile).toPath();
- Charset charset = Charset.defaultCharset();
- List<String> stringList = Files.readAllLines(filePath, charset);
- String[] stringArray = stringList.toArray(new String[]{});
- msoLogger.error (MessageEnum.GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.UnknownError, "test error msg");
-
- Assert.assertTrue(stringArray[0].contains("|reqId|servId|main||testRecordMetricEvent||VNF|createVNF|COMPLETE|0|Successful|Test UUID as JBoss not found|INFO|0|"));
- // count the occurance of symbol "|"
- Assert.assertTrue ((stringArray[0].length() - stringArray[0].replace("|", "").length()) == 28);
- Assert.assertTrue(stringArray[1].contains("|reqId|servId|main||testRecordMetricEvent|testUser|SDNC|removeSDNC|ERROR|501|Exception|Test UUID as JBoss not found|INFO|0|") && stringArray[1].contains("|127.0.0.1||||testVNF|||||"));
- Assert.assertTrue ((stringArray[1].length() - stringArray[1].replace("|", "").length()) == 28);
+ Assert.assertTrue(stringArray[size - 3]
+ .contains("|reqId2|main|MSO.testServiceName||target entity|target service|INFO|null||")
+ && stringArray[size - 3].contains(
+ "||MSO-GENERAL-5408I Successfully update Logger: testLogger from level INFO to level DEBUG"));
+ Assert.assertTrue(stringArray[size - 2]
+ .contains("|reqId2|main|MSO.testServiceName||||WARN|UnknownError|warning test|")
+ && stringArray[size - 2].contains("|MSO-GENERAL-5401W WARNING: warning test"));
+ Assert.assertTrue(stringArray[size - 1].contains(
+ "|reqId2|main|MSO.testServiceName||target entity|target service|ERROR|UnknownError|error test|")
+ && stringArray[size - 1].contains("|MSO-GENERAL-9401E Exception encountered"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- }
+ }
- /**
- * This method implements a test of testRecordAuditEvent method.
- */
+ /**
+ * This method implements a test of recordMetricEvent method.
+ *
+ * @throws IOException
+ */
@Test
- public final void testRecordAuditEvent () {
-
- try {
-
- MDC.clear();
- MsoLogger.setLogContext("reqId", "servId");
- msoLogger.recordAuditEvent(123456789L, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
- MDC.put (MsoLogger.REMOTE_HOST, "127.0.0.1");
- MDC.put (MsoLogger.PARTNERNAME, "testUser");
- msoLogger.recordAuditEvent(123456789L, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable, "Exception");
-
- //Fetch from the metric log
- URL url = this.getClass().getClassLoader().getResource("logback-test.xml");
- String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes")) + "/MSO/Test/auditjboss.server.name_IS_UNDEFINED.log";
-
- Path filePath = new File(logFile).toPath();
- Charset charset = Charset.defaultCharset();
- List<String> stringList = Files.readAllLines(filePath, charset);
- String[] stringArray = stringList.toArray(new String[]{});
- msoLogger.error (MessageEnum.GENERAL_EXCEPTION, "", "", ErrorCode.UnknownError, "log error");
-
- Assert.assertTrue (stringArray[0].contains("|reqId|servId|main||testRecordAuditEvent||COMPLETE|0|Successful|Test UUID as JBoss not found|INFO|0|"));
- // count the occurance of symbol "|"
- Assert.assertTrue ((stringArray[0].length() - stringArray[0].replace("|", "").length()) == 25);
- Assert.assertTrue (stringArray[1].contains("|reqId|servId|main||testRecordAuditEvent|testUser|ERROR|501|Exception|Test UUID as JBoss not found|INFO|0|") && stringArray[1].contains("|127.0.0.1||||||||"));
- Assert.assertTrue ((stringArray[1].length() - stringArray[1].replace("|", "").length()) == 25);
-
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
-
-
-
- // User reflection to invoke to avoid change the publicity of the method
- private static String invokePrepareMsg (String arg1, String arg2, String arg3) {
- Method method;
+ @Ignore
+ public final void testRecordMetricEvent() throws IOException {
+ MDC.clear();
+ MsoLogger.setLogContext("reqId", "servId");
+ msoLogger.recordMetricEvent(123456789L, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful",
+ "VNF", "createVNF", null);
+ MDC.put(MsoLogger.REMOTE_HOST, "127.0.0.1");
+ MDC.put(MsoLogger.PARTNERNAME, "testUser");
+ msoLogger.recordMetricEvent(123456789L, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable,
+ "Exception", "SDNC", "removeSDNC", "testVNF");
+
+ // Fetch from the metric log
+ URL url = this.getClass().getClassLoader().getResource("logback-test.xml");
+ String logFile = url.getFile().substring(0, url.getFile().indexOf("test-classes"))
+ + "/MSO/Test/metricsjboss.server.name_IS_UNDEFINED.log";
+
+ Path filePath = new File(logFile).toPath();
+ Charset charset = Charset.defaultCharset();
+ List<String> stringList = Files.readAllLines(filePath, charset);
+ String[] stringArray = stringList.toArray(new String[] {});
+ msoLogger.error(MessageEnum.GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.UnknownError, "test error msg");
+
+ Assert.assertTrue(stringArray[0]
+ .contains("|reqId|servId|main||testRecordMetricEvent||VNF|createVNF|COMPLETE|0|Successful|"));
+ // count the occurance of symbol "|"
+ Assert.assertTrue((stringArray[0].length() - stringArray[0].replace("|", "").length()) == 28);
+ Assert.assertTrue(stringArray[1]
+ .contains("|reqId|servId|main||testRecordMetricEvent|testUser|SDNC|removeSDNC|ERROR|501|Exception|")
+ && stringArray[1].contains("|127.0.0.1||||testVNF|||||"));
+ Assert.assertTrue((stringArray[1].length() - stringArray[1].replace("|", "").length()) == 28);
+ }
+
+ /**
+ * This method implements a test of testRecordAuditEvent method.
+ */
+
+ // User reflection to invoke to avoid change the publicity of the method
+ private static String invokePrepareMsg(String arg1, String arg2, String arg3) {
+ Method method;
try {
method = MsoLogger.class.getDeclaredMethod("prepareMsg", String.class, String.class, String.class);
method.setAccessible(true);
- return (String)method.invoke(msoLogger, arg1, arg2, arg3);
+ return (String) method.invoke(msoLogger, arg1, arg2, arg3);
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -308,16 +300,16 @@ public class MsoLoggerTest {
// TODO Auto-generated catch block
e.printStackTrace();
}
- return null;
- }
+ return null;
+ }
- // User reflection to invoke to avoid change the publicity of the method
- private static Object invokePriveMethod (String methodName, String arg) {
- Method method;
+ // User reflection to invoke to avoid change the publicity of the method
+ private static Object invokePriveMethod(String methodName, String arg) {
+ Method method;
try {
method = MsoLogger.class.getDeclaredMethod(methodName, String.class);
method.setAccessible(true);
- return method.invoke(msoLogger, arg);
+ return method.invoke(msoLogger, arg);
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -334,6 +326,6 @@ public class MsoLoggerTest {
// TODO Auto-generated catch block
e.printStackTrace();
}
- return null;
- }
+ return null;
+ }
}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIConfigurationTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIConfigurationTest.java
new file mode 100644
index 0000000000..da63b27efb
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/AAIConfigurationTest.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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.client.aai;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static org.junit.Assert.assertEquals;
+
+import java.util.UUID;
+
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.openecomp.mso.client.aai.entities.uri.AAIUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+import org.openecomp.mso.serviceinstancebeans.ModelInfo;
+import org.openecomp.mso.serviceinstancebeans.RequestDetails;
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+
+public class AAIConfigurationTest {
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443));
+
+ @Ignore
+ @Test
+ public void verifyCreate() {
+ AAIConfigurationClient aaiConfiguration = new AAIConfigurationClient();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelInvariantId("testInvariantID");
+ modelInfo.setModelVersionId("testVersionID");
+ modelInfo.setModelCustomizationId("testCustomizationID");
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setModelInfo(modelInfo);
+ String configurationType = "test";
+ String configurationSubType = "test";
+ aaiConfiguration.createConfiguration(requestDetails, UUID.randomUUID().toString(), configurationType, configurationSubType);
+ }
+
+ @Test
+ public void verifyNotExists() {
+ AAIUri path = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "test2");
+ wireMockRule.stubFor(get(
+ urlPathEqualTo("/aai/v11" + path.build()))
+ .willReturn(
+ aResponse()
+ .withHeader("Content-Type", "text/plain")
+ .withBody("hello")
+ .withStatus(404)));
+ AAIConfigurationClient aaiConfiguration = new AAIConfigurationClient();
+ boolean result = aaiConfiguration.configurationExists("test2");
+ assertEquals("path not found", false, result);
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIExceptionMapperTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIExceptionMapperTest.java
new file mode 100644
index 0000000000..625e281792
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/AAIExceptionMapperTest.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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.client.aai;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.mso.client.aai.entities.AAIError;
+
+public class AAIExceptionMapperTest {
+
+ @Mock private AAIError errorObj;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ }
+ @Test
+ public void nestedReplace() {
+ String error = "Error %1 on %2";
+ List<String> list = Arrays.asList("PUT", "hello %1");
+ AAIErrorFormatter formatter = new AAIErrorFormatter(errorObj);
+ String result = formatter.fillInTemplate(error, list);
+ assertEquals("equal", "Error PUT on hello PUT", result);
+
+ }
+
+ @Test
+ public void noReplace() {
+ String error = "Error";
+ List<String> list = new ArrayList<>();
+ AAIErrorFormatter formatter = new AAIErrorFormatter(errorObj);
+ String result = formatter.fillInTemplate(error, list);
+ assertEquals("equal", "Error", result);
+
+ }
+
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIObjectTypeTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIObjectTypeTest.java
new file mode 100644
index 0000000000..c8f6299d81
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/AAIObjectTypeTest.java
@@ -0,0 +1,39 @@
+/*-
+ * ============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.client.aai;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class AAIObjectTypeTest {
+
+ @Test
+ public void verifyDefaultCase() {
+ assertEquals("default removed for tenant", "tenant", AAIObjectType.DEFAULT_TENANT.typeName());
+ assertEquals("default removed for cloud-region", "cloud-region", AAIObjectType.DEFAULT_CLOUD_REGION.typeName());
+ }
+
+ @Test
+ public void verifyRegularCase() {
+ assertEquals("default removed for tenant", "allotted-resource", AAIObjectType.ALLOTTED_RESOURCE.typeName());
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.java
new file mode 100644
index 0000000000..b6b01b384a
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.java
@@ -0,0 +1,57 @@
+/*-
+ * ============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.client.aai;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.NoSuchAlgorithmException;
+import java.util.List;
+import java.util.UUID;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.aai.domain.yang.Pserver;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+public class AAIPServerTest {
+
+ @Test
+ public void pserverTest() throws JsonParseException, JsonMappingException, IOException, NoSuchAlgorithmException {
+ AAIRestClientImpl client = new AAIRestClientImpl();
+ String json = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/aai/pserver.json")));
+ List<Pserver> list = client.getListOfPservers(json);
+
+ assertEquals("", list.get(0).getHostname(), "test");
+ }
+
+ @Test
+ @Ignore // IGNORED FOR 1710 MERGE TO ONAP
+ public void pserverActualTest() throws JsonParseException, JsonMappingException, IOException, NoSuchAlgorithmException {
+ AAIRestClientImpl client = new AAIRestClientImpl();
+ List<Pserver> list = client.getPhysicalServerByVnfId("d946afed-8ebe-4c5d-9665-54fcc043b8e7", UUID.randomUUID().toString());
+ assertEquals("", list.size(), 0);
+ }
+
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIResourcesClientTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIResourcesClientTest.java
new file mode 100644
index 0000000000..daf8130cd4
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/AAIResourcesClientTest.java
@@ -0,0 +1,96 @@
+/*-
+ * ============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.client.aai;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.delete;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+public class AAIResourcesClientTest {
+
+
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443));
+
+ @Test
+ public void verifyNotExists() {
+ AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test");
+ wireMockRule.stubFor(get(
+ urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString()))
+ .willReturn(
+ aResponse()
+ .withHeader("Content-Type", "text/plain")
+ .withBody("hello")
+ .withStatus(404)));
+ AAIResourcesClient client = new AAIResourcesClient();
+ boolean result = client.exists(path);
+ assertEquals("path not found", false, result);
+ }
+
+ @Test
+ public void verifyDelete() {
+ AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2");
+ wireMockRule.stubFor(get(
+ urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString()))
+ .willReturn(
+ aResponse()
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("aai/resources/mockObject.json")
+ .withStatus(200)));
+ wireMockRule.stubFor(delete(
+ urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString()))
+ .withQueryParam("resource-version", equalTo("1234"))
+ .willReturn(
+ aResponse()
+ .withStatus(204)));
+ AAIResourcesClient client = new AAIResourcesClient();
+ client.delete(path);
+ }
+
+ @Test
+ public void verifyConnect() {
+ AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test2");
+ AAIResourceUri path2 = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3");
+ wireMockRule.stubFor(put(
+ urlPathEqualTo("/aai/" + AAIVersion.LATEST + path.build().toString() + "/relationship-list/relationship"))
+ .willReturn(
+ aResponse()
+ .withHeader("Content-Type", "application/json")
+ .withStatus(200)));
+
+ AAIResourceUri pathClone = path.clone();
+ AAIResourcesClient client = new AAIResourcesClient();
+ client.connect(path, path2);
+ assertEquals("uri not modified", pathClone.build().toString(), path.build().toString());
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAITransactionalClientTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAITransactionalClientTest.java
new file mode 100644
index 0000000000..1abb940f6e
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/AAITransactionalClientTest.java
@@ -0,0 +1,83 @@
+/*-
+ * ============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.client.aai;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Map;
+import java.util.Optional;
+
+import org.junit.Test;
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
+public class AAITransactionalClientTest {
+
+
+ private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/bulkprocess/";
+
+ @Test
+ public void run() throws IOException {
+
+
+ AAIResourcesClient client = new AAIResourcesClient();
+ AAIResourceUri uriA = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1");
+ AAIResourceUri uriB = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test2");
+ AAIResourceUri uriC = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test3");
+ AAIResourceUri uriD = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test4");
+ AAIResourceUri uriE = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test5");
+ AAIResourceUri uriF = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test6");
+
+ AAIResourceUri uriAClone = uriA.clone();
+ AAITransactionalClient transactions = client
+ .beginTransaction().connect(uriA, uriB).connect(uriC, uriD)
+ .beginNewTransaction().connect(uriE, uriF);
+ ObjectMapper mapper = new AAICommonObjectMapperProvider().getMapper();
+ mapper.enable(SerializationFeature.INDENT_OUTPUT);
+ String serializedTransactions = mapper.writeValueAsString(transactions.getTransactions());
+ Map<String, Object> map1 = mapper.readValue(serializedTransactions, new TypeReference<Map<String, Object>>(){});
+ Map<String, Object> map2 = mapper.readValue(getJson("test-request.json"), new TypeReference<Map<String, Object>>(){});
+ assertEquals("payloads are equal", map2, map1);
+ assertEquals("uri not manipulated", uriAClone.build().toString(), uriA.build().toString());
+ }
+
+ @Test
+ public void verifyResponse() throws IOException {
+ AAIResourcesClient client = new AAIResourcesClient();
+ AAITransactionalClient transactions = client
+ .beginTransaction();
+ assertEquals("success status", Optional.empty(), transactions.locateErrorMessages(getJson("response-success.json")));
+ assertEquals(transactions.locateErrorMessages(getJson("response-failure.json")).get(), "another error message\nmy great error");
+
+
+ }
+
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + filename)));
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIURITest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIURITest.java
new file mode 100644
index 0000000000..366c587b11
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/AAIURITest.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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.client.aai;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.ws.rs.core.UriBuilder;
+
+import org.junit.Test;
+import org.openecomp.mso.client.aai.entities.uri.AAIUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+
+public class AAIURITest {
+
+
+
+
+ @Test
+ public void verifyTemplateReplacement() {
+ final String id = "test1";
+ AAIUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, id);
+ String manualReplace = AAIObjectType.CONFIGURATION.toString().replaceAll("\\{configuration-id\\}", id);
+ assertEquals("uri template replaced", aaiUri.build(), UriBuilder.fromPath(manualReplace).build());
+
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java b/common/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java
new file mode 100644
index 0000000000..12034e0eea
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java
@@ -0,0 +1,98 @@
+/*-
+ * ============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.client.aai;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.Pserver;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AAIValidatorTest {
+
+ @Mock
+ protected AAIRestClientI client;
+ String vnfName = "testVnf";
+ String uuid = "UUID";
+ AAIValidatorImpl validator;
+
+ @Before
+ public void init(){
+ validator = new AAIValidatorImpl();
+ validator.setClient(client);
+ }
+
+ public List<Pserver> getPservers(boolean locked){
+ Pserver pserver = new Pserver();
+ pserver.setInMaint(locked);
+ List<Pserver> pservers = new ArrayList<Pserver>();
+ pservers.add(pserver);
+ return pservers;
+ }
+
+ public GenericVnf createGenericVnfs(boolean locked){
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setInMaint(locked);
+ return genericVnf;
+ }
+
+ @Test
+ public void test_IsPhysicalServerLocked_True() throws IOException{
+ when(client.getPhysicalServerByVnfId(vnfName,uuid)).thenReturn(getPservers(true));
+ boolean locked = validator.isPhysicalServerLocked(vnfName, uuid);
+ assertEquals(true, locked);
+ }
+
+ @Test
+ public void test_IsPhysicalServerLocked_False() throws JsonParseException, JsonMappingException, UnsupportedEncodingException, IOException {
+ when(client.getPhysicalServerByVnfId(vnfName,uuid)).thenReturn(getPservers(false));
+ boolean locked = validator.isPhysicalServerLocked(vnfName, uuid);
+ assertEquals(false, locked);
+ }
+
+ @Test
+ public void test_IsVNFLocked_False() throws Exception{
+ when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(false));
+ boolean locked = validator.isVNFLocked(vnfName, uuid);
+ assertEquals(false, locked);
+ }
+
+ @Test
+ public void test_IsVNFLocked_True() throws Exception{
+ when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(true));
+ boolean locked = validator.isVNFLocked(vnfName, uuid);
+ assertEquals(true,locked );
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/RelationshipsTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/RelationshipsTest.java
new file mode 100644
index 0000000000..b2c1f9ed64
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/entities/RelationshipsTest.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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.client.aai.entities;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.openecomp.mso.client.aai.AAIObjectType;
+import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
+import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
+
+public class RelationshipsTest {
+
+ private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/resources/";
+
+ @Test
+ public void run() throws IOException {
+ final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "e2e-complex.json")));
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(content);
+ Relationships relationships = wrapper.getRelationships().get();
+
+ List<AAIResourceUri> test = relationships.getRelatedAAIUris(AAIObjectType.VCE);
+
+ System.out.println(test.get(0).build());
+ List<AAIResourceUri> uris = Arrays.asList(
+ AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a9fec18e-1ea3-40e4-a6c0-a89b3de07053"),
+ AAIUriFactory.createResourceUri(AAIObjectType.VCE, "8ae1e5f8-61f1-4c71-913a-b40cc4593cb9"),
+ AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a2935fa9-b743-49f4-9813-a127f13c4e93"),
+ AAIUriFactory.createResourceUri(AAIObjectType.VCE, "c7fe7698-8063-4e26-8bd3-ca3edde0b0d4"));
+
+
+ assertTrue(uris.containsAll(test) && test.containsAll(uris));
+
+ }
+
+} \ No newline at end of file
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactoryTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactoryTest.java
new file mode 100644
index 0000000000..a62d4b89c6
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/AAIUriFactoryTest.java
@@ -0,0 +1,40 @@
+/*-
+ * ============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.client.aai.entities.uri;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.openecomp.mso.client.aai.AAIObjectType;
+
+public class AAIUriFactoryTest {
+
+
+
+ @Test
+ public void automaticallyEncodeUriTemplateValue() {
+
+ AAIUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "VIP(VelocitytoIP)");
+
+ String expected = "/network/generic-vnfs/generic-vnf/VIP%28VelocitytoIP%29";
+ assertEquals(expected, uri.build().toString());
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUriTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUriTest.java
new file mode 100644
index 0000000000..12ca0a2709
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/ServiceInstanceUriTest.java
@@ -0,0 +1,194 @@
+/*-
+ * ============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.client.aai.entities.uri;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static com.github.tomakehurst.wiremock.client.WireMock.containing;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Optional;
+
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.core.UriBuilder;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Matchers;
+import org.openecomp.mso.client.aai.AAIObjectType;
+import org.openecomp.mso.client.aai.AAIQueryClient;
+import org.openecomp.mso.client.aai.Format;
+import org.openecomp.mso.client.aai.entities.CustomQuery;
+import org.openecomp.mso.client.aai.exceptions.AAIPayloadException;
+import org.openecomp.mso.client.aai.exceptions.AAIUriComputationException;
+import org.openecomp.mso.client.aai.exceptions.AAIUriNotFoundException;
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+
+public class ServiceInstanceUriTest {
+
+ private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/resources/";
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443));
+
+ @Rule
+ public final ExpectedException exception = ExpectedException.none();
+
+ @Test
+ public void found() throws IOException {
+ final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "service-instance-pathed-query.json")));
+
+ ServiceInstanceUri instance = new ServiceInstanceUri("key3");
+ final Optional<String> result = instance.extractRelatedLink(content);
+ final String expected = "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3";
+ assertEquals("result is equal", expected, result.get());
+
+ }
+
+ @Test
+ public void oneKey() throws IOException, URISyntaxException, AAIUriNotFoundException, AAIPayloadException {
+
+ ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri spy = spy(instance);
+ doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").when(spy).getSerivceInstance(any(Object.class));
+
+ final URI result = spy.build();
+ final URI expected = UriBuilder.fromPath("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").build();
+ assertEquals("result is equal", expected, result);
+
+ }
+
+ @Test
+ public void oneKeyQueryParams() throws IOException, URISyntaxException, AAIUriNotFoundException, AAIPayloadException {
+
+ ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri spy = spy(instance);
+ doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").when(spy).getSerivceInstance(any(Object.class));
+
+ final URI result = spy.resourceVersion("1234").build();
+ final URI expected = UriBuilder.fromUri("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3?resource-version=1234").build();
+ assertEquals("result is equal", expected, result);
+
+ }
+
+ @Test
+ public void oneKeyEncoded() throws IOException, URISyntaxException, AAIUriNotFoundException, AAIPayloadException {
+
+ ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri spy = spy(instance);
+ doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%20space").when(spy).getSerivceInstance(any(Object.class));
+
+ final URI result = spy.build();
+ final URI expected = UriBuilder.fromUri("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%20space").build();
+ assertEquals("result is equal", expected, result);
+
+ }
+
+ @Test
+ public void oneKeyGetKeys() throws IOException, URISyntaxException, AAIUriNotFoundException, AAIPayloadException {
+
+ ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri spy = spy(instance);
+ doReturn("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3%28space").when(spy).getSerivceInstance(any(Object.class));
+
+ assertThat(spy.getURIKeys().values(), contains("key1", "key2", "key3(space"));
+
+ }
+ @Test
+ public void oneKeyClone() throws AAIUriNotFoundException, AAIPayloadException {
+ ServiceInstanceUri instance = new ServiceInstanceUri("key1");
+ ServiceInstanceUri spy = spy(instance);
+ String uri = "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3";
+ doReturn(uri).when(spy).getSerivceInstance(any(Object.class));
+ doReturn(Optional.of(uri)).when(spy).getCachedValue();
+ final URI result = spy.resourceVersion("1234").clone().build();
+ final URI expected = UriBuilder.fromUri("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3?resource-version=1234").build();
+ assertEquals("result is equal", expected, result);
+ }
+
+ @Test
+ public void threeKey() throws IOException {
+
+ ServiceInstanceUri instance = new ServiceInstanceUri("key1", "key2", "key3");
+ final URI result = instance.build();
+ final URI expected = UriBuilder.fromPath("/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3").build();
+ assertEquals("result is equal", expected, result);
+
+ }
+
+ @Test
+ public void notfound() throws IOException, AAIUriNotFoundException, AAIPayloadException {
+ final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "empty-query-result.json")));
+
+ ServiceInstanceUri instance = new ServiceInstanceUri("key3");
+ ServiceInstanceUri spy = spy(instance);
+ AAIQueryClient mockQueryClient = mock(AAIQueryClient.class);
+ when(mockQueryClient.query(any(Format.class), any(CustomQuery.class))).thenReturn(content);
+ when(spy.getQueryClient()).thenReturn(mockQueryClient);
+ exception.expect(AAIUriComputationException.class);
+ spy.build();
+
+ }
+
+ @Test
+ public void cloneTest() {
+ ServiceInstanceUri instance = new ServiceInstanceUri("key1", "key2", "key3");
+ final URI result = instance.build();
+ final URI result2 = instance.clone().queryParam("something", "new").build();
+ assertEquals("uris are not equal", false, result.toString().equals(result2.toString()));
+
+ }
+
+ @Test
+ public void noVertexFound() throws AAIUriNotFoundException, AAIPayloadException {
+ ServiceInstanceUri instance = new ServiceInstanceUri("key3");
+ ServiceInstanceUri spy = spy(instance);
+ stubFor(put(urlMatching("/aai/v[0-9]+/query.*"))
+ .withRequestBody(containing("key3"))
+ .willReturn(aResponse()
+ .withStatus(400)
+ .withHeader("Content-Type", "application/json")
+ .withBodyFile("")));
+ exception.expect(AAIUriComputationException.class);
+ exception.expectMessage(containsString("NotFoundException"));
+ spy.build();
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriFromUriTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriFromUriTest.java
new file mode 100644
index 0000000000..6e3ab64108
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriFromUriTest.java
@@ -0,0 +1,59 @@
+/*-
+ * ============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.client.aai.entities.uri;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.ws.rs.core.UriBuilder;
+
+import org.junit.Test;
+import org.openecomp.mso.client.aai.AAIObjectType;
+
+public class SimpleUriFromUriTest {
+
+
+
+ @Test
+ public void removeHost() {
+
+ AAIUri uri = new SimpleUri(AAIObjectType.UNKNOWN, UriBuilder.fromUri("https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053").build());
+
+ assertEquals("root and version removed", "/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString());
+
+ }
+ @Test
+ public void noChange() {
+
+ AAIUri uri = new SimpleUri(AAIObjectType.UNKNOWN, UriBuilder.fromUri("/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053").build());
+
+ assertEquals("no change", "/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString());
+
+ }
+
+ @Test
+ public void encodingPreserved() {
+
+ AAIUri uri = new SimpleUri(AAIObjectType.UNKNOWN, UriBuilder.fromUri("/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053").build());
+
+ assertEquals("encoding preserved", "/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString());
+
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriTest.java
new file mode 100644
index 0000000000..f4fe216cd2
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/SimpleUriTest.java
@@ -0,0 +1,69 @@
+/*-
+ * ============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.client.aai.entities.uri;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Map;
+
+import org.junit.Test;
+import org.openecomp.mso.client.aai.AAIObjectPlurals;
+import org.openecomp.mso.client.aai.AAIObjectType;
+
+public class SimpleUriTest {
+
+
+
+ @Test
+ public void relatedToTestPlural() {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1");
+ uri.relatedTo(AAIObjectPlurals.PSERVER);
+ String uriOutput = uri.build().toString();
+ assertEquals(true, uriOutput.contains("related-to"));
+ }
+
+ @Test
+ public void relatedToTestSingular() {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1");
+ uri.relatedTo(AAIObjectType.PSERVER, "test2");
+ String uriOutput = uri.build().toString();
+ assertEquals(true, uriOutput.contains("related-to"));
+ }
+
+ @Test
+ public void cloneTest() {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test1");
+ AAIResourceUri cloned = uri.clone();
+ Map<String,String> keys = cloned.getURIKeys();
+ assertThat(keys.values(), contains("test1"));
+ }
+
+ @Test
+ public void getKeysTest() {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, "cloud1", "cloud2", "tenant1", "vserver1");
+ Map<String,String> keys = uri.getURIKeys();
+ System.out.println(keys);
+ System.out.println(uri.build());
+ assertEquals("vserver1", keys.get("vserver-id"));
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImplTest.java b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImplTest.java
new file mode 100644
index 0000000000..e8d98718a4
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/aai/entities/uri/parsers/UriParserSpringImplTest.java
@@ -0,0 +1,47 @@
+/*-
+ * ============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.client.aai.entities.uri.parsers;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Map;
+
+import org.junit.Test;
+import org.openecomp.mso.client.aai.AAIObjectType;
+
+public class UriParserSpringImplTest {
+
+
+
+
+ @Test
+ public void reverseTemplate() {
+ final UriParser parser = new UriParserSpringImpl(AAIObjectType.SERVICE_INSTANCE.toString());
+ final String uri = "/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3";
+
+ Map<String, String> result = parser.parse(uri);
+
+ assertEquals("found customer-id", "key1", result.get("global-customer-id"));
+ assertEquals("found service-type", "key2", result.get("service-type"));
+ assertEquals("found service-instance-id", "key3", result.get("service-instance-id"));
+
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/dmaap/DmaapClientTest.java b/common/src/test/java/org/openecomp/mso/client/dmaap/DmaapClientTest.java
new file mode 100644
index 0000000000..dda7754712
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/dmaap/DmaapClientTest.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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.client.dmaap;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.junit.Test;
+import org.openecomp.mso.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer;
+
+public class DmaapClientTest {
+
+ @Test
+ public void deobfuscateTest() throws FileNotFoundException, IOException {
+ String encodedBase64 = "dGVzdHBhc3N3b3Jk";
+ String notEncoded = "testpassword";
+ DmaapConsumer consumer = new SDNOHealthCheckDmaapConsumer();
+ assertEquals("decoded password", notEncoded, consumer.deobfuscatePassword(encodedBase64));
+
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java b/common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java
new file mode 100644
index 0000000000..ef2d984af4
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java
@@ -0,0 +1,59 @@
+/*-
+ * ============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.client.grm;
+
+import java.util.List;
+
+import org.junit.Test;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.affirm.Affirm;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+public class GRMBeansTest {
+ private static final int EXPECTED_CLASS_COUNT = 10;
+ private static final String POJO_PACKAGE = "org.openecomp.mso.client.grm.beans";
+
+ @Test
+ public void ensureExpectedPojoCount() {
+ List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses( POJO_PACKAGE, new FilterPackageInfo());
+ Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size());
+ }
+
+ @Test
+ public void testPojoStructureAndBehavior() {
+ Validator validator = ValidatorBuilder.create()
+ .with(new GetterMustExistRule())
+ .with(new SetterMustExistRule())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .build();
+
+ validator.validate(POJO_PACKAGE, new FilterPackageInfo());
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java b/common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java
new file mode 100644
index 0000000000..6865bbd773
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java
@@ -0,0 +1,185 @@
+/*-
+ * ============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.client.grm;
+
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.core.MediaType;
+
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.openecomp.mso.client.grm.exceptions.GRMClientCallFailed;
+import org.openecomp.mso.client.grm.GRMClient;
+import org.openecomp.mso.client.grm.beans.ServiceEndPointRequest;
+import org.openecomp.mso.client.grm.beans.OperationalInfo;
+import org.openecomp.mso.client.grm.beans.Property;
+import org.openecomp.mso.client.grm.beans.ServiceEndPoint;
+import org.openecomp.mso.client.grm.beans.ServiceEndPointList;
+import org.openecomp.mso.client.grm.beans.ServiceEndPointLookupRequest;
+import org.openecomp.mso.client.grm.beans.Version;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+
+public class GRMClientTest {
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(28090));
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void testFind() throws Exception {
+ String endpoints = getFileContentsAsString("__files/grm/endpoints.json");
+ wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", MediaType.APPLICATION_JSON)
+ .withBody(endpoints)));
+
+
+ GRMClient client = new GRMClient();
+ ServiceEndPointList sel = client.findRunningServices("TEST.ECOMP_PSL.*", 1, "TEST");
+ List<ServiceEndPoint> list = sel.getServiceEndPointList();
+ assertEquals(3, list.size());
+ }
+
+ @Test(expected = GRMClientCallFailed.class)
+ public void testFindFail() throws Exception {
+
+ wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
+ .willReturn(aResponse()
+ .withStatus(400)
+ .withHeader("Content-Type", MediaType.APPLICATION_JSON)
+ .withBody("")));
+
+ GRMClient client = new GRMClient();
+ client.findRunningServices("TEST.ECOMP_PSL.*", 1, "TEST");
+ }
+
+ @Ignore
+ @Test
+ public void testAdd() throws Exception {
+
+ wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/add"))
+ .willReturn(aResponse()
+ .withStatus(202)
+ .withHeader("Content-Type", MediaType.APPLICATION_JSON)
+ .withBody("test")));
+ wireMockRule.addMockServiceRequestListener((request, response) -> {
+ System.out.println("URL Requested => " + request.getAbsoluteUrl());
+ System.out.println("Request Body => " + request.getBodyAsString());
+ System.out.println("Request Headers => " + request.getHeaders().toString());
+ System.out.println("Response Status => " + response.getStatus());
+ System.out.println("Response Body => " + response.getBodyAsString());
+ });
+
+ Version ver = new Version();
+ ver.setMajor(1);
+ ver.setMinor(0);
+ ver.setPatch("0");
+
+ ServiceEndPoint sep = new ServiceEndPoint();
+ sep.setName("TEST.ECOMP_PSL.Inventory");
+ sep.setVersion(ver);
+ sep.setHostAddress("127.0.0.1");
+ sep.setListenPort("8080");
+ sep.setLatitude("37.7022");
+ sep.setLongitude("121.9358");
+ sep.setContextPath("/");
+ sep.setRouteOffer("TEST");
+
+ OperationalInfo operInfo = new OperationalInfo();
+ operInfo.setCreatedBy("edge");
+ operInfo.setUpdatedBy("edge");
+
+ sep.setOperationalInfo(operInfo);
+
+ Property prop1 = new Property();
+ prop1.setName("Environment");
+ prop1.setValue("TEST");
+
+ Property prop2 = new Property();
+ prop2.setName("cpfrun_cluster_name");
+ prop2.setValue("testcase_cluster_no_cluster");
+
+ List<Property> props = new ArrayList<Property>();
+ props.add(prop1);
+ props.add(prop2);
+
+ sep.setProperties(props);
+
+ ServiceEndPointRequest request = new ServiceEndPointRequest();
+ request.setEnv("DEV");
+ request.setServiceEndPoint(sep);
+
+ System.out.println("Request in JSON: " + mapper.writeValueAsString(request));
+
+ GRMClient client = new GRMClient();
+ client.addServiceEndPoint(request);
+ }
+
+ @Test(expected = GRMClientCallFailed.class)
+ public void testAddFail() throws Exception {
+ wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/add"))
+ .willReturn(aResponse()
+ .withStatus(404)
+ .withHeader("Content-Type", MediaType.APPLICATION_JSON)
+ .withBody("test")));
+ ServiceEndPointRequest request = new ServiceEndPointRequest();
+ GRMClient client = new GRMClient();
+ client.addServiceEndPoint(request);
+ }
+
+ @Test
+ public void testBuildServiceEndPointLookupRequest() {
+ GRMClient client = new GRMClient();
+ ServiceEndPointLookupRequest request = client.buildServiceEndPointlookupRequest("TEST.ECOMP_PSL.Inventory", 1, "DEV");
+ assertEquals("TEST.ECOMP_PSL.Inventory", request.getServiceEndPoint().getName());
+ assertEquals(Integer.valueOf(1), Integer.valueOf(request.getServiceEndPoint().getVersion().getMajor()));
+ assertEquals("DEV", request.getEnv());
+
+ }
+
+ protected String getFileContentsAsString(String fileName) {
+ String content = "";
+ try {
+ ClassLoader classLoader = this.getClass().getClassLoader();
+ File file = new File(classLoader.getResource(fileName).getFile());
+ content = new String(Files.readAllBytes(file.toPath()));
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage());
+ }
+ return content;
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java b/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java
new file mode 100644
index 0000000000..111fec46eb
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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.client.grm;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.util.List;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.openecomp.mso.client.grm.beans.ServiceEndPoint;
+import org.openecomp.mso.client.grm.beans.ServiceEndPointList;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ServiceEndPointListTest {
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void testUnmarshall() throws Exception {
+ String endpointsJson = getFileContentsAsString("__files/grm/endpoints.json");
+ ServiceEndPointList sel = mapper.readValue(endpointsJson, ServiceEndPointList.class);
+
+ List<ServiceEndPoint> list = sel.getServiceEndPointList();
+ ServiceEndPoint se = list.get(0);
+
+ assertEquals(3, list.size());
+ assertEquals("dummy.pod.ns.dummy-pod3", se.getName());
+ assertEquals(Integer.valueOf(1), Integer.valueOf(se.getVersion().getMajor()));
+ assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getMinor()));
+ assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getPatch()));
+ assertEquals("135.144.120.218", se.getHostAddress());
+ assertEquals("32004", se.getListenPort());
+ assertEquals("37.7022", se.getLatitude());
+ assertEquals("121.9358", se.getLongitude());
+ assertEquals("/", se.getContextPath());
+ assertEquals("edge", se.getOperationalInfo().getCreatedBy());
+ assertEquals("edge", se.getOperationalInfo().getUpdatedBy());
+ assertEquals("Environment", se.getProperties().get(0).getName());
+ assertEquals("DEV", se.getProperties().get(0).getValue());
+ }
+
+ protected String getFileContentsAsString(String fileName) {
+
+ String content = "";
+ try {
+ ClassLoader classLoader = this.getClass().getClassLoader();
+ File file = new File(classLoader.getResource(fileName).getFile());
+ content = new String(Files.readAllBytes(file.toPath()));
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage());
+ }
+ return content;
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java b/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java
new file mode 100644
index 0000000000..230b58bd84
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============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.client.grm;
+
+import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+import org.openecomp.mso.client.grm.beans.OperationalInfo;
+import org.openecomp.mso.client.grm.beans.Property;
+import org.openecomp.mso.client.grm.beans.ServiceEndPoint;
+import org.openecomp.mso.client.grm.beans.ServiceEndPointRequest;
+import org.openecomp.mso.client.grm.beans.Version;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ServiceEndPointRequestTest {
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void testMarshall() throws Exception {
+
+ String expected =
+ "{\"serviceEndPoint\":{\"name\":\"TEST.ECOMP_PSL.Inventory\",\"version\":{\"major\":1,\"minor\":0,\"patch\":\"0\"}," +
+ "\"hostAddress\":\"127.0.0.1\",\"listenPort\":\"8080\",\"latitude\":\"37.7022\",\"longitude\":\"121.9358\"," +
+ "\"contextPath\":\"/\",\"routeOffer\":\"TEST\",\"operationalInfo\":{\"createdBy\":\"edge\",\"updatedBy\":\"edge\"}," +
+ "\"properties\":[{\"name\":\"Environment\",\"value\":\"TEST\"},{\"name\":\"cpfrun_cluster_name\"," +
+ "\"value\":\"testcase_cluster_no_cluster\"}]},\"env\":\"DEV\"}";
+
+ Version ver = new Version();
+ ver.setMajor(1);
+ ver.setMinor(0);
+ ver.setPatch("0");
+
+ ServiceEndPoint sep = new ServiceEndPoint();
+ sep.setName("TEST.ECOMP_PSL.Inventory");
+ sep.setVersion(ver);
+ sep.setHostAddress("127.0.0.1");
+ sep.setListenPort("8080");
+ sep.setLatitude("37.7022");
+ sep.setLongitude("121.9358");
+ sep.setContextPath("/");
+ sep.setRouteOffer("TEST");
+
+ OperationalInfo operInfo = new OperationalInfo();
+ operInfo.setCreatedBy("edge");
+ operInfo.setUpdatedBy("edge");
+
+ sep.setOperationalInfo(operInfo);
+
+ Property prop1 = new Property();
+ prop1.setName("Environment");
+ prop1.setValue("TEST");
+
+ Property prop2 = new Property();
+ prop2.setName("cpfrun_cluster_name");
+ prop2.setValue("testcase_cluster_no_cluster");
+
+ List<Property> props = new ArrayList<Property>();
+ props.add(prop1);
+ props.add(prop2);
+
+ sep.setProperties(props);
+
+ ServiceEndPointRequest request = new ServiceEndPointRequest();
+ request.setEnv("DEV");
+ request.setServiceEndPoint(sep);
+
+ assertEquals(expected, mapper.writeValueAsString(request));
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/policy/PolicyClientImplTest.java b/common/src/test/java/org/openecomp/mso/client/policy/PolicyClientImplTest.java
new file mode 100644
index 0000000000..88cb4fa2a4
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/policy/PolicyClientImplTest.java
@@ -0,0 +1,75 @@
+/*-
+ * ============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.client.policy;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openecomp.mso.client.defaultproperties.PolicyRestPropertiesImpl;
+import org.openecomp.mso.client.policy.entities.Bbid;
+import org.openecomp.mso.client.policy.entities.DictionaryData;
+import org.openecomp.mso.client.policy.entities.PolicyDecision;
+import org.openecomp.mso.client.policy.entities.PolicyServiceType;
+import org.openecomp.mso.client.policy.entities.Workstep;
+
+public class PolicyClientImplTest {
+
+ @Test
+ public void successReadProperties() {
+ PolicyRestClient client = new PolicyRestClient(new PolicyRestPropertiesImpl(), PolicyServiceType.GET_DECISION);
+ client.initializeHeaderMap(client.headerMap);
+
+ assertEquals("Found expected Client Auth", client.headerMap.get("ClientAuth"), "Basic bTAzNzQzOnBvbGljeVIwY2sk");
+ assertEquals("Found expected Authorization", client.headerMap.get("Authorization"), "Basic dGVzdHBkcDphbHBoYTEyMw==");
+ assertEquals("Found expected Environment", client.headerMap.get("Environment"), "TEST");
+ assertEquals("Has X-ECOMP-RequestID", client.headerMap.containsKey("X-ECOMP-RequestID"), true);
+ }
+
+ @Test
+ @Ignore
+ public void getDecisionTest() {
+ PolicyClient client = new PolicyClientImpl();
+ PolicyDecision decision = client.getDecision("S", "V", "BB1", "1", "123");
+ assertEquals("Decision is correct", decision.getDecision(), "PERMIT");
+ assertEquals("Decision details is correct", decision.getDetails(), "Retry");
+ }
+
+ @Test
+ @Ignore
+ public void getAllowedTreatmentsTest(){
+ PolicyClient client = new PolicyClientImpl();
+ DictionaryData dictClient = client.getAllowedTreatments("BB1", "1");
+ final String dictBbidString = dictClient.getBbid().getString();
+ final String dictWorkStepString = dictClient.getWorkstep().getString();
+ assertEquals("DictionaryData matches a response Bbid", dictBbidString, "BB1");
+ assertEquals("DicitonaryData matches a response WorkStep", dictWorkStepString, "1");
+ }
+ /*
+ @Test
+ public void getAllowedTreatmentsTest() {
+ PolicyClient client = new PolicyClientImpl();
+ AllowedTreatments allowedTreatments = client.getAllowedTreatments("BB1", "1");
+ int expectedSizeOfList = 4;
+ int sizeOfList = allowedTreatments.getAllowedTreatments().size();
+ assertEquals("Decision is correct", sizeOfList, expectedSizeOfList);
+ }*/
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/ruby/RubyCheckClientTest.java b/common/src/test/java/org/openecomp/mso/client/ruby/RubyCheckClientTest.java
new file mode 100644
index 0000000000..053f1f2533
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/ruby/RubyCheckClientTest.java
@@ -0,0 +1,106 @@
+/*-
+ * ============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.client.ruby;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.text.ParseException;
+import java.time.format.DateTimeFormatter;
+
+import org.junit.Test;
+import org.openecomp.mso.client.ruby.beans.Ruby;
+
+import static org.apache.commons.lang3.StringUtils.*;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class RubyCheckClientTest {
+ private final String fileLocation = "src/test/resources/org/openecomp/mso/client/ruby/create-ticket/";
+ private static final String REQUEST_ID = "abc123";
+ private static final String SOURCE_NAME = "source-name";
+ private static final String TIME = "test-time";
+ private static final String REASON = "reason";
+ private static final String WORK_FLOW_ID = "work-flow-Id";
+ private static final String NOTIFICATION = "notification";
+
+
+
+ @Test
+ public void verifyRubyCreateTicketRequest() throws IOException, ParseException{
+ String content = this.getJson("create-ticket-request.json");
+ ObjectMapper mapper = new ObjectMapper();
+ Ruby expected = mapper.readValue(content, Ruby.class);
+ RubyClient client = new RubyClient();
+ RubyClient spy = spy(client);
+ when(spy.getTime()).thenReturn(TIME);
+ String actual = spy.buildRequest(REQUEST_ID, SOURCE_NAME, REASON, WORK_FLOW_ID, NOTIFICATION);
+ assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
+ }
+
+
+ @Test
+ public void verifyTimeFormat() {
+ RubyClient client = new RubyClient();
+ String time = client.getTime();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss Z");
+ formatter.parse(time);
+ }
+
+
+ @Test
+ public void verifyReasonCharLimit() throws IOException{
+ final String reasonLong = repeat("*", 256);
+ RubyClient client = new RubyClient();
+ try{
+ client.buildRequest(REQUEST_ID, SOURCE_NAME, reasonLong, WORK_FLOW_ID, NOTIFICATION);
+ fail("Should have thrown IllegalArgumentException but did not!");
+ }
+ catch(final IllegalArgumentException e){
+ final String msg = "reason exceeds 255 characters";
+ assertEquals(msg, e.getMessage());
+ }
+ }
+
+ @Test
+ public void verifyNotificationCharLimit() throws IOException{
+ final String notificationLong = repeat("*", 1025);
+ RubyClient client = new RubyClient();
+ try{
+ client.buildRequest(REQUEST_ID, SOURCE_NAME, REASON, WORK_FLOW_ID, notificationLong);
+ fail("Should have thrown IllegalArgumentException but did not!");
+ }
+ catch(final IllegalArgumentException e){
+ final String msg = "notification exceeds 1024 characters";
+ assertEquals(msg, e.getMessage());
+ }
+ }
+
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(fileLocation + filename)));
+ }
+
+}
+
diff --git a/common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java b/common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java
new file mode 100644
index 0000000000..6c64d90ff4
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/sdno/SDNOHealthCheckClientTest.java
@@ -0,0 +1,94 @@
+/*-
+ * ============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.client.sdno;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Optional;
+
+import org.junit.Test;
+import org.openecomp.mso.client.sdno.beans.SDNO;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class SDNOHealthCheckClientTest {
+
+
+
+ private final String fileLocation = "src/test/resources/org/openecomp/mso/client/sdno/health-check/";
+ private static final String userId = "test-user";
+ private static final Optional<String> clliCode = Optional.of("test-clli");
+ private static final String requestId = "test-request-id";
+ private static final String configurationId = "test-configuration-id";
+ private static final String interfaceId = "test-interface-id";
+
+ @Test
+ public void verfyLPortMirrorPreCheckRequest() throws IOException{
+ String content = this.getJson("custom-lport-mirror-pre-check-request.json");
+ ObjectMapper mapper = new ObjectMapper();
+ SDNO expected = mapper.readValue(content, SDNO.class);
+ SDNOHealthCheckClient client = new SDNOHealthCheckClient();
+ String actual = client.buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId);
+ assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
+ }
+
+ @Test
+ public void verfyLPortMirrorPostCheckRequest() throws IOException{
+ String content = this.getJson("custom-lport-mirror-post-check-request.json");
+ ObjectMapper mapper = new ObjectMapper();
+ SDNO expected = mapper.readValue(content, SDNO.class);
+ SDNOHealthCheckClient client = new SDNOHealthCheckClient();
+ String actual = client.buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId);
+ assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
+ }
+
+
+ @Test
+ public void verifyPortMirrorPostCheckRequest() throws IOException{
+ String content = this.getJson("custom-port-mirror-post-check-request.json");
+ ObjectMapper mapper = new ObjectMapper();
+ SDNO expected = mapper.readValue(content, SDNO.class);
+ SDNOHealthCheckClient client = new SDNOHealthCheckClient();
+ String actual = client.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId);
+
+ assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
+
+ }
+ @Test
+ public void verifyPortMirrorPreCheckRequest() throws IOException {
+ String content = this.getJson("custom-port-mirror-pre-check-request.json");
+ ObjectMapper mapper = new ObjectMapper();
+ SDNO expected = mapper.readValue(content, SDNO.class);
+ SDNOHealthCheckClient client = new SDNOHealthCheckClient();
+ String actual = client.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId);
+
+ assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
+
+ }
+
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(fileLocation + filename)));
+ }
+
+}
diff --git a/common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java b/common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java
new file mode 100644
index 0000000000..cd84e7854d
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/client/sdno/SDNOValidatorTest.java
@@ -0,0 +1,116 @@
+/*-
+ * ============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.client.sdno;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.UUID;
+
+import org.hamcrest.core.StringContains;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.onap.aai.domain.yang.GenericVnf;
+import org.openecomp.mso.client.dmaap.Consumer;
+import org.openecomp.mso.client.dmaap.exceptions.DMaaPConsumerFailure;
+import org.openecomp.mso.client.exceptions.SDNOException;
+import org.openecomp.mso.client.sdno.beans.SDNO;
+import org.openecomp.mso.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+public class SDNOValidatorTest {
+
+
+ @Mock private Consumer mrConsumer;
+ @Spy private SDNOHealthCheckDmaapConsumer dmaapConsumer;
+ private final String fileLocation = "src/test/resources/org/openecomp/mso/client/sdno/";
+ private final String uuid = "xyz123";
+ @Rule public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void setUpTests() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void success() throws IOException, Exception {
+ when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer);
+ when(mrConsumer.fetch()).thenReturn(Arrays.asList(new String[]{getJson("response.json"), getJson("output-success.json")}));
+
+ SDNOValidatorImpl validator = new SDNOValidatorImpl();
+ SDNOValidatorImpl spy = spy(validator);
+ when(dmaapConsumer.getRequestId()).thenReturn("xyz123");
+ doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class));
+ boolean result = spy.pollForResponse("xyz123");
+ assertEquals("result is true", result, true);
+ }
+
+ @Test
+ public void failure() throws IOException, Exception {
+ when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer);
+ when(mrConsumer.fetch()).thenReturn(Arrays.asList(new String[]{getJson("response.json"), getJson("output-failure.json")}));
+
+ SDNOValidatorImpl validator = new SDNOValidatorImpl();
+ SDNOValidatorImpl spy = spy(validator);
+ when(dmaapConsumer.getRequestId()).thenReturn("xyz123");
+ doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class));
+ thrown.expect(SDNOException.class);
+ thrown.expectMessage(new StringContains("my error message"));
+ boolean result = spy.pollForResponse("xyz123");
+
+ }
+ @Ignore
+ @Test
+ public void run() throws Exception {
+ SDNOValidatorImpl validator = new SDNOValidatorImpl();
+ UUID uuid = UUID.randomUUID();
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("test");
+ vnf.setIpv4OamAddress("1.2.3.4");
+ vnf.setVnfType("VPE");
+ SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid");
+ ObjectMapper mapper = new ObjectMapper();
+ String json = mapper.writeValueAsString(request);
+ validator.submitRequest(json);
+ thrown.expect(DMaaPConsumerFailure.class);
+ boolean result = validator.pollForResponse(uuid.toString());
+ System.out.println(json);
+
+ }
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get(fileLocation + filename)));
+ }
+}
diff --git a/common/src/test/java/org/openecomp/mso/jsonpath/JsonPathUtilTest.java b/common/src/test/java/org/openecomp/mso/jsonpath/JsonPathUtilTest.java
new file mode 100644
index 0000000000..85bb8b6804
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/jsonpath/JsonPathUtilTest.java
@@ -0,0 +1,49 @@
+/*-
+ * ============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.jsonpath;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Optional;
+
+import org.junit.Test;
+
+public class JsonPathUtilTest {
+
+ private static final String json = "{\"test\" : \"hello\", \"test2\" : {\"nested\" : \"value\"}}";
+ @Test
+ public void pathExistsTest() {
+ assertEquals("test is found", JsonPathUtil.getInstance().pathExists(json, "$.test"), true);
+ assertEquals("nothing is not found", JsonPathUtil.getInstance().pathExists(json, "$.nothing"), false);
+ }
+
+ @Test
+ public void locateResultTest() {
+ assertEquals("value of hello is found", Optional.of("hello"), JsonPathUtil.getInstance().locateResult(json, "$.test"));
+ assertEquals("nothing returns empty", Optional.empty(), JsonPathUtil.getInstance().locateResult(json, "$.nothing"));
+ }
+
+ @Test
+ public void simpleAndComplexValues() {
+ assertEquals("json doc found", Optional.of("{\"nested\":\"value\"}"), JsonPathUtil.getInstance().locateResult(json, "$.test2"));
+ assertEquals("value found", Optional.of("value"), JsonPathUtil.getInstance().locateResult(json, "$.test2.nested"));
+ }
+} \ No newline at end of file
diff --git a/common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequestTest.java b/common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequestTest.java
new file mode 100644
index 0000000000..28cbe799cd
--- /dev/null
+++ b/common/src/test/java/org/openecomp/mso/serviceinstancebeans/ServiceInstancesRequestTest.java
@@ -0,0 +1,44 @@
+/*-
+ * ============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.serviceinstancebeans;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ServiceInstancesRequestTest {
+
+ @Test
+ public void serializeServiceInstance() {
+ String incomingRequest = "{\"requestDetails\":{\"modelInfo\":{\"modelInvariantUuid\":\"9647dfc4-2083-11e7-93ae-92361f002672\",\"modelType\":\"configuration\",\"modelName\":\"MSO-Configuration\",\"modelVersion\":\"1.0\",\"modelUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444455\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002671\"},\"requestInfo\":{\"source\":\"VID\",\"instanceName\":\"port_mirror_config_m830-01\",\"suppressRollback\":false,\"requestorId\":\"mdg1215\"},\"relatedInstanceList\":[{\"relatedInstance\":{\"instanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f13\",\"modelInfo\":{\"modelInvariantUuid\":\"9647dfc4-2083-11e7-93ae-92361f002671\",\"modelType\":\"service\",\"modelName\":\"MSOTADevInfra_vSAMP10a_Service\",\"modelVersion\":\"1.0\",\"modelUuid\":\"5df8b6de-2083-11e7-93ae-92361f002671\"}}},{\"relatedInstance\":{\"instanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f11\",\"modelInfo\":{\"modelInvariantUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444456\",\"modelType\":\"vnf\",\"modelName\":\"testvnf\",\"modelVersion\":\"1.0\",\"modelUuid\":\"956121e0-542d-4b30-b8c7-be611e3c8f14\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002676\"},\"instanceDirection\":\"source\"}},{\"relatedInstance\":{\"instanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f12\",\"modelInfo\":{\"modelInvariantUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444477\",\"modelType\":\"vnf\",\"modelName\":\"svProbe vnf model name\",\"modelVersion\":\"1.0\",\"modelUuid\":\"36a3a8ea-49a6-4ac8-b06c-89a545444488\",\"modelCustomizationUuid\":\"68dc9a92-214c-11e7-93ae-92361f002672\"},\"instanceDirection\":\"destination\"}}],\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\"},\"requestParameters\":{\"subscriptionServiceType\":\"MSO-dev-service-type\",\"userParams\":[{\"name\":\"someUserParam\",\"value\":\"someValue\"}],\"aLaCarte\":false,\"autoBuildVfModules\":false,\"cascadeDelete\":false,\"usePreload\":true,\"rebuildVolumeGroups\":false}},\"serviceInstanceId\":\"956121e0-542d-4b30-b8c7-be611e3c8f13\"}";
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ try {
+ ServiceInstancesRequest request = mapper.readValue(incomingRequest, ServiceInstancesRequest.class);
+ System.out.println("Java Object: " + request);
+ } catch (Exception e) {
+ System.out.println("Caught Exception " + e.getMessage());
+ Assert.fail("Caught error on object serialization");
+ }
+ }
+}
diff --git a/common/src/test/resources/__files/Policy/policyAbortResponse.json b/common/src/test/resources/__files/Policy/policyAbortResponse.json
new file mode 100644
index 0000000000..c315b1ed1d
--- /dev/null
+++ b/common/src/test/resources/__files/Policy/policyAbortResponse.json
@@ -0,0 +1 @@
+{"decision":"PERMIT","details":"Abort"} \ No newline at end of file
diff --git a/common/src/test/resources/__files/Policy/policySkipResponse.json b/common/src/test/resources/__files/Policy/policySkipResponse.json
new file mode 100644
index 0000000000..7cbdebb6b3
--- /dev/null
+++ b/common/src/test/resources/__files/Policy/policySkipResponse.json
@@ -0,0 +1 @@
+{"decision":"PERMIT","details":"Skip"} \ No newline at end of file
diff --git a/common/src/test/resources/__files/aai/bulkprocess/response-failure.json b/common/src/test/resources/__files/aai/bulkprocess/response-failure.json
new file mode 100644
index 0000000000..bbc2c38b76
--- /dev/null
+++ b/common/src/test/resources/__files/aai/bulkprocess/response-failure.json
@@ -0,0 +1,32 @@
+{
+ "transaction": [
+ {
+ "put": [
+ {
+ "body": {
+ "401": "{\"requestError\": {\"serviceException\": {\"messageId\": \"SVC3003\",\"text\": \"another error message\",\"variables\": []}}}"
+ }
+ },
+ {
+ "body": {
+ "200": "test2"
+ }
+ }
+ ]
+ },
+ {
+ "put": [
+ {
+ "body": {
+ "400": "{\"requestError\": {\"serviceException\": {\"messageId\": \"SVC3003\",\"text\": \"my great error\",\"variables\": []}}}"
+ }
+ },
+ {
+ "body": {
+ "200": "test4"
+ }
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/common/src/test/resources/__files/aai/bulkprocess/response-success.json b/common/src/test/resources/__files/aai/bulkprocess/response-success.json
new file mode 100644
index 0000000000..7dae38335a
--- /dev/null
+++ b/common/src/test/resources/__files/aai/bulkprocess/response-success.json
@@ -0,0 +1,32 @@
+{
+ "transaction": [
+ {
+ "put": [
+ {
+ "body": {
+ "201": "test"
+ }
+ },
+ {
+ "body": {
+ "200": "test2"
+ }
+ }
+ ]
+ },
+ {
+ "put": [
+ {
+ "body": {
+ "201": "test3"
+ }
+ },
+ {
+ "body": {
+ "200": "test4"
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/common/src/test/resources/__files/aai/bulkprocess/test-request.json b/common/src/test/resources/__files/aai/bulkprocess/test-request.json
new file mode 100644
index 0000000000..f5ffe38285
--- /dev/null
+++ b/common/src/test/resources/__files/aai/bulkprocess/test-request.json
@@ -0,0 +1,22 @@
+{
+ "transactions" : [ {
+ "put" : [ {
+ "uri" : "/network/generic-vnfs/generic-vnf/test1/relationship-list/relationship",
+ "body" : {
+ "related-link" : "/cloud-infrastructure/pservers/pserver/test2"
+ }
+ }, {
+ "uri" : "/network/generic-vnfs/generic-vnf/test3/relationship-list/relationship",
+ "body" : {
+ "related-link" : "/cloud-infrastructure/pservers/pserver/test4"
+ }
+ } ]
+ }, {
+ "put" : [ {
+ "uri" : "/network/generic-vnfs/generic-vnf/test5/relationship-list/relationship",
+ "body" : {
+ "related-link" : "/cloud-infrastructure/pservers/pserver/test6"
+ }
+ } ]
+ } ]
+} \ No newline at end of file
diff --git a/common/src/test/resources/__files/aai/pserver.json b/common/src/test/resources/__files/aai/pserver.json
new file mode 100644
index 0000000000..1a3f40aac3
--- /dev/null
+++ b/common/src/test/resources/__files/aai/pserver.json
@@ -0,0 +1,14 @@
+{
+ "results": [
+ {
+ "pserver": {
+ "hostname": "test"
+ }
+ },
+ {
+ "pserver": {
+ "hostname": "test2"
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/common/src/test/resources/__files/aai/resources/e2e-complex.json b/common/src/test/resources/__files/aai/resources/e2e-complex.json
new file mode 100644
index 0000000000..6fc9cb36e6
--- /dev/null
+++ b/common/src/test/resources/__files/aai/resources/e2e-complex.json
@@ -0,0 +1,660 @@
+{
+ "physical-location-id": "MTCWNJA4DCP",
+ "complex-name": "mtcnj",
+ "resource-version": "1498188613044",
+ "physical-location-type": "Mobility",
+ "street1": "200 S. Laurel Ave, Rm A4-3C30",
+ "city": "Middletown",
+ "state": "NJ",
+ "postal-code": "07748",
+ "country": "USA",
+ "region": "US",
+ "latitude": "40.39596",
+ "longitude": "-74.135342",
+ "lata": "224",
+ "ctag-pools": {
+ "ctag-pool": [
+ {
+ "target-pe": "sfcca301vr1",
+ "availability-zone-name": "mtcnj-esx-az01",
+ "ctag-pool-purpose": "IPAG",
+ "ctag-values": "2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025",
+ "resource-version": "1494254946087",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vpls-pe",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vpls-pes/vpls-pe/sfcca301vr1",
+ "relationship-data": [
+ {
+ "relationship-key": "vpls-pe.equipment-name",
+ "relationship-value": "sfcca301vr1"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "target-pe": "VPESAT-mtcnj401me6",
+ "availability-zone-name": "mtcnj-esx-az01",
+ "ctag-pool-purpose": "VPE",
+ "ctag-values": "3001,3002,3003,3004,3005,3006,3007,3008,3009,3010,3011,3012,3013,3014,3015,3016,3017,3018,3019,3020,3021,3022,3023,3024,3025,3026,3027,3028,3029,3030,3031,3032,3033,3034,3035,3036,3037,3038,3039,3040,3041,3042,3043,3044,3045,3046,3047,3048,3049,3050",
+ "resource-version": "1494254975977"
+ }
+ ]
+ },
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vce",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053",
+ "relationship-data": [
+ {
+ "relationship-key": "vce.vnf-id",
+ "relationship-value": "a9fec18e-1ea3-40e4-a6c0-a89b3de07053"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vce.vnf-name",
+ "property-value": "mtcnj411vbc"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj104snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj104snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj105snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj105snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/compute_host",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "compute_host"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj106snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj106snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj126sd9",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj126sd9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "vce",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/8ae1e5f8-61f1-4c71-913a-b40cc4593cb9",
+ "relationship-data": [
+ {
+ "relationship-key": "vce.vnf-id",
+ "relationship-value": "8ae1e5f8-61f1-4c71-913a-b40cc4593cb9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vce.vnf-name",
+ "property-value": "mtcnj411vbc"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj102sta",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj102sta"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnjtax102",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnjtax102"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj107snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj107snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj118snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj118snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj110snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj110snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj109snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj109snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj114snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj114snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj119snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj119snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj116snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj116snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "vce",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/a2935fa9-b743-49f4-9813-a127f13c4e93",
+ "relationship-data": [
+ {
+ "relationship-key": "vce.vnf-id",
+ "relationship-value": "a2935fa9-b743-49f4-9813-a127f13c4e93"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vce.vnf-name",
+ "property-value": "mtcnj410vbc"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj108snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj108snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj123sd9",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj123sd9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj101snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj101snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj102snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj102snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnjtax101",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnjtax101"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj113snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj113snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj111snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj111snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj103snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj103snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj117snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj117snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj101sta",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj101sta"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "vce",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/c7fe7698-8063-4e26-8bd3-ca3edde0b0d4",
+ "relationship-data": [
+ {
+ "relationship-key": "vce.vnf-id",
+ "relationship-value": "c7fe7698-8063-4e26-8bd3-ca3edde0b0d4"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "vce.vnf-name",
+ "property-value": "mtcnj412vbc"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj120snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj120snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj124sd9",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj124sd9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj125sd9",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj125sd9"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj112snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj112snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "pserver",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj115snd",
+ "relationship-data": [
+ {
+ "relationship-key": "pserver.hostname",
+ "relationship-value": "mtcnj115snd"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "pserver.pserver-name2"
+ }
+ ]
+ },
+ {
+ "related-to": "cloud-region",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtcnj2",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "att-aic"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "mtcnj2"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "cloud-region.owner-defined-type",
+ "property-value": "lcp"
+ }
+ ]
+ },
+ {
+ "related-to": "oam-network",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/f9263cat-4eaa-43a0-bea4-adcf6e123456",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "att-aic"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "AAIAIC25"
+ },
+ {
+ "relationship-key": "oam-network.network-uuid",
+ "relationship-value": "f9263cat-4eaa-43a0-bea4-adcf6e123456"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "oam-network.network-name",
+ "property-value": "VLAN-OAM-1323"
+ }
+ ]
+ },
+ {
+ "related-to": "oam-network",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/b9263fab-4eaa-43a0-bea4-adcf6e999999",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "att-aic"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "AAIAIC25"
+ },
+ {
+ "relationship-key": "oam-network.network-uuid",
+ "relationship-value": "b9263fab-4eaa-43a0-bea4-adcf6e999999"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "oam-network.network-name",
+ "property-value": "VLAN-OAM-1323"
+ }
+ ]
+ },
+ {
+ "related-to": "oam-network",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/cf33dc95-c5d2-48fd-8078-fd949363f63b",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "att-aic"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "AAIAIC25"
+ },
+ {
+ "relationship-key": "oam-network.network-uuid",
+ "relationship-value": "cf33dc95-c5d2-48fd-8078-fd949363f63b"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "oam-network.network-name",
+ "property-value": "VLAN-OAM-1323"
+ }
+ ]
+ },
+ {
+ "related-to": "availability-zone",
+ "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/availability-zones/availability-zone/mtcnj-esx-az01",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "att-aic"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "AAIAIC25"
+ },
+ {
+ "relationship-key": "availability-zone.availability-zone-name",
+ "relationship-value": "mtcnj-esx-az01"
+ }
+ ]
+ }
+ ]
+ }
+ } \ No newline at end of file
diff --git a/common/src/test/resources/__files/aai/resources/empty-query-result.json b/common/src/test/resources/__files/aai/resources/empty-query-result.json
new file mode 100644
index 0000000000..914332edba
--- /dev/null
+++ b/common/src/test/resources/__files/aai/resources/empty-query-result.json
@@ -0,0 +1,3 @@
+{
+ "results": []
+} \ No newline at end of file
diff --git a/common/src/test/resources/__files/aai/resources/mockObject.json b/common/src/test/resources/__files/aai/resources/mockObject.json
new file mode 100644
index 0000000000..2f97b47dd3
--- /dev/null
+++ b/common/src/test/resources/__files/aai/resources/mockObject.json
@@ -0,0 +1,10 @@
+{
+ "id" : "something",
+ "resource-version" : "1234",
+ "plural" : {
+ "singular" : [{
+ "id" : "something2",
+ "resource-version" : "5678"
+ }]
+ }
+} \ No newline at end of file
diff --git a/common/src/test/resources/__files/aai/resources/service-instance-pathed-query.json b/common/src/test/resources/__files/aai/resources/service-instance-pathed-query.json
new file mode 100644
index 0000000000..6ec513e4bb
--- /dev/null
+++ b/common/src/test/resources/__files/aai/resources/service-instance-pathed-query.json
@@ -0,0 +1,8 @@
+{
+ "results": [
+ {
+ "resource-type": "service-instance",
+ "resource-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3"
+ }
+ ]
+} \ No newline at end of file
diff --git a/common/src/test/resources/__files/grm/endpoints.json b/common/src/test/resources/__files/grm/endpoints.json
new file mode 100644
index 0000000000..20947540b4
--- /dev/null
+++ b/common/src/test/resources/__files/grm/endpoints.json
@@ -0,0 +1,145 @@
+{
+ "serviceEndPointList": [
+ {
+ "name": "dummy.pod.ns.dummy-pod3",
+ "version": {
+ "major": 1,
+ "minor": 0,
+ "patch": "0"
+ },
+ "hostAddress": "135.144.120.218",
+ "listenPort": "32004",
+ "latitude": "37.7022",
+ "longitude": "121.9358",
+ "registrationTime": "2017-07-18T15:39:17.367+0000",
+ "expirationTime": "9999-10-09T15:39:17.368+0000",
+ "contextPath": "/",
+ "routeOffer": "DEFAULT",
+ "statusInfo": {
+ "status": "RUNNING"
+ },
+ "eventStatusInfo": {
+ "status": "RUNNING"
+ },
+ "validatorStatusInfo": {
+ "status": "RUNNING"
+ },
+ "operationalInfo": {
+ "createdBy": "edge",
+ "updatedBy": "edge",
+ "createdTimestamp": "2017-07-18T15:39:17.367+0000",
+ "updatedTimestamp": "2017-07-18T15:39:17.367+0000"
+ },
+ "protocol": "dummypod-port",
+ "properties": [
+ {
+ "name": "Environment",
+ "value": "DEV"
+ },
+ {
+ "name": "Kubernetes Namespace",
+ "value": "dummy-pod-ns"
+ },
+ {
+ "name": "cpfrun_cluster_name",
+ "value": "CI-PDK1-TFINIT-CJ9125401"
+ }
+ ],
+ "disableType": []
+ },
+ {
+ "name": "dummy.pod.ns.dummy-pod3",
+ "version": {
+ "major": 1,
+ "minor": 0,
+ "patch": "0"
+ },
+ "hostAddress": "135.144.120.22",
+ "listenPort": "32004",
+ "latitude": "1.0",
+ "longitude": "1.0",
+ "registrationTime": "2017-07-18T15:39:17.816+0000",
+ "expirationTime": "9999-10-09T15:39:17.817+0000",
+ "contextPath": "/",
+ "routeOffer": "DEFAULT",
+ "statusInfo": {
+ "status": "RUNNING"
+ },
+ "eventStatusInfo": {
+ "status": "RUNNING"
+ },
+ "validatorStatusInfo": {
+ "status": "RUNNING"
+ },
+ "operationalInfo": {
+ "createdBy": "edge",
+ "updatedBy": "edge",
+ "createdTimestamp": "2017-07-18T15:39:17.816+0000",
+ "updatedTimestamp": "2017-07-18T15:39:17.816+0000"
+ },
+ "protocol": "dummypod-port",
+ "properties": [
+ {
+ "name": "Environment",
+ "value": "DEV"
+ },
+ {
+ "name": "Kubernetes Namespace",
+ "value": "dummy-pod-ns"
+ },
+ {
+ "name": "cpfrun_cluster_name",
+ "value": "CI-PDK1-TFINIT-CJ9125401"
+ }
+ ],
+ "disableType": []
+ },
+ {
+ "name": "dummy.pod.ns.dummy-pod1",
+ "version": {
+ "major": 1,
+ "minor": 0,
+ "patch": "0"
+ },
+ "hostAddress": "135.144.120.218",
+ "listenPort": "32002",
+ "latitude": "1.0",
+ "longitude": "1.0",
+ "registrationTime": "2017-07-18T15:39:14.443+0000",
+ "expirationTime": "9999-10-09T15:39:14.453+0000",
+ "contextPath": "/",
+ "routeOffer": "DEFAULT",
+ "statusInfo": {
+ "status": "RUNNING"
+ },
+ "eventStatusInfo": {
+ "status": "RUNNING"
+ },
+ "validatorStatusInfo": {
+ "status": "RUNNING"
+ },
+ "operationalInfo": {
+ "createdBy": "edge",
+ "updatedBy": "edge",
+ "createdTimestamp": "2017-07-18T15:39:14.443+0000",
+ "updatedTimestamp": "2017-07-18T15:39:14.443+0000"
+ },
+ "protocol": "dummypod-port",
+ "properties": [
+ {
+ "name": "Environment",
+ "value": "DEV"
+ },
+ {
+ "name": "Kubernetes Namespace",
+ "value": "dummy-pod-ns"
+ },
+ {
+ "name": "cpfrun_cluster_name",
+ "value": "CI-PDK1-TFINIT-CJ9125401"
+ }
+ ],
+ "disableType": []
+ }
+ ]
+} \ No newline at end of file
diff --git a/common/src/test/resources/aai.properties b/common/src/test/resources/aai.properties
new file mode 100644
index 0000000000..9d9f1bdce9
--- /dev/null
+++ b/common/src/test/resources/aai.properties
@@ -0,0 +1 @@
+aai.endpoint=http://localhost:8443 \ No newline at end of file
diff --git a/common/src/test/resources/dmaap.properties b/common/src/test/resources/dmaap.properties
new file mode 100644
index 0000000000..8adb8e4976
--- /dev/null
+++ b/common/src/test/resources/dmaap.properties
@@ -0,0 +1,7 @@
+sdno.health-check.dmaap.username=m04768@mso.ecomp.att.com
+sdno.health-check.dmaap.password=eHQ1cUJrOUc
+sdno.health-check.dmaap.subscriber.topic=com.att.sdno.test-health-diagnostic-v02
+sdno.health-check.dmaap.publisher.topic=com.att.sdno.test-health-diagnostic-v02
+ruby.create-ticket-request.dmaap.username=m04768@mso.ecomp.att.com
+ruby.create-ticket-request.dmaap.password=eHQ1cUJrOUc
+ruby.create-ticket-request.publisher.topic=com.att.pdas.st1.msoCMFallout-v1 \ No newline at end of file
diff --git a/common/src/test/resources/mso-bad.json b/common/src/test/resources/mso-bad.json
index 42328efb92..57b271459e 100644
--- a/common/src/test/resources/mso-bad.json
+++ b/common/src/test/resources/mso-bad.json
@@ -1,23 +1,3 @@
-/*-
- * ============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=========================================================
- */
-
{
"asdc-connections":{,
"asdc-controller1":{
diff --git a/common/src/test/resources/mso2.json b/common/src/test/resources/mso2.json
index ee7fe124d2..bac30c495c 100644
--- a/common/src/test/resources/mso2.json
+++ b/common/src/test/resources/mso2.json
@@ -1,41 +1,20 @@
-/*-
- * ============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=========================================================
- */
-
{
- "asdc-connections":{
- "asdc-controller1":{
- "asdcUser": "user1B",
- "asdcConsumerGroup": "consumer1",
- "asdcConsumerId": "consumer1",
- "asdcEnvironmentName": "PROD",
- "asdcAddress": "localhost:8443",
- "asdcPassword": "1c551b8b5ab91fcd5a0907b11c304199"
- },
- "asdc-controller2":{
- "asdcUser": "user2B",
- "asdcConsumerGroup": "consumer2",
- "asdcConsumerId": "consumer2",
- "asdcEnvironmentName": "E2E",
- "asdcAddress": "localhost:8443",
- "asdcPassword": "1c551b8b5ab91fcd5a0907b11c304199"
- }
- }
-
-}
+ "asdc-connections": {
+ "asdc-controller1": {
+ "asdcUser": "user1B",
+ "asdcConsumerGroup": "consumer1",
+ "asdcConsumerId": "consumer1",
+ "asdcEnvironmentName": "PROD",
+ "asdcAddress": "localhost:8443",
+ "asdcPassword": "1c551b8b5ab91fcd5a0907b11c304199"
+ },
+ "asdc-controller2": {
+ "asdcUser": "user2B",
+ "asdcConsumerGroup": "consumer2",
+ "asdcConsumerId": "consumer2",
+ "asdcEnvironmentName": "E2E",
+ "asdcAddress": "localhost:8443",
+ "asdcPassword": "1c551b8b5ab91fcd5a0907b11c304199"
+ }
+ }
+} \ No newline at end of file
diff --git a/common/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json b/common/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json
new file mode 100644
index 0000000000..e388d3e9ad
--- /dev/null
+++ b/common/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json
@@ -0,0 +1,15 @@
+{
+ "event": {
+ "msoRequest": {
+ "requestClientName": "MSO",
+ "requestId": "abc123",
+ "requestTime": "test-time",
+ "sourceName": "source-name",
+ "reason": "reason",
+ "action": "Create Ticket",
+ "workflowId": "work-flow-Id",
+ "notification": "notification"
+ }
+}
+}
+
diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json
new file mode 100644
index 0000000000..8c3ca1938d
--- /dev/null
+++ b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json
@@ -0,0 +1,26 @@
+{
+ "body": {
+ "input": {
+ "request-hd-custom": {
+ "request-client-name": "MSO",
+ "request-user-id": "test-user",
+ "request-id": "test-request-id",
+ "health-diagnostic-code": "VROUTER000004",
+ "operation-type": "lport_mirroring_check",
+ "aai-param-list": [
+ {
+ "key": "configuration-id",
+ "value": "test-configuration-id"
+ },
+ {
+ "key": "interface-id",
+ "value": "test-interface-id"
+ }
+ ]
+ }
+ }
+ },
+ "operation": "health-diagnostic-custom",
+ "nodeLoc": "test-clli",
+ "nodeType": "VROUTER"
+} \ No newline at end of file
diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json
new file mode 100644
index 0000000000..08220abe2d
--- /dev/null
+++ b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json
@@ -0,0 +1,26 @@
+{
+ "body": {
+ "input": {
+ "request-hd-custom": {
+ "request-client-name": "MSO",
+ "request-user-id": "test-user",
+ "request-id": "test-request-id",
+ "health-diagnostic-code": "VROUTER000003",
+ "operation-type": "lport_mirroring_check",
+ "aai-param-list": [
+ {
+ "key": "configuration-id",
+ "value": "test-configuration-id"
+ },
+ {
+ "key": "interface-id",
+ "value": "test-interface-id"
+ }
+ ]
+ }
+ }
+ },
+ "operation": "health-diagnostic-custom",
+ "nodeLoc": "test-clli",
+ "nodeType": "VROUTER"
+} \ No newline at end of file
diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json
new file mode 100644
index 0000000000..834fcc8e72
--- /dev/null
+++ b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json
@@ -0,0 +1,22 @@
+{
+ "body": {
+ "input": {
+ "request-hd-custom": {
+ "request-client-name": "MSO",
+ "request-user-id": "test-user",
+ "request-id": "test-request-id",
+ "health-diagnostic-code": "VROUTER000004",
+ "operation-type": "mirroring_check",
+ "aai-param-list": [
+ {
+ "key": "configuration-id",
+ "value": "test-configuration-id"
+ }
+ ]
+ }
+ }
+ },
+ "operation": "health-diagnostic-custom",
+ "nodeLoc": "test-clli",
+ "nodeType": "VROUTER"
+} \ No newline at end of file
diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json
new file mode 100644
index 0000000000..19d934d291
--- /dev/null
+++ b/common/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json
@@ -0,0 +1,22 @@
+{
+ "body": {
+ "input": {
+ "request-hd-custom": {
+ "request-client-name": "MSO",
+ "request-user-id": "test-user",
+ "request-id": "test-request-id",
+ "health-diagnostic-code": "VROUTER000003",
+ "operation-type": "mirroring_check",
+ "aai-param-list": [
+ {
+ "key": "configuration-id",
+ "value": "test-configuration-id"
+ }
+ ]
+ }
+ }
+ },
+ "operation": "health-diagnostic-custom",
+ "nodeLoc": "test-clli",
+ "nodeType": "VROUTER"
+}
diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json b/common/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json
new file mode 100644
index 0000000000..15160b9dd9
--- /dev/null
+++ b/common/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json
@@ -0,0 +1,25 @@
+{
+ "body": {
+ "output": {
+ "response-hd-custom": {
+ "response-status": "Failure",
+ "cached-data": "false",
+ "response-interface-type": "ansible",
+ "response-id": "191bf423-8473-4f7c-9fbb-e5dcbb40a12b",
+ "remote_end_time": "2017-10-13T14:51:53.490+0000",
+ "response-client-name": "MSO",
+ "user_id": "md5621",
+ "remote_start_time": "2017-10-13T14:51:53.173+0000",
+ "error-message": "my error message",
+ "connection-failure-msg": "SDNO was unable to connect to an Ansible REST API server; Please ensure Ansible REST server is running"
+ }
+ }
+ },
+ "result-info": {
+ "code": "200",
+ "status": "SUCCESS",
+ "request-id": "xyz123",
+ "client-name": "MSO",
+ "processing-host": "sdno-sdno-mtsnjv9sdno01"
+ }
+} \ No newline at end of file
diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/output-success.json b/common/src/test/resources/org/openecomp/mso/client/sdno/output-success.json
new file mode 100644
index 0000000000..a6794327d8
--- /dev/null
+++ b/common/src/test/resources/org/openecomp/mso/client/sdno/output-success.json
@@ -0,0 +1,22 @@
+{
+ "body": {
+ "output": {
+ "response-healthdiagnostic": {
+ "response-node-ip": "192.20.127.76",
+ "response-id": "xyz123",
+ "response-node-name": "mtvnjv9aads11",
+ "response-status": "Success",
+ "response-interface-type": "ssh",
+ "response-details-json": "result",
+ "cached-data": "false"
+ }
+ }
+ },
+ "result-info": {
+ "client-name": "MSO",
+ "code": "200",
+ "processing-host": "sdno1-host01",
+ "request-id": "xyz123",
+ "status": "SUCCESS"
+ }
+} \ No newline at end of file
diff --git a/common/src/test/resources/org/openecomp/mso/client/sdno/response.json b/common/src/test/resources/org/openecomp/mso/client/sdno/response.json
new file mode 100644
index 0000000000..2355e86938
--- /dev/null
+++ b/common/src/test/resources/org/openecomp/mso/client/sdno/response.json
@@ -0,0 +1,17 @@
+{
+
+ "result-info": {
+
+ "client-name": "MSO",
+
+ "code": "202",
+
+ "processing-host": "sdno1-host01",
+
+ "request-id": "xyz123",
+
+ "status": "ACCEPTED"
+
+ }
+
+} \ No newline at end of file
diff --git a/common/src/test/resources/policy.properties b/common/src/test/resources/policy.properties
new file mode 100644
index 0000000000..ef064e8bc0
--- /dev/null
+++ b/common/src/test/resources/policy.properties
@@ -0,0 +1,4 @@
+policy.endpoint=https://policyhost:8081/pdp/api/
+policy.client.auth=Basic bTAzNzQzOnBvbGljeVIwY2sk
+policy.auth=Basic dGVzdHBkcDphbHBoYTEyMw==
+policy.environment=TEST \ No newline at end of file