aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/test/java/org/openecomp/mso/asdc/client
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller/src/test/java/org/openecomp/mso/asdc/client')
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTest.java134
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTestscaffolding.java79
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTest.java26
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTestscaffolding.java82
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTest.java24
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTestscaffolding.java82
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTest.java24
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTestscaffolding.java82
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTest.java24
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTestscaffolding.java82
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCConfigurationTest.java356
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java412
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCElementInfoTest.java175
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCGlobalControllerTest.java213
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/BigDecimalVersionTest.java53
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/YamlTest.java165
16 files changed, 2013 insertions, 0 deletions
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTest.java
new file mode 100644
index 0000000000..e2112cee03
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTest.java
@@ -0,0 +1,134 @@
+/*
+ * This file was automatically generated by EvoSuite
+ * Fri Nov 25 13:39:00 GMT 2016
+ */
+
+package org.openecomp.mso.asdc.client;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.evosuite.runtime.EvoRunner;
+import org.evosuite.runtime.EvoRunnerParameters;
+import org.junit.runner.RunWith;
+import org.openecomp.sdc.utils.DistributionStatusEnum;
+
+@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true)
+public class DistributionStatusMessageESTest extends DistributionStatusMessageESTestscaffolding {
+
+ @Test(timeout = 4000)
+ public void test00() throws Throwable {
+ DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED;
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L);
+ long long0 = distributionStatusMessage0.getTimestamp();
+ assertEquals(1L, long0);
+ }
+
+ @Test(timeout = 4000)
+ public void test01() throws Throwable {
+ DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DEPLOYED;
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("n*lho0\"NQ4azb%8]KN", "n*lho0\"NQ4azb%8]KN", "BMWmXl2i-B", distributionStatusEnum0, (-58L));
+ long long0 = distributionStatusMessage0.getTimestamp();
+ assertEquals("BMWmXl2i-B", distributionStatusMessage0.getDistributionID());
+ assertEquals((-58L), long0);
+ assertEquals("n*lho0\"NQ4azb%8]KN", distributionStatusMessage0.getConsumerID());
+ assertEquals("n*lho0\"NQ4azb%8]KN", distributionStatusMessage0.getArtifactURL());
+ }
+
+ @Test(timeout = 4000)
+ public void test02() throws Throwable {
+ DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED;
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L);
+ DistributionStatusEnum distributionStatusEnum1 = distributionStatusMessage0.getStatus();
+ DistributionStatusMessage distributionStatusMessage1 = new DistributionStatusMessage("", (String) null, "*? q^M(_q^3$ZQ", distributionStatusEnum1, (-833L));
+ String string0 = distributionStatusMessage1.getDistributionID();
+ assertNotNull(string0);
+ assertEquals((-833L), distributionStatusMessage1.getTimestamp());
+ assertEquals("", distributionStatusMessage1.getArtifactURL());
+ assertEquals("*? q^M(_q^3$ZQ", string0);
+ }
+
+ @Test(timeout = 4000)
+ public void test03() throws Throwable {
+ DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED;
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("", "", "", distributionStatusEnum0, 1L);
+ distributionStatusMessage0.getDistributionID();
+ assertEquals(1L, distributionStatusMessage0.getTimestamp());
+ }
+
+ @Test(timeout = 4000)
+ public void test04() throws Throwable {
+ DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED;
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("ALREADY_DEPLOYED", "ALREADY_DEPLOYED", "ALREADY_DEPLOYED", distributionStatusEnum0, 0L);
+ String string0 = distributionStatusMessage0.getConsumerID();
+ assertEquals("ALREADY_DEPLOYED", string0);
+ }
+
+ @Test(timeout = 4000)
+ public void test05() throws Throwable {
+ DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED;
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L);
+ DistributionStatusEnum distributionStatusEnum1 = distributionStatusMessage0.getStatus();
+ DistributionStatusMessage distributionStatusMessage1 = new DistributionStatusMessage((String) null, "", "Qcuo3~gd})vsI*", distributionStatusEnum1, 0L);
+ String string0 = distributionStatusMessage1.getConsumerID();
+ assertNotNull(string0);
+ assertEquals(1L, distributionStatusMessage0.getTimestamp());
+ assertEquals("", string0);
+ assertEquals("Qcuo3~gd})vsI*", distributionStatusMessage1.getDistributionID());
+ }
+
+ @Test(timeout = 4000)
+ public void test06() throws Throwable {
+ DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED;
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("ALREADY_DEPLOYED", "ALREADY_DEPLOYED", "ALREADY_DEPLOYED", distributionStatusEnum0, 0L);
+ String string0 = distributionStatusMessage0.getArtifactURL();
+ assertEquals("ALREADY_DEPLOYED", string0);
+ }
+
+ @Test(timeout = 4000)
+ public void test07() throws Throwable {
+ DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED;
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L);
+ DistributionStatusEnum distributionStatusEnum1 = distributionStatusMessage0.getStatus();
+ DistributionStatusMessage distributionStatusMessage1 = new DistributionStatusMessage("", (String) null, "*? q^M(_q^3$ZQ", distributionStatusEnum1, (-833L));
+ String string0 = distributionStatusMessage1.getArtifactURL();
+ assertEquals("", string0);
+ assertEquals("*? q^M(_q^3$ZQ", distributionStatusMessage1.getDistributionID());
+ assertNotNull(string0);
+ assertEquals((-833L), distributionStatusMessage1.getTimestamp());
+ }
+
+ @Test(timeout = 4000)
+ public void test08() throws Throwable {
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L);
+ long long0 = distributionStatusMessage0.getTimestamp();
+ assertEquals(0L, long0);
+ }
+
+ @Test(timeout = 4000)
+ public void test09() throws Throwable {
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L);
+ String string0 = distributionStatusMessage0.getDistributionID();
+ assertNull(string0);
+ }
+
+ @Test(timeout = 4000)
+ public void test10() throws Throwable {
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L);
+ distributionStatusMessage0.getStatus();
+ }
+
+ @Test(timeout = 4000)
+ public void test11() throws Throwable {
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L);
+ String string0 = distributionStatusMessage0.getConsumerID();
+ assertNull(string0);
+ }
+
+ @Test(timeout = 4000)
+ public void test12() throws Throwable {
+ DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L);
+ String string0 = distributionStatusMessage0.getArtifactURL();
+ assertNull(string0);
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTestscaffolding.java
new file mode 100644
index 0000000000..f234ca64d5
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTestscaffolding.java
@@ -0,0 +1,79 @@
+/**
+ * Scaffolding file used to store all the setups needed to run
+ * tests automatically generated by EvoSuite
+ * Fri Nov 25 13:39:00 GMT 2016
+ */
+
+package org.openecomp.mso.asdc.client;
+
+import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
+import org.junit.BeforeClass;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.evosuite.runtime.sandbox.Sandbox;
+
+@EvoSuiteClassExclude
+public class DistributionStatusMessageESTestscaffolding {
+
+ @org.junit.Rule
+ public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule();
+
+ private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone();
+
+ private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000);
+
+ @BeforeClass
+ public static void initEvoSuiteFramework() {
+ org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.DistributionStatusMessage";
+ org.evosuite.runtime.GuiSupport.initialize();
+ org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100;
+ org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000;
+ org.evosuite.runtime.RuntimeSettings.mockSystemIn = true;
+ org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED;
+ org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT();
+ org.evosuite.runtime.classhandling.JDKClassResetter.init();
+ initializeClasses();
+ org.evosuite.runtime.Runtime.getInstance().resetRuntime();
+ }
+
+ @AfterClass
+ public static void clearEvoSuiteFramework(){
+ Sandbox.resetDefaultSecurityManager();
+ java.lang.System.setProperties((java.util.Properties) defaultProperties.clone());
+ }
+
+ @Before
+ public void initTestCase(){
+ threadStopper.storeCurrentThreads();
+ threadStopper.startRecordingTime();
+ org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler();
+ org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode();
+
+ org.evosuite.runtime.GuiSupport.setHeadless();
+ org.evosuite.runtime.Runtime.getInstance().resetRuntime();
+ org.evosuite.runtime.agent.InstrumentingAgent.activate();
+ }
+
+ @After
+ public void doneWithTestCase(){
+ threadStopper.killAndJoinClientThreads();
+ org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks();
+ org.evosuite.runtime.classhandling.JDKClassResetter.reset();
+ resetClasses();
+ org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode();
+ org.evosuite.runtime.agent.InstrumentingAgent.deactivate();
+ org.evosuite.runtime.GuiSupport.restoreHeadlessMode();
+ }
+
+ private static void initializeClasses() {
+ org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DistributionStatusMessageESTestscaffolding.class.getClassLoader() ,
+ "org.openecomp.sdc.utils.DistributionStatusEnum",
+ "org.openecomp.mso.asdc.client.DistributionStatusMessage",
+ "org.openecomp.sdc.api.consumer.IDistributionStatusMessage"
+ );
+ }
+
+ private static void resetClasses() {
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTest.java
new file mode 100644
index 0000000000..37af59c639
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTest.java
@@ -0,0 +1,26 @@
+/*
+ * This file was automatically generated by EvoSuite
+ * Fri Nov 25 13:39:27 GMT 2016
+ */
+
+package org.openecomp.mso.asdc.client.exceptions;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.evosuite.runtime.EvoRunner;
+import org.evosuite.runtime.EvoRunnerParameters;
+import org.evosuite.runtime.mock.java.lang.MockThrowable;
+import org.junit.runner.RunWith;
+
+@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true)
+public class ASDCControllerExceptionESTest extends ASDCControllerExceptionESTestscaffolding {
+
+ @Test(timeout = 4000)
+ public void test0() throws Throwable {
+ ASDCControllerException aSDCControllerException0 = new ASDCControllerException("org.openecomp.mso.asdc.client.exceptions.ASDCControllerException");
+ MockThrowable mockThrowable0 = new MockThrowable("B+;:\"w4^M(-Y:e~=", (Throwable) aSDCControllerException0);
+ ASDCControllerException aSDCControllerException1 = new ASDCControllerException("The list of prefixes must not be null", (Throwable) mockThrowable0);
+ assertFalse(aSDCControllerException1.equals((Object)aSDCControllerException0));
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTestscaffolding.java
new file mode 100644
index 0000000000..d6041c2fb2
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTestscaffolding.java
@@ -0,0 +1,82 @@
+/**
+ * Scaffolding file used to store all the setups needed to run
+ * tests automatically generated by EvoSuite
+ * Fri Nov 25 13:39:27 GMT 2016
+ */
+
+package org.openecomp.mso.asdc.client.exceptions;
+
+import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
+import org.junit.BeforeClass;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.evosuite.runtime.sandbox.Sandbox;
+
+@EvoSuiteClassExclude
+public class ASDCControllerExceptionESTestscaffolding {
+
+ @org.junit.Rule
+ public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule();
+
+ private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone();
+
+ private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000);
+
+ @BeforeClass
+ public static void initEvoSuiteFramework() {
+ org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.exceptions.ASDCControllerException";
+ org.evosuite.runtime.GuiSupport.initialize();
+ org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100;
+ org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000;
+ org.evosuite.runtime.RuntimeSettings.mockSystemIn = true;
+ org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED;
+ org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT();
+ org.evosuite.runtime.classhandling.JDKClassResetter.init();
+ initializeClasses();
+ org.evosuite.runtime.Runtime.getInstance().resetRuntime();
+ }
+
+ @AfterClass
+ public static void clearEvoSuiteFramework(){
+ Sandbox.resetDefaultSecurityManager();
+ java.lang.System.setProperties((java.util.Properties) defaultProperties.clone());
+ }
+
+ @Before
+ public void initTestCase(){
+ threadStopper.storeCurrentThreads();
+ threadStopper.startRecordingTime();
+ org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler();
+ org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode();
+
+ org.evosuite.runtime.GuiSupport.setHeadless();
+ org.evosuite.runtime.Runtime.getInstance().resetRuntime();
+ org.evosuite.runtime.agent.InstrumentingAgent.activate();
+ }
+
+ @After
+ public void doneWithTestCase(){
+ threadStopper.killAndJoinClientThreads();
+ org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks();
+ org.evosuite.runtime.classhandling.JDKClassResetter.reset();
+ resetClasses();
+ org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode();
+ org.evosuite.runtime.agent.InstrumentingAgent.deactivate();
+ org.evosuite.runtime.GuiSupport.restoreHeadlessMode();
+ }
+
+ private static void initializeClasses() {
+ org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCControllerExceptionESTestscaffolding.class.getClassLoader() ,
+ "org.openecomp.mso.asdc.client.exceptions.ASDCControllerException"
+ );
+ }
+
+ private static void resetClasses() {
+ org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ASDCControllerExceptionESTestscaffolding.class.getClassLoader());
+
+ org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses(
+ "org.openecomp.mso.asdc.client.exceptions.ASDCControllerException"
+ );
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTest.java
new file mode 100644
index 0000000000..75f4b5d27c
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTest.java
@@ -0,0 +1,24 @@
+/*
+ * This file was automatically generated by EvoSuite
+ * Fri Nov 25 13:38:49 GMT 2016
+ */
+
+package org.openecomp.mso.asdc.client.exceptions;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.evosuite.runtime.EvoRunner;
+import org.evosuite.runtime.EvoRunnerParameters;
+import org.junit.runner.RunWith;
+
+@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true)
+public class ASDCDownloadExceptionESTest extends ASDCDownloadExceptionESTestscaffolding {
+
+ @Test(timeout = 4000)
+ public void test0() throws Throwable {
+ ASDCDownloadException aSDCDownloadException0 = new ASDCDownloadException("");
+ ASDCDownloadException aSDCDownloadException1 = new ASDCDownloadException("", (Throwable) aSDCDownloadException0);
+ assertFalse(aSDCDownloadException1.equals((Object)aSDCDownloadException0));
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTestscaffolding.java
new file mode 100644
index 0000000000..5db3c2098f
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTestscaffolding.java
@@ -0,0 +1,82 @@
+/**
+ * Scaffolding file used to store all the setups needed to run
+ * tests automatically generated by EvoSuite
+ * Fri Nov 25 13:38:49 GMT 2016
+ */
+
+package org.openecomp.mso.asdc.client.exceptions;
+
+import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
+import org.junit.BeforeClass;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.evosuite.runtime.sandbox.Sandbox;
+
+@EvoSuiteClassExclude
+public class ASDCDownloadExceptionESTestscaffolding {
+
+ @org.junit.Rule
+ public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule();
+
+ private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone();
+
+ private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000);
+
+ @BeforeClass
+ public static void initEvoSuiteFramework() {
+ org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException";
+ org.evosuite.runtime.GuiSupport.initialize();
+ org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100;
+ org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000;
+ org.evosuite.runtime.RuntimeSettings.mockSystemIn = true;
+ org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED;
+ org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT();
+ org.evosuite.runtime.classhandling.JDKClassResetter.init();
+ initializeClasses();
+ org.evosuite.runtime.Runtime.getInstance().resetRuntime();
+ }
+
+ @AfterClass
+ public static void clearEvoSuiteFramework(){
+ Sandbox.resetDefaultSecurityManager();
+ java.lang.System.setProperties((java.util.Properties) defaultProperties.clone());
+ }
+
+ @Before
+ public void initTestCase(){
+ threadStopper.storeCurrentThreads();
+ threadStopper.startRecordingTime();
+ org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler();
+ org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode();
+
+ org.evosuite.runtime.GuiSupport.setHeadless();
+ org.evosuite.runtime.Runtime.getInstance().resetRuntime();
+ org.evosuite.runtime.agent.InstrumentingAgent.activate();
+ }
+
+ @After
+ public void doneWithTestCase(){
+ threadStopper.killAndJoinClientThreads();
+ org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks();
+ org.evosuite.runtime.classhandling.JDKClassResetter.reset();
+ resetClasses();
+ org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode();
+ org.evosuite.runtime.agent.InstrumentingAgent.deactivate();
+ org.evosuite.runtime.GuiSupport.restoreHeadlessMode();
+ }
+
+ private static void initializeClasses() {
+ org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCDownloadExceptionESTestscaffolding.class.getClassLoader() ,
+ "org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException"
+ );
+ }
+
+ private static void resetClasses() {
+ org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ASDCDownloadExceptionESTestscaffolding.class.getClassLoader());
+
+ org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses(
+ "org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException"
+ );
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTest.java
new file mode 100644
index 0000000000..afc28346e3
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTest.java
@@ -0,0 +1,24 @@
+/*
+ * This file was automatically generated by EvoSuite
+ * Fri Nov 25 13:39:10 GMT 2016
+ */
+
+package org.openecomp.mso.asdc.client.exceptions;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.evosuite.runtime.EvoRunner;
+import org.evosuite.runtime.EvoRunnerParameters;
+import org.junit.runner.RunWith;
+
+@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true)
+public class ASDCParametersExceptionESTest extends ASDCParametersExceptionESTestscaffolding {
+
+ @Test(timeout = 4000)
+ public void test0() throws Throwable {
+ ASDCParametersException aSDCParametersException0 = new ASDCParametersException("4vI_{2b<h&iIy");
+ ASDCParametersException aSDCParametersException1 = new ASDCParametersException((String) null, (Throwable) aSDCParametersException0);
+ assertFalse(aSDCParametersException1.equals((Object)aSDCParametersException0));
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTestscaffolding.java
new file mode 100644
index 0000000000..ce3afc92cd
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTestscaffolding.java
@@ -0,0 +1,82 @@
+/**
+ * Scaffolding file used to store all the setups needed to run
+ * tests automatically generated by EvoSuite
+ * Fri Nov 25 13:39:10 GMT 2016
+ */
+
+package org.openecomp.mso.asdc.client.exceptions;
+
+import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
+import org.junit.BeforeClass;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.evosuite.runtime.sandbox.Sandbox;
+
+@EvoSuiteClassExclude
+public class ASDCParametersExceptionESTestscaffolding {
+
+ @org.junit.Rule
+ public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule();
+
+ private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone();
+
+ private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000);
+
+ @BeforeClass
+ public static void initEvoSuiteFramework() {
+ org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.exceptions.ASDCParametersException";
+ org.evosuite.runtime.GuiSupport.initialize();
+ org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100;
+ org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000;
+ org.evosuite.runtime.RuntimeSettings.mockSystemIn = true;
+ org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED;
+ org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT();
+ org.evosuite.runtime.classhandling.JDKClassResetter.init();
+ initializeClasses();
+ org.evosuite.runtime.Runtime.getInstance().resetRuntime();
+ }
+
+ @AfterClass
+ public static void clearEvoSuiteFramework(){
+ Sandbox.resetDefaultSecurityManager();
+ java.lang.System.setProperties((java.util.Properties) defaultProperties.clone());
+ }
+
+ @Before
+ public void initTestCase(){
+ threadStopper.storeCurrentThreads();
+ threadStopper.startRecordingTime();
+ org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler();
+ org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode();
+
+ org.evosuite.runtime.GuiSupport.setHeadless();
+ org.evosuite.runtime.Runtime.getInstance().resetRuntime();
+ org.evosuite.runtime.agent.InstrumentingAgent.activate();
+ }
+
+ @After
+ public void doneWithTestCase(){
+ threadStopper.killAndJoinClientThreads();
+ org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks();
+ org.evosuite.runtime.classhandling.JDKClassResetter.reset();
+ resetClasses();
+ org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode();
+ org.evosuite.runtime.agent.InstrumentingAgent.deactivate();
+ org.evosuite.runtime.GuiSupport.restoreHeadlessMode();
+ }
+
+ private static void initializeClasses() {
+ org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCParametersExceptionESTestscaffolding.class.getClassLoader() ,
+ "org.openecomp.mso.asdc.client.exceptions.ASDCParametersException"
+ );
+ }
+
+ private static void resetClasses() {
+ org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ASDCParametersExceptionESTestscaffolding.class.getClassLoader());
+
+ org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses(
+ "org.openecomp.mso.asdc.client.exceptions.ASDCParametersException"
+ );
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTest.java
new file mode 100644
index 0000000000..2a1c8177de
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTest.java
@@ -0,0 +1,24 @@
+/*
+ * This file was automatically generated by EvoSuite
+ * Fri Nov 25 13:38:39 GMT 2016
+ */
+
+package org.openecomp.mso.asdc.client.exceptions;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.evosuite.runtime.EvoRunner;
+import org.evosuite.runtime.EvoRunnerParameters;
+import org.junit.runner.RunWith;
+
+@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true)
+public class ArtifactInstallerExceptionESTest extends ArtifactInstallerExceptionESTestscaffolding {
+
+ @Test(timeout = 4000)
+ public void test0() throws Throwable {
+ ArtifactInstallerException artifactInstallerException0 = new ArtifactInstallerException("kD=Ua3[");
+ ArtifactInstallerException artifactInstallerException1 = new ArtifactInstallerException("kD=Ua3[", (Throwable) artifactInstallerException0);
+ assertFalse(artifactInstallerException1.equals((Object)artifactInstallerException0));
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTestscaffolding.java
new file mode 100644
index 0000000000..0bd3d65f0e
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTestscaffolding.java
@@ -0,0 +1,82 @@
+/**
+ * Scaffolding file used to store all the setups needed to run
+ * tests automatically generated by EvoSuite
+ * Fri Nov 25 13:38:39 GMT 2016
+ */
+
+package org.openecomp.mso.asdc.client.exceptions;
+
+import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
+import org.junit.BeforeClass;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.evosuite.runtime.sandbox.Sandbox;
+
+@EvoSuiteClassExclude
+public class ArtifactInstallerExceptionESTestscaffolding {
+
+ @org.junit.Rule
+ public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule();
+
+ private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone();
+
+ private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000);
+
+ @BeforeClass
+ public static void initEvoSuiteFramework() {
+ org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException";
+ org.evosuite.runtime.GuiSupport.initialize();
+ org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100;
+ org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000;
+ org.evosuite.runtime.RuntimeSettings.mockSystemIn = true;
+ org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED;
+ org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT();
+ org.evosuite.runtime.classhandling.JDKClassResetter.init();
+ initializeClasses();
+ org.evosuite.runtime.Runtime.getInstance().resetRuntime();
+ }
+
+ @AfterClass
+ public static void clearEvoSuiteFramework(){
+ Sandbox.resetDefaultSecurityManager();
+ java.lang.System.setProperties((java.util.Properties) defaultProperties.clone());
+ }
+
+ @Before
+ public void initTestCase(){
+ threadStopper.storeCurrentThreads();
+ threadStopper.startRecordingTime();
+ org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler();
+ org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode();
+
+ org.evosuite.runtime.GuiSupport.setHeadless();
+ org.evosuite.runtime.Runtime.getInstance().resetRuntime();
+ org.evosuite.runtime.agent.InstrumentingAgent.activate();
+ }
+
+ @After
+ public void doneWithTestCase(){
+ threadStopper.killAndJoinClientThreads();
+ org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks();
+ org.evosuite.runtime.classhandling.JDKClassResetter.reset();
+ resetClasses();
+ org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode();
+ org.evosuite.runtime.agent.InstrumentingAgent.deactivate();
+ org.evosuite.runtime.GuiSupport.restoreHeadlessMode();
+ }
+
+ private static void initializeClasses() {
+ org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ArtifactInstallerExceptionESTestscaffolding.class.getClassLoader() ,
+ "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException"
+ );
+ }
+
+ private static void resetClasses() {
+ org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ArtifactInstallerExceptionESTestscaffolding.class.getClassLoader());
+
+ org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses(
+ "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException"
+ );
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCConfigurationTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCConfigurationTest.java
new file mode 100644
index 0000000000..168f830f83
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCConfigurationTest.java
@@ -0,0 +1,356 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.asdc.client.tests;
+
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.openecomp.mso.asdc.client.ASDCConfiguration;
+import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException;
+import org.openecomp.mso.properties.MsoPropertiesException;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+
+/**
+ * THis class tests the ASDC Controller by using the ASDC Mock CLient
+ *
+ *
+ */
+public class ASDCConfigurationTest {
+
+ public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
+ public final String ASDC_PROP = ASDCConfigurationTest.class.getClassLoader().getResource("mso.json").toString().substring(5);
+ public final String ASDC_PROP2 = ASDCConfigurationTest.class.getClassLoader().getResource("mso2.json").toString().substring(5);
+ public final String ASDC_PROP3 = ASDCConfigurationTest.class.getClassLoader().getResource("mso3.json").toString().substring(5);
+ public final String ASDC_PROP_BAD = ASDCConfigurationTest.class.getClassLoader().getResource("mso-bad.json").toString().substring(5);
+ public final String ASDC_PROP_WITH_NULL = ASDCConfigurationTest.class.getClassLoader().getResource("mso-with-NULL.json").toString().substring(5);
+ public final String ASDC_PROP_DOUBLE_CONFIG = ASDCConfigurationTest.class.getClassLoader().getResource("mso-two-configs.json").toString().substring(5);
+ public final String ASDC_PROP4_WITH_TLS = ASDCConfigurationTest.class.getClassLoader().getResource("mso4-with-TLS.json").toString().substring(5);
+
+ @BeforeClass
+ public static final void prepareBeforeAllTests() {
+ msoPropertiesFactory.removeAllMsoProperties();
+ }
+
+ @Before
+ public final void prepareBeforeEachTest () throws MsoPropertiesException {
+ msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ }
+
+ @After
+ public final void cleanAfterEachTest () {
+ msoPropertiesFactory.removeAllMsoProperties();
+ }
+
+ @Test
+ public final void testTheInit() throws ASDCParametersException, IOException {
+ ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1");
+ assertNotNull(asdcConfig.getUser());
+ assertTrue("User".equals(asdcConfig.getUser()));
+
+ assertNotNull(asdcConfig.getPassword());
+ assertTrue("ThePassword".equals(asdcConfig.getPassword()));
+
+ assertNotNull(asdcConfig.getConsumerGroup());
+ assertTrue("consumerGroup".equals(asdcConfig.getConsumerGroup()));
+
+ assertNotNull(asdcConfig.getConsumerID());
+ assertTrue("consumerId".equals(asdcConfig.getConsumerID()));
+
+ assertNotNull(asdcConfig.getEnvironmentName());
+ assertTrue("environmentName".equals(asdcConfig.getEnvironmentName()));
+
+ assertNotNull(asdcConfig.getAsdcAddress());
+ assertTrue("hostname".equals(asdcConfig.getAsdcAddress()));
+
+ assertNotNull(asdcConfig.getPollingInterval());
+ assertTrue(asdcConfig.getPollingInterval() == 10);
+
+ assertNotNull(asdcConfig.getPollingTimeout());
+ assertTrue(asdcConfig.getPollingTimeout() == 30);
+
+ assertNotNull(asdcConfig.getRelevantArtifactTypes());
+ assertTrue(asdcConfig.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size());
+
+ assertFalse(asdcConfig.activateServerTLSAuth());
+
+ }
+
+ @Test
+ public final void testAllParametersMethod() throws ASDCParametersException, IOException {
+ ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1");
+
+ // No exception should be raised
+ asdcConfig.testAllParameters();
+ }
+
+ @Test
+ public final void testTheRefreshConfigFalseCase() throws ASDCParametersException, IOException {
+ ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1");
+
+ // No update should be done as we use the mso.properties located in the resource folder for testing
+ assertFalse(asdcConfig.hasASDCConfigChanged());
+ assertFalse(asdcConfig.refreshASDCConfig());
+
+ assertNotNull(asdcConfig.getUser());
+ assertTrue("User".equals(asdcConfig.getUser()));
+
+ assertNotNull(asdcConfig.getPassword());
+ assertTrue("ThePassword".equals(asdcConfig.getPassword()));
+
+ assertNotNull(asdcConfig.getConsumerGroup());
+ assertTrue("consumerGroup".equals(asdcConfig.getConsumerGroup()));
+
+ assertNotNull(asdcConfig.getConsumerID());
+ assertTrue("consumerId".equals(asdcConfig.getConsumerID()));
+
+ assertNotNull(asdcConfig.getEnvironmentName());
+ assertTrue("environmentName".equals(asdcConfig.getEnvironmentName()));
+
+ assertNotNull(asdcConfig.getAsdcAddress());
+ assertTrue("hostname".equals(asdcConfig.getAsdcAddress()));
+
+ assertNotNull(asdcConfig.getPollingInterval());
+ assertTrue(asdcConfig.getPollingInterval() == 10);
+
+ assertNotNull(asdcConfig.getPollingTimeout());
+ assertTrue(asdcConfig.getPollingTimeout() == 30);
+
+ assertNotNull(asdcConfig.getRelevantArtifactTypes());
+ assertTrue(asdcConfig.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size());
+
+ msoPropertiesFactory.removeAllMsoProperties();
+
+ try {
+ asdcConfig.refreshASDCConfig();
+ fail("Should have thrown an ASDCParametersException because config does not exist anymore!");
+ } catch (ASDCParametersException e) {
+ assertTrue(e.getMessage().contains(("mso.asdc.json not initialized properly, ASDC config cannot be reloaded")));
+ }
+
+ try {
+ asdcConfig.hasASDCConfigChanged();
+ fail("Should have thrown an ASDCParametersException because config does not exist anymore!");
+ } catch (ASDCParametersException e) {
+ assertTrue(e.getMessage().contains(("mso.asdc.json not initialized properly, ASDC config cannot be read")));
+ }
+
+ }
+
+
+ @Test
+ public final void testToChangeTheFileAndRefresh () throws ASDCParametersException, IOException, MsoPropertiesException {
+ ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1");
+
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP2);
+ msoPropertiesFactory.reloadMsoProperties();
+
+ // SHould be the same file untouched just a different file name, there should be no difference between them
+ // In a normal case a different Filename should force the system to reload the config but not here as we have changed the filename by reflection
+ assertFalse(asdcConfig.hasASDCConfigChanged());
+ assertFalse(asdcConfig.refreshASDCConfig());
+
+ assertNotNull(asdcConfig.getUser());
+ assertTrue("User".equals(asdcConfig.getUser()));
+
+ assertNotNull(asdcConfig.getPassword());
+ assertTrue("ThePassword".equals(asdcConfig.getPassword()));
+
+ assertNotNull(asdcConfig.getConsumerGroup());
+ assertTrue("consumerGroup".equals(asdcConfig.getConsumerGroup()));
+
+ assertNotNull(asdcConfig.getConsumerID());
+ assertTrue("consumerId".equals(asdcConfig.getConsumerID()));
+
+ assertNotNull(asdcConfig.getEnvironmentName());
+ assertTrue("environmentName".equals(asdcConfig.getEnvironmentName()));
+
+ assertNotNull(asdcConfig.getAsdcAddress());
+ assertTrue("hostname".equals(asdcConfig.getAsdcAddress()));
+
+ assertNotNull(asdcConfig.getPollingInterval());
+ assertTrue(asdcConfig.getPollingInterval() == 10);
+
+ assertNotNull(asdcConfig.getPollingTimeout());
+ assertTrue(asdcConfig.getPollingTimeout() == 30);
+
+ assertNotNull(asdcConfig.getRelevantArtifactTypes());
+ assertTrue(asdcConfig.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size());
+
+ // Set another file that has some attributes changed
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP3);
+ msoPropertiesFactory.reloadMsoProperties();
+
+ // SHould be the same file untouched just a different file name, so new config
+ assertTrue(asdcConfig.hasASDCConfigChanged());
+ assertTrue(asdcConfig.refreshASDCConfig());
+
+ assertNotNull(asdcConfig.getUser());
+ assertTrue("User".equals(asdcConfig.getUser()));
+
+ assertNotNull(asdcConfig.getPassword());
+ assertTrue("ThePassword".equals(asdcConfig.getPassword()));
+
+ assertNotNull(asdcConfig.getConsumerGroup());
+ assertTrue("consumerGroup".equals(asdcConfig.getConsumerGroup()));
+
+ assertNotNull(asdcConfig.getConsumerID());
+ assertTrue("consumerId".equals(asdcConfig.getConsumerID()));
+
+ assertNotNull(asdcConfig.getEnvironmentName());
+ assertTrue("environmentName".equals(asdcConfig.getEnvironmentName()));
+
+ // only this field has been changed
+ assertNotNull(asdcConfig.getAsdcAddress());
+ assertTrue("hostname1".equals(asdcConfig.getAsdcAddress()));
+
+ assertNotNull(asdcConfig.getPollingInterval());
+ assertTrue(asdcConfig.getPollingInterval() == 10);
+
+ assertNotNull(asdcConfig.getPollingTimeout());
+ assertTrue(asdcConfig.getPollingTimeout() == 30);
+
+ assertNotNull(asdcConfig.getRelevantArtifactTypes());
+ assertTrue(asdcConfig.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size());
+
+
+ // reload the good property file for other test cases
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ msoPropertiesFactory.reloadMsoProperties();
+
+ }
+
+ @Test
+ public final void testAllParametersCheck () throws ASDCParametersException, IOException, MsoPropertiesException {
+ ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1");
+
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_BAD);
+ msoPropertiesFactory.reloadMsoProperties();
+ // SHould be a bad file, it should raise an exception
+ try {
+ asdcConfig.refreshASDCConfig();
+ fail("Should have thrown an ASDCControllerException because one param is missing!");
+ } catch (ASDCParametersException e) {
+ assertTrue(e.getMessage().contains(("consumerGroup parameter cannot be found in config mso.properties")));
+ }
+
+
+ // reload the good property file for other test cases
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ msoPropertiesFactory.reloadMsoProperties();
+
+ assertTrue(asdcConfig.refreshASDCConfig());
+
+ }
+
+ @Test
+ public final void testConsumerGroupWithNULL () throws MsoPropertiesException, ASDCParametersException, IOException {
+ ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1");
+
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_WITH_NULL);
+ msoPropertiesFactory.reloadMsoProperties();
+
+ asdcConfig.refreshASDCConfig();
+ assertTrue(asdcConfig.getConsumerGroup()==null);
+
+ // reload the good property file for other test cases
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ msoPropertiesFactory.reloadMsoProperties();
+
+ assertTrue(asdcConfig.refreshASDCConfig());
+
+
+ }
+
+ @Test
+ public final void testGetAllDefinedControllers() throws MsoPropertiesException, ASDCParametersException, IOException {
+ List<String> listControllers = ASDCConfiguration.getAllDefinedControllers();
+
+ assertTrue(listControllers.size()==1);
+ assertTrue("asdc-controller1".equals(listControllers.get(0)));
+
+ ASDCConfiguration asdcConfiguration = new ASDCConfiguration("asdc-controller1");
+ assertTrue(asdcConfiguration.getAsdcControllerName().equals("asdc-controller1"));
+
+
+ // Try to reload a wrong Json file
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_BAD);
+ msoPropertiesFactory.reloadMsoProperties();
+
+ listControllers = ASDCConfiguration.getAllDefinedControllers();
+ assertTrue(listControllers.size()==0);
+
+ }
+
+ @Test
+ public final void testABadInit() throws MsoPropertiesException {
+ msoPropertiesFactory.removeAllMsoProperties();
+
+ try {
+ ASDCConfiguration asdcConfiguration = new ASDCConfiguration("asdc-controller1");
+ fail("Should have thrown an ASDCParametersException because prop factory is empty!");
+ } catch (ASDCParametersException e) {
+ assertTrue(e.getMessage().contains(("mso.asdc.json not initialized properly, ASDC config cannot be reloaded")));
+ } catch (IOException e) {
+ fail("Should have thrown an ASDCParametersException, not IOException because file is corrupted!");
+ }
+ }
+
+ @Test
+ public final void testFileDoesNotExist() throws MsoPropertiesException, ASDCParametersException, IOException {
+
+ ASDCConfiguration asdcConfiguration = new ASDCConfiguration("asdc-controller1");
+
+ msoPropertiesFactory.removeAllMsoProperties();
+
+ try {
+ asdcConfiguration.refreshASDCConfig();
+ fail("Should have thrown an ASDCParametersException because factory is empty!");
+ } catch (ASDCParametersException e) {
+ assertTrue(e.getMessage().contains(("mso.asdc.json not initialized properly, ASDC config cannot be reloaded")));
+ }
+ }
+
+ @Test
+ public final void testWithTLS () throws ASDCParametersException, IOException, MsoPropertiesException {
+ ASDCConfiguration asdcConfiguration = new ASDCConfiguration("asdc-controller1");
+
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP4_WITH_TLS);
+ msoPropertiesFactory.reloadMsoProperties();
+
+ asdcConfiguration.refreshASDCConfig();
+
+ assertTrue(asdcConfiguration.activateServerTLSAuth());
+ assertTrue("/test".equals(asdcConfiguration.getKeyStorePath()));
+ assertTrue("ThePassword".equals(asdcConfiguration.getKeyStorePassword()));
+ }
+
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java
new file mode 100644
index 0000000000..b6c5577b63
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java
@@ -0,0 +1,412 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.asdc.client.tests;
+
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.codec.binary.Base64;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import org.openecomp.sdc.api.IDistributionClient;
+import org.openecomp.sdc.api.consumer.INotificationCallback;
+import org.openecomp.sdc.api.notification.IArtifactInfo;
+import org.openecomp.sdc.api.notification.INotificationData;
+import org.openecomp.sdc.api.notification.IResourceInstance;
+import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
+import org.openecomp.sdc.api.results.IDistributionClientResult;
+import org.openecomp.sdc.impl.mock.DistributionClientStubImpl;
+import org.openecomp.sdc.utils.DistributionActionResultEnum;
+import org.openecomp.mso.asdc.client.ASDCConfiguration;
+import org.openecomp.mso.asdc.client.ASDCController;
+import org.openecomp.mso.asdc.client.ASDCControllerStatus;
+import org.openecomp.mso.asdc.client.exceptions.ASDCControllerException;
+import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException;
+import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
+import org.openecomp.mso.asdc.installer.heat.VfResourceInstaller;
+import org.openecomp.mso.properties.MsoJavaProperties;
+import org.openecomp.mso.properties.MsoPropertiesException;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+
+
+
+/**
+ * THis class tests the ASDC Controller by using the ASDC Mock CLient
+ *
+ *
+ */
+public class ASDCControllerTest {
+
+ private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
+
+ private static String heatExample;
+ private static String heatExampleMD5HashBase64;
+
+ private static INotificationData iNotif;
+
+ private static IDistributionClientDownloadResult downloadResult;
+ private static IDistributionClientDownloadResult downloadCorruptedResult;
+
+ private static IDistributionClientResult successfulClientInitResult;
+ private static IDistributionClientResult unsuccessfulClientInitResult;
+
+ private static IArtifactInfo artifactInfo1;
+
+ private static IResourceInstance resource1;
+
+ private static VfResourceInstaller vnfInstaller;
+
+ public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString().substring(5);
+ public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString().substring(5);
+ public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString().substring(5);
+ public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json").toString().substring(5);
+ public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader().getResource("mso-with-NULL.json").toString().substring(5);
+
+ @BeforeClass
+ public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException, NoSuchAlgorithmException, ArtifactInstallerException {
+
+ heatExample = new String(Files.readAllBytes(Paths.get(ASDCControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI())));
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ byte[] md5Hash = md.digest(heatExample.getBytes());
+ heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash);
+
+ iNotif= Mockito.mock(INotificationData.class);
+
+ // Create fake ArtifactInfo
+ artifactInfo1 = Mockito.mock(IArtifactInfo.class);
+ Mockito.when(artifactInfo1.getArtifactChecksum()).thenReturn(ASDCControllerTest.heatExampleMD5HashBase64);
+
+ Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1");
+ Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT);
+ Mockito.when(artifactInfo1.getArtifactURL()).thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
+ Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1");
+ Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1");
+
+ // Now provision the NotificationData mock
+ List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>();
+ listArtifact.add(artifactInfo1);
+
+ // Create fake resource Instance
+ resource1 = Mockito.mock (IResourceInstance.class);
+ Mockito.when (resource1.getResourceType ()).thenReturn ("VF");
+ Mockito.when (resource1.getResourceName ()).thenReturn ("resourceName");
+ Mockito.when (resource1.getArtifacts ()).thenReturn (listArtifact);
+
+ List<IResourceInstance> resources = new ArrayList<> ();
+ resources.add (resource1);
+
+ Mockito.when(iNotif.getResources()).thenReturn(resources);
+ Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1");
+ Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1");
+ Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1");
+ Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0");
+
+ downloadResult = Mockito.mock(IDistributionClientDownloadResult.class);
+ Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes());
+ Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);
+ Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success");
+
+ downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class);
+ Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample+"badone").getBytes());
+ Mockito.when(downloadCorruptedResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);
+ Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success");
+
+ vnfInstaller = Mockito.mock(VfResourceInstaller.class);
+
+ // Mock now the ASDC distribution client behavior
+ successfulClientInitResult = Mockito.mock(IDistributionClientResult.class);
+ Mockito.when(successfulClientInitResult.getDistributionActionResult ()).thenReturn(DistributionActionResultEnum.SUCCESS);
+
+ unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class);
+ Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult ()).thenReturn(DistributionActionResultEnum.GENERAL_ERROR);
+
+ }
+
+ @Before
+ public final void initBeforeEachTest() throws MsoPropertiesException {
+ // load the config
+ msoPropertiesFactory.removeAllMsoProperties();
+ msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ }
+
+ @AfterClass
+ public static final void kill () throws MsoPropertiesException {
+
+ msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC);
+
+ }
+
+ @Test
+ public final void testTheInitWithASDCStub() throws ASDCControllerException, ASDCParametersException, IOException {
+
+ ASDCController asdcController = new ASDCController("asdc-controller1",new DistributionClientStubImpl());
+ asdcController.initASDC();
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE);
+ assertTrue(asdcController.getNbOfNotificationsOngoing()== 0);
+ }
+
+ @Test
+ public final void testTheNotificationWithASDCStub() throws ASDCControllerException, ASDCParametersException, IOException {
+
+ ASDCController asdcController = new ASDCController("asdc-controller1",new DistributionClientStubImpl(),vnfInstaller);
+ asdcController.initASDC();
+ // try to send a notif, this should fail internally, we just want to ensure that in case of crash, controller status goes to IDLE
+ asdcController.treatNotification(iNotif);
+
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE);
+ assertTrue(asdcController.getNbOfNotificationsOngoing()== 0);
+
+ }
+
+ @Test
+ public final void testASecondInit() throws ASDCControllerException, ASDCParametersException, IOException {
+ ASDCController asdcController = new ASDCController("asdc-controller1",new DistributionClientStubImpl(),vnfInstaller);
+ asdcController.initASDC();
+ // try to send a notif, this should fail internally, we just want to ensure that in case of crash, controller status goes to IDLE
+
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE);
+ assertTrue(asdcController.getNbOfNotificationsOngoing()== 0);
+
+ try {
+ asdcController.initASDC();
+ fail("ASDCControllerException should have been raised for the init");
+ } catch (ASDCControllerException e) {
+ assertTrue("The controller is already initialized, call the closeASDC method first".equals(e.getMessage()));
+ }
+
+ // No changes expected on the controller state
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE);
+ assertTrue(asdcController.getNbOfNotificationsOngoing()== 0);
+ }
+
+ @Test
+ public final void testInitCrashWithMockitoClient() throws ASDCParametersException, IOException {
+
+ IDistributionClient distributionClient;
+ // First case for init method
+ distributionClient = Mockito.mock(IDistributionClient.class);
+ Mockito.when(distributionClient.download(artifactInfo1)).thenThrow(new RuntimeException("ASDC Client not initialized"));
+ Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(unsuccessfulClientInitResult);
+ Mockito.when(distributionClient.start()).thenReturn(unsuccessfulClientInitResult);
+
+ ASDCController asdcController = new ASDCController("asdc-controller1",distributionClient,vnfInstaller);
+
+ // This should return an exception
+ try {
+ asdcController.initASDC();
+ fail("ASDCControllerException should have been raised for the init");
+ } catch (ASDCControllerException e) {
+ assertTrue("Initialization of the ASDC Controller failed with reason: null".equals(e.getMessage()));
+ }
+
+ assertTrue(asdcController.getControllerStatus() == ASDCControllerStatus.STOPPED);
+ assertTrue(asdcController.getNbOfNotificationsOngoing()== 0);
+
+ // Second case for start method
+
+ Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(successfulClientInitResult);
+ Mockito.when(distributionClient.start()).thenReturn(unsuccessfulClientInitResult);
+
+ // This should return an exception
+ try {
+ asdcController.initASDC();
+ fail("ASDCControllerException should have been raised for the init");
+ } catch (ASDCControllerException e) {
+ assertTrue("Startup of the ASDC Controller failed with reason: null".equals(e.getMessage()));
+ }
+
+ assertTrue(asdcController.getControllerStatus() == ASDCControllerStatus.STOPPED);
+ assertTrue(asdcController.getNbOfNotificationsOngoing()== 0);
+ }
+
+ @Test
+ public final void testTheStop() throws ASDCControllerException, ASDCParametersException, IOException {
+
+ ASDCController asdcController = new ASDCController("asdc-controller1",new DistributionClientStubImpl(),vnfInstaller);
+
+ asdcController.closeASDC();
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.STOPPED);
+
+
+ asdcController = new ASDCController("asdc-controller1",new DistributionClientStubImpl(),vnfInstaller);
+ asdcController.initASDC();
+ asdcController.closeASDC();
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.STOPPED);
+ }
+
+ @Test
+ public final void testConfigRefresh () throws ASDCParametersException, ASDCControllerException, IOException, MsoPropertiesException {
+ IDistributionClient distributionClient;
+ distributionClient = Mockito.mock(IDistributionClient.class);
+ Mockito.when(distributionClient.download(artifactInfo1)).thenReturn(downloadResult);
+ Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(successfulClientInitResult);
+ Mockito.when(distributionClient.start()).thenReturn(successfulClientInitResult);
+
+
+ ASDCController asdcController = new ASDCController("asdc-controller1",distributionClient,vnfInstaller);
+
+ // it should not raise any exception even if controller is not yet initialized
+ asdcController.updateConfigIfNeeded();
+
+ asdcController.initASDC();
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE);
+ assertFalse(asdcController.updateConfigIfNeeded());
+
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP3);
+ msoPropertiesFactory.reloadMsoProperties();
+ // It should fail if it tries to refresh the config as the init will now fail
+ assertTrue(asdcController.updateConfigIfNeeded());
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE);
+
+
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ msoPropertiesFactory.reloadMsoProperties();
+ }
+
+ @Test
+ public final void testConfigRefreshWhenBusy () throws IOException, MsoPropertiesException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ASDCParametersException, ASDCControllerException {
+ IDistributionClient distributionClient;
+ distributionClient = Mockito.mock(IDistributionClient.class);
+ Mockito.when(distributionClient.download(artifactInfo1)).thenReturn(downloadResult);
+ Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(successfulClientInitResult);
+ Mockito.when(distributionClient.start()).thenReturn(successfulClientInitResult);
+
+ ASDCController asdcController = new ASDCController("asdc-controller1",distributionClient,vnfInstaller);
+
+ // it should not raise any exception even if controller is not yet initialized
+ asdcController.updateConfigIfNeeded();
+
+ asdcController.initASDC();
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE);
+ assertFalse(asdcController.updateConfigIfNeeded());
+
+ // Simulate a BUSY case by reflection
+ Field controllerStatus;
+ controllerStatus = ASDCController.class.getDeclaredField("controllerStatus");
+ controllerStatus.setAccessible(true);
+ controllerStatus.set(asdcController,ASDCControllerStatus.BUSY);
+
+
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP3);
+ msoPropertiesFactory.reloadMsoProperties();
+ // It should fail if it tries to refresh the config as the init will now fail
+ try {
+ asdcController.updateConfigIfNeeded();
+ fail ("ASDCControllerException should have been raised");
+ } catch (ASDCControllerException e) {
+ assertTrue("Cannot close the ASDC controller as it's currently in BUSY state".equals(e.getMessage()));
+ }
+
+ // Try it a second time to see if we still see the changes
+ try {
+ asdcController.updateConfigIfNeeded();
+ fail ("ASDCControllerException should have been raised");
+ } catch (ASDCControllerException e) {
+ assertTrue("Cannot close the ASDC controller as it's currently in BUSY state".equals(e.getMessage()));
+ }
+
+ // Revert to Idle by reflection
+ controllerStatus.set(asdcController,ASDCControllerStatus.IDLE);
+ controllerStatus.setAccessible(false);
+
+ // This should work now, controller should be restarted
+ assertTrue(asdcController.updateConfigIfNeeded());
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE);
+
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ msoPropertiesFactory.reloadMsoProperties();
+ }
+
+
+ @Test
+ public final void testBadConfigRefresh () throws ASDCParametersException, ASDCControllerException, IOException, MsoPropertiesException {
+ IDistributionClient distributionClient;
+ distributionClient = Mockito.mock(IDistributionClient.class);
+ Mockito.when(distributionClient.download(artifactInfo1)).thenReturn(downloadResult);
+ Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(successfulClientInitResult);
+ Mockito.when(distributionClient.start()).thenReturn(successfulClientInitResult);
+
+
+ ASDCController asdcController = new ASDCController("asdc-controller1",distributionClient,vnfInstaller);
+
+ // it should not raise any exception even if controller is not yet initialized
+ asdcController.updateConfigIfNeeded();
+
+ asdcController.initASDC();
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE);
+ assertFalse(asdcController.updateConfigIfNeeded());
+
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_BAD);
+ msoPropertiesFactory.reloadMsoProperties();
+ // It should fail if it tries to refresh the config as the init will now fail
+ try {
+ asdcController.updateConfigIfNeeded();
+ fail ("ASDCParametersException should have been raised");
+ } catch (ASDCParametersException ep) {
+ assertTrue("consumerGroup parameter cannot be found in config mso.properties".equals(ep.getMessage()));
+ }
+
+ // This should stop the controller, as it can't work with a bad config file
+ assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.STOPPED);
+
+
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ msoPropertiesFactory.reloadMsoProperties();
+ }
+
+ @Test
+ public final void testConfigAccess () throws ASDCControllerException, ASDCParametersException, IOException {
+ IDistributionClient distributionClient;
+ distributionClient = Mockito.mock(IDistributionClient.class);
+ Mockito.when(distributionClient.download(artifactInfo1)).thenReturn(downloadResult);
+ Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(successfulClientInitResult);
+ Mockito.when(distributionClient.start()).thenReturn(successfulClientInitResult);
+
+
+ ASDCController asdcController = new ASDCController("asdc-controller1",distributionClient,vnfInstaller);
+
+ assertTrue("Unknown".equals(asdcController.getAddress()));
+ assertTrue("Unknown".equals(asdcController.getEnvironment()));
+
+ asdcController.initASDC();
+
+ assertTrue("hostname".equals(asdcController.getAddress()));
+ assertTrue("environmentName".equals(asdcController.getEnvironment()));
+
+ }
+
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCElementInfoTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCElementInfoTest.java
new file mode 100644
index 0000000000..23b7a80dbe
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCElementInfoTest.java
@@ -0,0 +1,175 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.asdc.client.tests;
+
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
+import java.util.UUID;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import org.openecomp.sdc.api.notification.IArtifactInfo;
+import org.openecomp.sdc.api.notification.INotificationData;
+import org.openecomp.sdc.api.notification.IResourceInstance;
+import org.openecomp.sdc.api.notification.IVfModuleMetadata;
+import org.openecomp.mso.asdc.client.ASDCConfiguration;
+import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
+import org.openecomp.mso.asdc.installer.ASDCElementInfo;
+import org.openecomp.mso.asdc.installer.VfModuleStructure;
+import org.openecomp.mso.asdc.installer.VfResourceStructure;
+
+
+public class ASDCElementInfoTest {
+
+ @Test
+ public void createASDCElementInfoWithNullParameterTest() {
+ ASDCElementInfo elementInfoFromNullVfArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(null);
+ ASDCElementInfo elementInfoFromNullVfModuleStructure = ASDCElementInfo.createElementFromVfModuleStructure(null);
+ ASDCElementInfo elementInfoFromNullVfResourceStructure = ASDCElementInfo.createElementFromVfResourceStructure(null);
+
+ elementInfoFromNullVfArtifact.addElementInfo(null, null);
+ elementInfoFromNullVfModuleStructure.addElementInfo(null, "someValue");
+ elementInfoFromNullVfResourceStructure.addElementInfo("someKey", null);
+
+ assertEquals(elementInfoFromNullVfArtifact.toString(), "");
+ assertEquals(elementInfoFromNullVfModuleStructure.toString(), "");
+ assertEquals(elementInfoFromNullVfResourceStructure.toString(), "");
+
+ assertNotNull(elementInfoFromNullVfArtifact);
+ assertNotNull(elementInfoFromNullVfModuleStructure);
+ assertNotNull(elementInfoFromNullVfResourceStructure);
+
+ assertNotNull(ASDCElementInfo.EMPTY_INSTANCE);
+
+ assertEquals(elementInfoFromNullVfArtifact, ASDCElementInfo.EMPTY_INSTANCE);
+ assertEquals(elementInfoFromNullVfModuleStructure, ASDCElementInfo.EMPTY_INSTANCE);
+ assertEquals(elementInfoFromNullVfResourceStructure, ASDCElementInfo.EMPTY_INSTANCE);
+
+ assertEquals(ASDCElementInfo.EMPTY_INSTANCE.getType(), "");
+ assertEquals(ASDCElementInfo.EMPTY_INSTANCE.toString(), "");
+
+ assertEquals(elementInfoFromNullVfArtifact.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
+ assertEquals(elementInfoFromNullVfModuleStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
+ assertEquals(elementInfoFromNullVfResourceStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
+ }
+
+ @Test
+ public void createASDCElementInfoFromVfResourceTest() {
+
+ String resourceInstanceName = "Resource 1";
+
+ UUID generatedUUID = UUID.randomUUID();
+
+ INotificationData notificationData = Mockito.mock(INotificationData.class);
+ IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
+
+ Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
+ Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
+
+ VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
+
+ ASDCElementInfo elementInfoFromVfResource = ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure);
+
+ assertTrue(elementInfoFromVfResource.toString().contains(resourceInstanceName));
+ assertTrue(elementInfoFromVfResource.toString().contains(generatedUUID.toString()));
+
+ assertFalse(ASDCConfiguration.VF_MODULES_METADATA.equals(elementInfoFromVfResource.getType()));
+ assertEquals(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name(), elementInfoFromVfResource.getType());
+
+ assertFalse(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));
+ elementInfoFromVfResource.addElementInfo("MyInfo1", "someValue");
+ assertTrue(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));
+ }
+
+ @Test
+ public void createASDCElementInfoFromVfModuleTest() throws ArtifactInstallerException {
+
+ String resourceInstanceName = "Resource 1";
+
+ UUID generatedUUID = UUID.randomUUID();
+
+ INotificationData notificationData = Mockito.mock(INotificationData.class);
+ IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
+
+ Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
+ Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
+
+ VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
+
+ // Create module structure now
+
+ String vfModuleModelName = "Module Model XYZ";
+
+ UUID generatedUUIDForModule = UUID.randomUUID();
+
+ IVfModuleMetadata moduleMetadata = Mockito.mock(IVfModuleMetadata.class);
+ Mockito.when(moduleMetadata.getVfModuleModelName()).thenReturn(vfModuleModelName);
+ Mockito.when(moduleMetadata.getVfModuleModelInvariantUUID()).thenReturn(generatedUUIDForModule.toString());
+ Mockito.when(moduleMetadata.getArtifacts()).thenReturn(Collections.<String> emptyList());
+
+ VfModuleStructure vfModuleStructure = new VfModuleStructure(vfResourceStructure, moduleMetadata);
+
+ ASDCElementInfo elementInfoFromVfModule = ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure);
+
+ assertTrue(elementInfoFromVfModule.toString().contains(vfModuleModelName));
+ assertTrue(elementInfoFromVfModule.toString().contains(generatedUUIDForModule.toString()));
+
+ assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromVfModule.getType()));
+ assertEquals(ASDCConfiguration.VF_MODULES_METADATA, elementInfoFromVfModule.getType());
+
+ assertFalse(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
+ elementInfoFromVfModule.addElementInfo("MyInfo2", "someValue");
+ assertTrue(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
+ }
+
+ @Test
+ public void createASDCElementInfoFromArtifact() {
+ for (String eVal : ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST) {
+ String generatedArtifactName = eVal + " 1";
+ UUID generatedUUIDForArtifact = UUID.randomUUID();
+
+ IArtifactInfo artifactInfo = Mockito.mock(IArtifactInfo.class);
+ Mockito.when(artifactInfo.getArtifactType()).thenReturn(eVal);
+ Mockito.when(artifactInfo.getArtifactName()).thenReturn(generatedArtifactName);
+ Mockito.when(artifactInfo.getArtifactUUID()).thenReturn(generatedUUIDForArtifact.toString());
+
+ ASDCElementInfo elementInfoFromArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(artifactInfo);
+
+ assertTrue(elementInfoFromArtifact.toString().contains(generatedArtifactName));
+ assertTrue(elementInfoFromArtifact.toString().contains(generatedUUIDForArtifact.toString()));
+
+ assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromArtifact.getType()));
+ assertEquals(eVal, elementInfoFromArtifact.getType());
+
+ assertFalse(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));
+ elementInfoFromArtifact.addElementInfo("MyInfo3", "someValue");
+ assertTrue(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));
+ }
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCGlobalControllerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCGlobalControllerTest.java
new file mode 100644
index 0000000000..9ac50c4854
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCGlobalControllerTest.java
@@ -0,0 +1,213 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.asdc.client.tests;
+
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.codec.binary.Base64;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import org.openecomp.sdc.api.notification.IArtifactInfo;
+import org.openecomp.sdc.api.notification.INotificationData;
+import org.openecomp.sdc.api.notification.IResourceInstance;
+import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
+import org.openecomp.sdc.api.results.IDistributionClientResult;
+import org.openecomp.sdc.utils.DistributionActionResultEnum;
+import org.openecomp.mso.asdc.client.ASDCConfiguration;
+import org.openecomp.mso.asdc.client.ASDCGlobalController;
+import org.openecomp.mso.asdc.client.exceptions.ASDCControllerException;
+import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException;
+import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
+import org.openecomp.mso.properties.MsoJavaProperties;
+import org.openecomp.mso.properties.MsoPropertiesException;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
+
+
+
+/**
+ * THis class tests the ASDC Controller by using the ASDC Mock CLient
+ *
+ *
+ */
+public class ASDCGlobalControllerTest {
+
+ private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
+
+ private static String heatExample;
+ private static String heatExampleMD5HashBase64;
+
+ private static INotificationData iNotif;
+
+ private static IDistributionClientDownloadResult downloadResult;
+ private static IDistributionClientDownloadResult downloadCorruptedResult;
+
+ private static IDistributionClientResult successfulClientInitResult;
+ private static IDistributionClientResult unsuccessfulClientInitResult;
+
+ private static IArtifactInfo artifactInfo1;
+
+ private static IResourceInstance resource1;
+
+ public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString().substring(5);
+ public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString().substring(5);
+ public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString().substring(5);
+ public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json").toString().substring(5);
+ public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader().getResource("mso-with-NULL.json").toString().substring(5);
+ public static final String ASDC_PROP_WITH_DOUBLE = MsoJavaProperties.class.getClassLoader().getResource("mso-two-configs.json").toString().substring(5);
+ public static final String ASDC_PROP_WITH_DOUBLE2 = MsoJavaProperties.class.getClassLoader().getResource("mso-two-configs2.json").toString().substring(5);
+
+ @BeforeClass
+ public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException, NoSuchAlgorithmException, ArtifactInstallerException {
+
+ heatExample = new String(Files.readAllBytes(Paths.get(ASDCGlobalControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI())));
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ byte[] md5Hash = md.digest(heatExample.getBytes());
+ heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash);
+
+ iNotif= Mockito.mock(INotificationData.class);
+
+ // Create fake ArtifactInfo
+ artifactInfo1 = Mockito.mock(IArtifactInfo.class);
+ Mockito.when(artifactInfo1.getArtifactChecksum()).thenReturn(ASDCGlobalControllerTest.heatExampleMD5HashBase64);
+
+ Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1");
+ Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT);
+ Mockito.when(artifactInfo1.getArtifactURL()).thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
+ Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1");
+ Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1");
+
+ // Now provision the NotificationData mock
+ List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>();
+ listArtifact.add(artifactInfo1);
+
+ // Create fake resource Instance
+ resource1 = Mockito.mock (IResourceInstance.class);
+ Mockito.when (resource1.getResourceType ()).thenReturn ("VF");
+ Mockito.when (resource1.getResourceName ()).thenReturn ("resourceName");
+ Mockito.when (resource1.getArtifacts ()).thenReturn (listArtifact);
+
+ List<IResourceInstance> resources = new ArrayList<> ();
+ resources.add (resource1);
+
+ Mockito.when(iNotif.getResources()).thenReturn(resources);
+ Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1");
+ Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1");
+ Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1");
+ Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0");
+
+ downloadResult = Mockito.mock(IDistributionClientDownloadResult.class);
+ Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes());
+ Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);
+ Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success");
+
+ downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class);
+ Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample+"badone").getBytes());
+ Mockito.when(downloadCorruptedResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);
+ Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success");
+
+
+ // Mock now the ASDC distribution client behavior
+ successfulClientInitResult = Mockito.mock(IDistributionClientResult.class);
+ Mockito.when(successfulClientInitResult.getDistributionActionResult ()).thenReturn(DistributionActionResultEnum.SUCCESS);
+
+ unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class);
+ Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult ()).thenReturn(DistributionActionResultEnum.GENERAL_ERROR);
+
+ }
+
+ @Before
+ public final void initBeforeEachTest() throws MsoPropertiesException {
+ // load the config
+ msoPropertiesFactory.removeAllMsoProperties();
+ msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ }
+
+ @AfterClass
+ public static final void kill () throws MsoPropertiesException {
+
+ msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC);
+ }
+
+ @Test
+ public final void testUpdateControllersConfigIfNeeded() throws ASDCControllerException, ASDCParametersException, IOException, MsoPropertiesException {
+
+ ASDCGlobalController asdcGlobalController = new ASDCGlobalController();
+ assertTrue(asdcGlobalController.getControllers().size()==0);
+
+ // first init
+ assertTrue(asdcGlobalController.updateControllersConfigIfNeeded());
+ assertTrue(asdcGlobalController.getControllers().size()==1);
+ assertTrue(asdcGlobalController.getControllers().get("asdc-controller1") != null);
+
+ // Add a second one
+ msoPropertiesFactory.removeAllMsoProperties();
+ msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_WITH_DOUBLE);
+ assertTrue(asdcGlobalController.updateControllersConfigIfNeeded());
+ assertTrue(asdcGlobalController.getControllers().size()==2);
+ assertTrue(asdcGlobalController.getControllers().get("asdc-controller1") != null);
+ assertTrue(asdcGlobalController.getControllers().get("asdc-controller2") != null);
+ // Check that update does nothing
+ assertFalse(asdcGlobalController.updateControllersConfigIfNeeded());
+ assertTrue(asdcGlobalController.getControllers().size()==2);
+
+ // Change the second one name
+ msoPropertiesFactory.removeAllMsoProperties();
+ msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_WITH_DOUBLE2);
+ assertTrue(asdcGlobalController.updateControllersConfigIfNeeded());
+ assertTrue(asdcGlobalController.getControllers().size()==2);
+ assertTrue(asdcGlobalController.getControllers().get("asdc-controller1") != null);
+ assertTrue(asdcGlobalController.getControllers().get("asdc-controller2B") != null);
+
+
+ }
+
+ @Test
+ public final void testCloseASDC() {
+
+ ASDCGlobalController asdcGlobalController = new ASDCGlobalController();
+ assertTrue(asdcGlobalController.getControllers().size()==0);
+
+ // first init
+ assertTrue(asdcGlobalController.updateControllersConfigIfNeeded());
+ assertTrue(asdcGlobalController.getControllers().size()==1);
+ assertTrue(asdcGlobalController.getControllers().get("asdc-controller1") != null);
+
+ asdcGlobalController.closeASDC();
+ assertTrue(asdcGlobalController.getControllers().size()==0);
+
+
+ }
+
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/BigDecimalVersionTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/BigDecimalVersionTest.java
new file mode 100644
index 0000000000..7decaffb2b
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/BigDecimalVersionTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.asdc.client.tests;
+
+
+import static org.junit.Assert.assertTrue;
+import java.math.BigDecimal;
+import org.junit.Test;
+
+import org.openecomp.mso.asdc.installer.BigDecimalVersion;
+
+
+public class BigDecimalVersionTest {
+
+ @Test
+ public final void versionCastTest () {
+
+ BigDecimal versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("12.0");
+ assertTrue(versionDecimal.equals(new BigDecimal("12.0")));
+ assertTrue("12.0".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("12.0")));
+
+ versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("12.0.2");
+ assertTrue(versionDecimal.equals(new BigDecimal("12.02")));
+ assertTrue("12.02".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("12.0.2")));
+
+ versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("10");
+ assertTrue(versionDecimal.equals(new BigDecimal("10")));
+ assertTrue("10".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("10")));
+
+ versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("10.1.2.6");
+ assertTrue(versionDecimal.equals(new BigDecimal("10.126")));
+ assertTrue("10.126".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("10.1.2.6")));
+
+ }
+}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/YamlTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/YamlTest.java
new file mode 100644
index 0000000000..bce9324de9
--- /dev/null
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/YamlTest.java
@@ -0,0 +1,165 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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.asdc.client.tests;
+
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.io.IOUtils;
+import org.junit.Test;
+
+import org.openecomp.mso.asdc.installer.heat.VfResourceInstaller;
+import org.openecomp.mso.asdc.util.YamlEditor;
+import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
+
+
+public class YamlTest {
+ @Test
+ public void getYamlResourceTypeTestList() throws Exception {
+
+ InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
+ YamlEditor decoder = new YamlEditor (IOUtils.toByteArray(input));
+ List<String> typeList = decoder.getYamlNestedFileResourceTypeList();
+
+ assertTrue(typeList.size() == 1 && typeList.get(0).equals("file:///my_test.yaml"));
+ }
+
+ @Test
+ public void getParameterListTest() throws Exception {
+
+ InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
+ YamlEditor decoder = new YamlEditor (IOUtils.toByteArray(input));
+ Set <HeatTemplateParam> paramSet = decoder.getParameterList();
+
+ assertTrue(paramSet.size() == 5);
+
+ for (HeatTemplateParam param : paramSet) {
+ if ("ip_port_snmp_manager".equals(param.getParamName()) || "cor_direct_net_name".equals(param.getParamName()) || "cor_direct_net_RT".equals(param.getParamName())) {
+
+ assertTrue(param.isRequired()==false);
+ } else {
+
+ assertTrue(param.isRequired()==true);
+ }
+
+ assertTrue("string".equals(param.getParamType()));
+ }
+ }
+
+ @Test
+ public void addParameterListWhenEmptyTest() throws Exception {
+
+ InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTestWithoutParam.yaml"));
+ YamlEditor decoder = new YamlEditor (IOUtils.toByteArray(input));
+
+ Set <HeatTemplateParam> newParamSet = new HashSet <HeatTemplateParam> ();
+
+ HeatTemplateParam heatParam1 = new HeatTemplateParam();
+ heatParam1.setId(1);
+ heatParam1.setParamName("testos1");
+ heatParam1.setParamType("string");
+
+ HeatTemplateParam heatParam2 = new HeatTemplateParam();
+ heatParam2.setId(2);
+ heatParam2.setParamName("testos2");
+ heatParam2.setParamType("number");
+
+ newParamSet.add(heatParam1);
+ newParamSet.add(heatParam2);
+
+ decoder.addParameterList(newParamSet);
+
+ Set <HeatTemplateParam> paramSet = decoder.getParameterList();
+ assertTrue(paramSet.size() == 2);
+
+ assertTrue(decoder.encode().contains("testos1"));
+ assertTrue(decoder.encode().contains("string"));
+ assertTrue(decoder.encode().contains("testos2"));
+ assertTrue(decoder.encode().contains("number"));
+ }
+
+ @Test
+ public void addParameterListTest() throws Exception {
+
+ InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
+ YamlEditor decoder = new YamlEditor (IOUtils.toByteArray(input));
+
+ Set <HeatTemplateParam> newParamSet = new HashSet <HeatTemplateParam> ();
+
+ HeatTemplateParam heatParam1 = new HeatTemplateParam();
+ heatParam1.setId(1);
+ heatParam1.setParamName("testos1");
+ heatParam1.setParamType("string");
+
+ HeatTemplateParam heatParam2 = new HeatTemplateParam();
+ heatParam2.setId(2);
+ heatParam2.setParamName("testos2");
+ heatParam2.setParamType("number");
+
+ newParamSet.add(heatParam1);
+ newParamSet.add(heatParam2);
+
+ decoder.addParameterList(newParamSet);
+
+ Set <HeatTemplateParam> paramSet = decoder.getParameterList();
+
+ assertTrue(paramSet.size() == 7);
+
+ Boolean check1 = Boolean.FALSE;
+ Boolean check2 = Boolean.FALSE;
+
+ for (HeatTemplateParam param : paramSet) {
+ if ("ip_port_snmp_manager".equals(param.getParamName()) || "cor_direct_net_name".equals(param.getParamName()) || "cor_direct_net_RT".equals(param.getParamName())) {
+ assertFalse(param.isRequired());
+ } else {
+ assertTrue(param.isRequired());
+ }
+
+ if ("testos1".equals(param.getParamName()) && "string".equals(param.getParamType())) {
+ check1=Boolean.TRUE;
+ }
+
+ if ("testos2".equals(param.getParamName()) && "number".equals(param.getParamType())) {
+ check2=Boolean.TRUE;
+ }
+
+ }
+
+ assertTrue(check1);
+ assertTrue(check2);
+ }
+
+ @Test
+ public void VfResourceInstallerTest() throws Exception {
+
+ assertTrue("mon ami toto, est dans le bois: toto ici".equals(VfResourceInstaller.verifyTheFilePrefixInString("mon ami toto, est dans le bois: toto ici","toto")));
+ assertTrue("mon ami toto, est dans le bois: toto ici".equals(VfResourceInstaller.verifyTheFilePrefixInString("mon ami file:///toto, est dans le bois: file:///toto ici","toto")));
+ assertTrue("mon ami toto, est dans le bois: toto ici".equals(VfResourceInstaller.verifyTheFilePrefixInString("mon ami file:///toto, est dans le bois: toto ici","toto")));
+ assertTrue("mon ami toto, est dans le bois: toto ici".equals(VfResourceInstaller.verifyTheFilePrefixInString("mon ami toto, est dans le bois: file:///toto ici","toto")));
+
+ }
+}