summaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/test
diff options
context:
space:
mode:
authorMarcus G K Williams <marcus.williams@intel.com>2018-03-07 18:17:22 -0800
committerMarcus G K Williams <marcus.williams@intel.com>2018-03-08 09:17:48 -0800
commit327b17ab250b4c17cf3f91f5e4cd9bffd89f3d1e (patch)
tree0d943226962ae31c0bf2fd0696e91c6bb41d099c /asdc-controller/src/test
parentdee036198ee09d71bfdd50247c1d23a7f472df87 (diff)
Reduce log noise/warnings format to conventions
Reduce build log warnings by formatting tests to ONAP code conventions (removing tabs etc.) Issue-ID: SO-368 Change-Id: I48c6d359b83617aebeb79db4e30c1d72d31f7eec Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
Diffstat (limited to 'asdc-controller/src/test')
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCConfigurationTest.java618
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java628
-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.java288
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/BigDecimalVersionTest.java28
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/YamlTest.java249
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java942
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java393
-rw-r--r--asdc-controller/src/test/java/org/openecomp/mso/asdc/util/tests/ASDCNotificationLoggingTest.java274
9 files changed, 1796 insertions, 1799 deletions
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
index ff2486276b..abab8dd076 100644
--- 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
@@ -41,316 +41,314 @@ 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()));
- }
-
+
+ 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
index 5026b51bd1..bb869bb324 100644
--- 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
@@ -25,6 +25,7 @@ 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;
@@ -63,350 +64,347 @@ 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 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<>();
+ 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();
- private static String heatExample;
- private static String heatExampleMD5HashBase64;
+ asdcController.initASDC();
+ assertTrue(asdcController.getControllerStatus() == ASDCControllerStatus.IDLE);
+ assertFalse(asdcController.updateConfigIfNeeded());
- private static INotificationData iNotif;
+ // Simulate a BUSY case by reflection
+ Field controllerStatus;
+ controllerStatus = ASDCController.class.getDeclaredField("controllerStatus");
+ controllerStatus.setAccessible(true);
+ controllerStatus.set(asdcController, ASDCControllerStatus.BUSY);
- private static IDistributionClientDownloadResult downloadResult;
- private static IDistributionClientDownloadResult downloadCorruptedResult;
- private static IDistributionClientResult successfulClientInitResult;
- private static IDistributionClientResult unsuccessfulClientInitResult;
+ 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()));
+ }
- private static IArtifactInfo artifactInfo1;
+ // 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()));
+ }
- private static IResourceInstance resource1;
+ // Revert to Idle by reflection
+ controllerStatus.set(asdcController, ASDCControllerStatus.IDLE);
+ controllerStatus.setAccessible(false);
- 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);
+ // This should work now, controller should be restarted
+ assertTrue(asdcController.updateConfigIfNeeded());
+ assertTrue(asdcController.getControllerStatus() == ASDCControllerStatus.IDLE);
- @BeforeClass
- public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException, NoSuchAlgorithmException, ArtifactInstallerException {
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ msoPropertiesFactory.reloadMsoProperties();
+ }
- 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);
+ @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);
- // 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");
+ ASDCController asdcController = new ASDCController("asdc-controller1", distributionClient, vnfInstaller);
- // Now provision the NotificationData mock
- List<IArtifactInfo> listArtifact = new ArrayList<>();
- listArtifact.add(artifactInfo1);
+ // it should not raise any exception even if controller is not yet initialized
+ asdcController.updateConfigIfNeeded();
- // 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);
+ asdcController.initASDC();
+ assertTrue(asdcController.getControllerStatus() == ASDCControllerStatus.IDLE);
+ assertFalse(asdcController.updateConfigIfNeeded());
- List<IResourceInstance> resources = new ArrayList<> ();
- resources.add (resource1);
+ 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()));
+ }
- 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");
+ // This should stop the controller, as it can't work with a bad config file
+ assertTrue(asdcController.getControllerStatus() == ASDCControllerStatus.STOPPED);
- 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);
- }
+ msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);
+ msoPropertiesFactory.reloadMsoProperties();
+ }
- @AfterClass
- public static final void kill () throws MsoPropertiesException {
+ @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);
- msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC);
- }
+ ASDCController asdcController = new ASDCController("asdc-controller1", distributionClient, vnfInstaller);
- @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);
+ assertTrue("Unknown".equals(asdcController.getAddress()));
+ assertTrue("Unknown".equals(asdcController.getEnvironment()));
+ asdcController.initASDC();
- asdcController = new ASDCController("asdc-controller1",new DistributionClientStubImpl(),vnfInstaller);
- asdcController.initASDC();
- asdcController.closeASDC();
- assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.STOPPED);
- }
+ assertTrue("hostname".equals(asdcController.getAddress()));
+ assertTrue("environmentName".equals(asdcController.getEnvironment()));
- @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
index 6de04e2862..d322e7e0a8 100644
--- 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
@@ -22,7 +22,6 @@
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;
@@ -46,129 +45,129 @@ import org.openecomp.mso.asdc.installer.IVfModuleData;
public class ASDCElementInfoTest {
- @Test
- public void createASDCElementInfoWithNullParameterTest() {
- ASDCElementInfo elementInfoFromNullVfArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(null);
- ASDCElementInfo elementInfoFromNullVfModuleStructure = ASDCElementInfo.createElementFromVfModuleStructure(null);
- ASDCElementInfo elementInfoFromNullVfResourceStructure = ASDCElementInfo.createElementFromVfResourceStructure(null);
+ @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);
+ elementInfoFromNullVfArtifact.addElementInfo(null, null);
+ elementInfoFromNullVfModuleStructure.addElementInfo(null, "someValue");
+ elementInfoFromNullVfResourceStructure.addElementInfo("someKey", null);
- assertEquals(elementInfoFromNullVfArtifact.toString(), "");
- assertEquals(elementInfoFromNullVfModuleStructure.toString(), "");
- assertEquals(elementInfoFromNullVfResourceStructure.toString(), "");
+ assertEquals(elementInfoFromNullVfArtifact.toString(), "");
+ assertEquals(elementInfoFromNullVfModuleStructure.toString(), "");
+ assertEquals(elementInfoFromNullVfResourceStructure.toString(), "");
- assertNotNull(elementInfoFromNullVfArtifact);
- assertNotNull(elementInfoFromNullVfModuleStructure);
- assertNotNull(elementInfoFromNullVfResourceStructure);
+ assertNotNull(elementInfoFromNullVfArtifact);
+ assertNotNull(elementInfoFromNullVfModuleStructure);
+ assertNotNull(elementInfoFromNullVfResourceStructure);
- assertNotNull(ASDCElementInfo.EMPTY_INSTANCE);
+ assertNotNull(ASDCElementInfo.EMPTY_INSTANCE);
- assertEquals(elementInfoFromNullVfArtifact, ASDCElementInfo.EMPTY_INSTANCE);
- assertEquals(elementInfoFromNullVfModuleStructure, ASDCElementInfo.EMPTY_INSTANCE);
- assertEquals(elementInfoFromNullVfResourceStructure, 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(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());
- }
+ 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() {
+ @Test
+ public void createASDCElementInfoFromVfResourceTest() {
- String resourceInstanceName = "Resource 1";
+ String resourceInstanceName = "Resource 1";
- UUID generatedUUID = UUID.randomUUID();
+ UUID generatedUUID = UUID.randomUUID();
- INotificationData notificationData = Mockito.mock(INotificationData.class);
- IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
+ 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());
+ Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
+ Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
- VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
+ VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
- ASDCElementInfo elementInfoFromVfResource = ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure);
+ ASDCElementInfo elementInfoFromVfResource = ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure);
- assertTrue(elementInfoFromVfResource.toString().contains(resourceInstanceName));
- assertTrue(elementInfoFromVfResource.toString().contains(generatedUUID.toString()));
+ 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(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"));
- }
+ assertFalse(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));
+ elementInfoFromVfResource.addElementInfo("MyInfo1", "someValue");
+ assertTrue(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));
+ }
- @Test
- public void createASDCElementInfoFromVfModuleTest() throws ArtifactInstallerException {
+ @Test
+ public void createASDCElementInfoFromVfModuleTest() throws ArtifactInstallerException {
- String resourceInstanceName = "Resource 1";
+ String resourceInstanceName = "Resource 1";
- UUID generatedUUID = UUID.randomUUID();
+ UUID generatedUUID = UUID.randomUUID();
- INotificationData notificationData = Mockito.mock(INotificationData.class);
- IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
+ 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());
+ Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
+ Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
- VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
+ VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
- // Create module structure now
+ // Create module structure now
- String vfModuleModelName = "Module Model XYZ";
+ String vfModuleModelName = "Module Model XYZ";
- UUID generatedUUIDForModule = UUID.randomUUID();
+ UUID generatedUUIDForModule = UUID.randomUUID();
- IVfModuleData moduleMetadata = Mockito.mock(IVfModuleData.class);
- Mockito.when(moduleMetadata.getVfModuleModelName()).thenReturn(vfModuleModelName);
- Mockito.when(moduleMetadata.getVfModuleModelInvariantUUID()).thenReturn(generatedUUIDForModule.toString());
- Mockito.when(moduleMetadata.getArtifacts()).thenReturn(Collections.<String> emptyList());
+ IVfModuleData moduleMetadata = Mockito.mock(IVfModuleData.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);
+ VfModuleStructure vfModuleStructure = new VfModuleStructure(vfResourceStructure, moduleMetadata);
- ASDCElementInfo elementInfoFromVfModule = ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure);
+ ASDCElementInfo elementInfoFromVfModule = ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure);
- assertTrue(elementInfoFromVfModule.toString().contains(vfModuleModelName));
- assertTrue(elementInfoFromVfModule.toString().contains(generatedUUIDForModule.toString()));
+ 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(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"));
- }
+ 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();
+ @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());
+ 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);
+ ASDCElementInfo elementInfoFromArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(artifactInfo);
- assertTrue(elementInfoFromArtifact.toString().contains(generatedArtifactName));
- assertTrue(elementInfoFromArtifact.toString().contains(generatedUUIDForArtifact.toString()));
+ 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(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"));
- }
- }
+ 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
index 73c5456d29..93a23f8663 100644
--- 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
@@ -23,6 +23,7 @@ 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;
@@ -55,159 +56,156 @@ 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 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<>();
+ 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);
- private static String heatExample;
- private static String heatExampleMD5HashBase64;
+ // first init
+ assertTrue(asdcGlobalController.updateControllersConfigIfNeeded());
+ assertTrue(asdcGlobalController.getControllers().size() == 1);
+ assertTrue(asdcGlobalController.getControllers().get("asdc-controller1") != null);
- private static INotificationData iNotif;
+ asdcGlobalController.closeASDC();
+ assertTrue(asdcGlobalController.getControllers().size() == 0);
- 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<>();
- 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
index 3ecfdbbe40..0371b0cfcf 100644
--- 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
@@ -22,7 +22,9 @@ 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;
@@ -31,23 +33,23 @@ import org.openecomp.mso.asdc.installer.BigDecimalVersion;
public class BigDecimalVersionTest {
@Test
- public final void versionCastTest () {
+ 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")));
+ 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("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");
+ 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")));
+ 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
index 589968ece4..812b4459e5 100644
--- 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
@@ -29,6 +29,7 @@ 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;
@@ -38,128 +39,128 @@ 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("123456");
-
- 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 heatParam1 = new HeatTemplateParam();
- heatParam1.setHeatTemplateArtifactUuid("1");
- heatParam1.setParamName("testos1");
- heatParam1.setParamType("string");
-
- HeatTemplateParam heatParam2 = new HeatTemplateParam();
- heatParam2.setHeatTemplateArtifactUuid("2");
- heatParam2.setParamName("testos2");
- heatParam2.setParamType("number");
-
- newParamSet.add(heatParam1);
- newParamSet.add(heatParam2);
-
- decoder.addParameterList(newParamSet);
-
- Set <HeatTemplateParam> paramSet = decoder.getParameterList("123456");
- 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 heatParam1 = new HeatTemplateParam();
- heatParam1.setHeatTemplateArtifactUuid("1");
- heatParam1.setParamName("testos1");
- heatParam1.setParamType("string");
-
- HeatTemplateParam heatParam2 = new HeatTemplateParam();
- heatParam2.setHeatTemplateArtifactUuid("2");
- heatParam2.setParamName("testos2");
- heatParam2.setParamType("number");
-
- newParamSet.add(heatParam1);
- newParamSet.add(heatParam2);
-
- decoder.addParameterList(newParamSet);
-
- Set <HeatTemplateParam> paramSet = decoder.getParameterList("123456");
-
- 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")));
-
- }
+ @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("123456");
+
+ 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 heatParam1 = new HeatTemplateParam();
+ heatParam1.setHeatTemplateArtifactUuid("1");
+ heatParam1.setParamName("testos1");
+ heatParam1.setParamType("string");
+
+ HeatTemplateParam heatParam2 = new HeatTemplateParam();
+ heatParam2.setHeatTemplateArtifactUuid("2");
+ heatParam2.setParamName("testos2");
+ heatParam2.setParamType("number");
+
+ newParamSet.add(heatParam1);
+ newParamSet.add(heatParam2);
+
+ decoder.addParameterList(newParamSet);
+
+ Set<HeatTemplateParam> paramSet = decoder.getParameterList("123456");
+ 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 heatParam1 = new HeatTemplateParam();
+ heatParam1.setHeatTemplateArtifactUuid("1");
+ heatParam1.setParamName("testos1");
+ heatParam1.setParamType("string");
+
+ HeatTemplateParam heatParam2 = new HeatTemplateParam();
+ heatParam2.setHeatTemplateArtifactUuid("2");
+ heatParam2.setParamName("testos2");
+ heatParam2.setParamType("number");
+
+ newParamSet.add(heatParam1);
+ newParamSet.add(heatParam2);
+
+ decoder.addParameterList(newParamSet);
+
+ Set<HeatTemplateParam> paramSet = decoder.getParameterList("123456");
+
+ 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")));
+
+ }
}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java
index 9c20a084c3..48e12c26be 100644
--- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java
@@ -84,475 +84,475 @@ import mockit.MockUp;
public class ToscaResourceInstallerTest {
- 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 IDistributionClient distributionClient;
-
- private static IArtifactInfo artifactInfo1;
-
- private static IResourceInstance resource1;
-
- private static VfResourceStructure vrs;
-
- 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(ToscaResourceInstallerTest.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");
-
- distributionClient = Mockito.mock(IDistributionClient.class);
-
- // Now provision the NotificationData mock
- List<IArtifactInfo> listArtifact = new ArrayList<>();
- 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");
-
- vrs = new VfResourceStructure(iNotif, resource1);
- try {
- vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- try {
- vrs.createVfModuleStructures();
- } catch (ArtifactInstallerException e) {
- e.printStackTrace();
- }
- vrs.getNotification();
- vrs.getArtifactsMapByUUID();
- vrs.getCatalogNetworkResourceCustomization();
- vrs.getCatalogResourceCustomization();
- vrs.getCatalogService();
- vrs.getCatalogServiceToAllottedResources();
- vrs.getCatalogServiceToNetworks();
- vrs.getCatalogVnfResource();
- vrs.getResourceInstance();
- vrs.getVfModulesStructureList();
- vrs.getVfModuleStructure();
- vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
- vrs.setCatalogResourceCustomization(new AllottedResourceCustomization());
- vrs.setCatalogService(new Service());
- vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources());
- vrs.setCatalogServiceToNetworks(new ServiceToNetworks());
- vrs.setCatalogVnfResource(new VnfResource());
- vrs.setSuccessfulDeployment();
-
- AllottedResourceCustomization arc = new AllottedResourceCustomization();
- arc.setModelCustomizationUuid("modelCustomizationUuid");
- List<AllottedResourceCustomization> allottedResources = new ArrayList<>();
- allottedResources.add(arc);
-
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- nrc.setModelCustomizationUuid("modelCustomizationUuid");
- List<NetworkResourceCustomization> networkResources = new ArrayList<>();
- networkResources.add(nrc);
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelUuid(
- String serviceModelUuid) {
- return allottedResources;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) {
- return networkResources;
- }
- };
-
- // 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 void isResourceAlreadyDeployedAllotedResourceTest() {
- Mockito.when(resource1.getResourceType()).thenReturn("VF");
- Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource");
- ToscaResourceInstaller tri = new ToscaResourceInstaller();
-
- try {
- tri.isResourceAlreadyDeployed(vrs);
- } catch (ArtifactInstallerException e) {
- }
- }
-
- @Test(expected=Exception.class)
- public void installTheResourceTest() {
-
- ToscaResourceStructure trs = new ToscaResourceStructure();
- trs.getAllottedResource();
- trs.getAllottedList();
- trs.getCatalogAllottedResourceCustomization();
- trs.getCatalogAllottedServiceToResourceCustomization();
- trs.getCatalogNetworkResource();
- trs.getCatalogNetworkResourceCustomization();
- trs.getCatalogResourceCustomization();
- trs.getCatalogService();
- trs.getCatalogTempNetworkHeatTemplateLookup();
- trs.getCatalogToscaCsar();
- trs.getCatalogVfModule();
- trs.getCatalogVfModuleCustomization();
- trs.getCatalogVfModuleToHeatFiles();
- trs.getCatalogVfServiceToResourceCustomization();
- trs.getCatalogVlServiceToResourceCustomization();
- trs.getCatalogVnfResCustomToVfModuleCustom();
- trs.getCatalogVnfResource();
- trs.getCatalogVnfResourceCustomization();
- trs.getEnvHeatTemplateUUID();
- trs.getHeatFilesUUID();
- trs.getHeatTemplateUUID();
- trs.getNetworkTypes();
- trs.getSdcCsarHelper();
- trs.getServiceMetadata();
- trs.getServiceToResourceCustomization();
- trs.getServiceVersion();
- trs.getToscaArtifact();
- trs.getVfTypes();
- trs.getVolHeatEnvTemplateUUID();
- trs.getVolHeatTemplateUUID();
-
- NodeTemplate nodeTemplate = Mockito.mock(NodeTemplate.class);
- List<NodeTemplate> alnt = new ArrayList<>();
- trs.setAllottedList(alnt);
- trs.setAllottedResource(new AllottedResource());
- trs.setCatalogAllottedResourceCustomization(new AllottedResourceCustomization());
- trs.setCatalogAllottedServiceToResourceCustomization(new ServiceToResourceCustomization());
- trs.setCatalogNetworkResource(new NetworkResource());
- trs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
- trs.setCatalogResourceCustomization(new AllottedResourceCustomization());
- trs.setCatalogService(new Service());
- trs.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
- trs.setCatalogToscaCsar(new ToscaCsar());
- trs.setCatalogVfModule(new VfModule());
- trs.setCatalogVfModuleCustomization(new VfModuleCustomization());
- trs.setCatalogVfModuleToHeatFiles(new VfModuleToHeatFiles());
- trs.setCatalogVfServiceToResourceCustomization(new ServiceToResourceCustomization());
- trs.setCatalogVlServiceToResourceCustomization(new ServiceToResourceCustomization());
- trs.setCatalogVnfResCustomToVfModuleCustom(new VnfResCustomToVfModuleCustom());
- trs.setCatalogVnfResource(new VnfResource());
- trs.setCatalogVnfResourceCustomization(new VnfResourceCustomization());
- trs.setEnvHeatTemplateUUID("envHeatTemplateUUID");
- trs.setHeatFilesUUID("heatFilesUUID");
- trs.setHeatTemplateUUID("heatTemplateUUID");
- trs.setNetworkTypes(alnt);
- trs.setVolHeatTemplateUUID("volHeatTemplateUUID");
- trs.setSdcCsarHelper(new ISdcCsarHelper() {
-
- @Override
- public boolean hasTopology(NodeTemplate arg0) {
- return false;
- }
-
- @Override
- public NodeTemplate getVnfConfig(String arg0) {
- return null;
- }
-
- @Override
- public List<NodeTemplate> getVfcListByVf(String arg0) {
- return null;
- }
-
- @Override
- public List<Group> getVfModulesByVf(String arg0) {
- return null;
- }
-
- @Override
- public String getTypeOfNodeTemplate(NodeTemplate arg0) {
- return null;
- }
-
- @Override
- public List<NodeTemplate> getServiceVlList() {
- return null;
- }
-
- @Override
- public List<NodeTemplate> getServiceVfList() {
- return null;
- }
-
- @Override
- public String getServiceSubstitutionMappingsTypeName() {
- return null;
- }
-
- @Override
- public List<NodeTemplate> getServiceNodeTemplatesByType(String arg0) {
- return null;
- }
-
- @Override
- public List<NodeTemplate> getServiceNodeTemplates() {
- return null;
- }
-
- @Override
- public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes arg0) {
- return null;
- }
-
- @Override
- public Map<String, Object> getServiceMetadataProperties() {
- return null;
- }
-
- @Override
- public Metadata getServiceMetadata() {
- return null;
- }
-
- @Override
- public List<Input> getServiceInputs() {
- return null;
- }
-
- @Override
- public Object getServiceInputLeafValueOfDefaultAsObject(String arg0) {
- return null;
- }
-
- @Override
- public String getServiceInputLeafValueOfDefault(String arg0) {
- return null;
- }
-
- @Override
- public String getNodeTemplatePropertyLeafValue(NodeTemplate arg0, String arg1) {
- return null;
- }
-
- @Override
- public Object getNodeTemplatePropertyAsObject(NodeTemplate arg0, String arg1) {
- return null;
- }
-
- @Override
- public List<Pair<NodeTemplate, NodeTemplate>> getNodeTemplatePairsByReqName(List<NodeTemplate> arg0,
- List<NodeTemplate> arg1, String arg2) {
- return null;
- }
-
- @Override
- public String getNodeTemplateCustomizationUuid(NodeTemplate arg0) {
- return null;
- }
-
- @Override
- public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate arg0) {
- return null;
- }
-
- @Override
- public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate arg0, SdcTypes arg1) {
- return null;
- }
-
- @Override
- public String getMetadataPropertyValue(Metadata arg0, String arg1) {
- return null;
- }
-
- @Override
- public List<NodeTemplate> getMembersOfVfModule(NodeTemplate arg0, Group arg1) {
- return null;
- }
-
- @Override
- public String getGroupPropertyLeafValue(Group arg0, String arg1) {
- return null;
- }
-
- @Override
- public Object getGroupPropertyAsObject(Group arg0, String arg1) {
- return null;
- }
-
- @Override
- public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate arg0) {
- return null;
- }
-
- @Override
- public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate arg0) {
- return null;
- }
-
- @Override
- public List<NodeTemplate> getCpListByVf(String arg0) {
- return null;
- }
-
- @Override
- public String getConformanceLevel() {
- return null;
- }
-
- @Override
- public List<NodeTemplate> getAllottedResources() {
- return null;
- }
-
- @Override
- public Map<String, String> filterNodeTemplatePropertiesByValue(NodeTemplate arg0, FilterType arg1,
- String arg2) {
- return null;
- }
- });
- // trs.setServiceMetadata(new Metadata(new HashMap<>()));
- trs.setServiceToResourceCustomization(new ServiceToResourceCustomization());
- trs.setServiceVersion("1.0");
- trs.setToscaArtifact(new IArtifactInfo() {
-
- @Override
- public List<IArtifactInfo> getRelatedArtifacts() {
- return null;
- }
-
- @Override
- public IArtifactInfo getGeneratedArtifact() {
- return null;
- }
-
- @Override
- public String getArtifactVersion() {
- return null;
- }
-
- @Override
- public String getArtifactUUID() {
- return null;
- }
-
- @Override
- public String getArtifactURL() {
- return null;
- }
-
- @Override
- public String getArtifactType() {
- return null;
- }
-
- @Override
- public Integer getArtifactTimeout() {
- return null;
- }
-
- @Override
- public String getArtifactName() {
- return null;
- }
-
- @Override
- public String getArtifactDescription() {
- return null;
- }
-
- @Override
- public String getArtifactChecksum() {
- return null;
- }
- });
- trs.setVfTypes(alnt);
- trs.setVnfAlreadyInstalled(true);
- trs.setVolHeatEnvTemplateUUID("volHeatEnvTemplateUUID");
- trs.isVnfAlreadyInstalled();
-
- trs.updateResourceStructure(artifactInfo1);
- ToscaResourceInstaller tri = new ToscaResourceInstaller();
-
- try {
- tri.installTheResource(trs, vrs);
- } catch (ArtifactInstallerException e) {
- }
- }
+ 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 IDistributionClient distributionClient;
+
+ private static IArtifactInfo artifactInfo1;
+
+ private static IResourceInstance resource1;
+
+ private static VfResourceStructure vrs;
+
+ 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(ToscaResourceInstallerTest.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");
+
+ distributionClient = Mockito.mock(IDistributionClient.class);
+
+ // Now provision the NotificationData mock
+ List<IArtifactInfo> listArtifact = new ArrayList<>();
+ 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");
+
+ vrs = new VfResourceStructure(iNotif, resource1);
+ try {
+ vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ try {
+ vrs.createVfModuleStructures();
+ } catch (ArtifactInstallerException e) {
+ e.printStackTrace();
+ }
+ vrs.getNotification();
+ vrs.getArtifactsMapByUUID();
+ vrs.getCatalogNetworkResourceCustomization();
+ vrs.getCatalogResourceCustomization();
+ vrs.getCatalogService();
+ vrs.getCatalogServiceToAllottedResources();
+ vrs.getCatalogServiceToNetworks();
+ vrs.getCatalogVnfResource();
+ vrs.getResourceInstance();
+ vrs.getVfModulesStructureList();
+ vrs.getVfModuleStructure();
+ vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
+ vrs.setCatalogResourceCustomization(new AllottedResourceCustomization());
+ vrs.setCatalogService(new Service());
+ vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources());
+ vrs.setCatalogServiceToNetworks(new ServiceToNetworks());
+ vrs.setCatalogVnfResource(new VnfResource());
+ vrs.setSuccessfulDeployment();
+
+ AllottedResourceCustomization arc = new AllottedResourceCustomization();
+ arc.setModelCustomizationUuid("modelCustomizationUuid");
+ List<AllottedResourceCustomization> allottedResources = new ArrayList<>();
+ allottedResources.add(arc);
+
+ NetworkResourceCustomization nrc = new NetworkResourceCustomization();
+ nrc.setModelCustomizationUuid("modelCustomizationUuid");
+ List<NetworkResourceCustomization> networkResources = new ArrayList<>();
+ networkResources.add(nrc);
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelUuid(
+ String serviceModelUuid) {
+ return allottedResources;
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) {
+ return networkResources;
+ }
+ };
+
+ // 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 void isResourceAlreadyDeployedAllotedResourceTest() {
+ Mockito.when(resource1.getResourceType()).thenReturn("VF");
+ Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource");
+ ToscaResourceInstaller tri = new ToscaResourceInstaller();
+
+ try {
+ tri.isResourceAlreadyDeployed(vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+ }
+
+ @Test(expected = Exception.class)
+ public void installTheResourceTest() {
+
+ ToscaResourceStructure trs = new ToscaResourceStructure();
+ trs.getAllottedResource();
+ trs.getAllottedList();
+ trs.getCatalogAllottedResourceCustomization();
+ trs.getCatalogAllottedServiceToResourceCustomization();
+ trs.getCatalogNetworkResource();
+ trs.getCatalogNetworkResourceCustomization();
+ trs.getCatalogResourceCustomization();
+ trs.getCatalogService();
+ trs.getCatalogTempNetworkHeatTemplateLookup();
+ trs.getCatalogToscaCsar();
+ trs.getCatalogVfModule();
+ trs.getCatalogVfModuleCustomization();
+ trs.getCatalogVfModuleToHeatFiles();
+ trs.getCatalogVfServiceToResourceCustomization();
+ trs.getCatalogVlServiceToResourceCustomization();
+ trs.getCatalogVnfResCustomToVfModuleCustom();
+ trs.getCatalogVnfResource();
+ trs.getCatalogVnfResourceCustomization();
+ trs.getEnvHeatTemplateUUID();
+ trs.getHeatFilesUUID();
+ trs.getHeatTemplateUUID();
+ trs.getNetworkTypes();
+ trs.getSdcCsarHelper();
+ trs.getServiceMetadata();
+ trs.getServiceToResourceCustomization();
+ trs.getServiceVersion();
+ trs.getToscaArtifact();
+ trs.getVfTypes();
+ trs.getVolHeatEnvTemplateUUID();
+ trs.getVolHeatTemplateUUID();
+
+ NodeTemplate nodeTemplate = Mockito.mock(NodeTemplate.class);
+ List<NodeTemplate> alnt = new ArrayList<>();
+ trs.setAllottedList(alnt);
+ trs.setAllottedResource(new AllottedResource());
+ trs.setCatalogAllottedResourceCustomization(new AllottedResourceCustomization());
+ trs.setCatalogAllottedServiceToResourceCustomization(new ServiceToResourceCustomization());
+ trs.setCatalogNetworkResource(new NetworkResource());
+ trs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
+ trs.setCatalogResourceCustomization(new AllottedResourceCustomization());
+ trs.setCatalogService(new Service());
+ trs.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
+ trs.setCatalogToscaCsar(new ToscaCsar());
+ trs.setCatalogVfModule(new VfModule());
+ trs.setCatalogVfModuleCustomization(new VfModuleCustomization());
+ trs.setCatalogVfModuleToHeatFiles(new VfModuleToHeatFiles());
+ trs.setCatalogVfServiceToResourceCustomization(new ServiceToResourceCustomization());
+ trs.setCatalogVlServiceToResourceCustomization(new ServiceToResourceCustomization());
+ trs.setCatalogVnfResCustomToVfModuleCustom(new VnfResCustomToVfModuleCustom());
+ trs.setCatalogVnfResource(new VnfResource());
+ trs.setCatalogVnfResourceCustomization(new VnfResourceCustomization());
+ trs.setEnvHeatTemplateUUID("envHeatTemplateUUID");
+ trs.setHeatFilesUUID("heatFilesUUID");
+ trs.setHeatTemplateUUID("heatTemplateUUID");
+ trs.setNetworkTypes(alnt);
+ trs.setVolHeatTemplateUUID("volHeatTemplateUUID");
+ trs.setSdcCsarHelper(new ISdcCsarHelper() {
+
+ @Override
+ public boolean hasTopology(NodeTemplate arg0) {
+ return false;
+ }
+
+ @Override
+ public NodeTemplate getVnfConfig(String arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getVfcListByVf(String arg0) {
+ return null;
+ }
+
+ @Override
+ public List<Group> getVfModulesByVf(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String getTypeOfNodeTemplate(NodeTemplate arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getServiceVlList() {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getServiceVfList() {
+ return null;
+ }
+
+ @Override
+ public String getServiceSubstitutionMappingsTypeName() {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getServiceNodeTemplatesByType(String arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getServiceNodeTemplates() {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes arg0) {
+ return null;
+ }
+
+ @Override
+ public Map<String, Object> getServiceMetadataProperties() {
+ return null;
+ }
+
+ @Override
+ public Metadata getServiceMetadata() {
+ return null;
+ }
+
+ @Override
+ public List<Input> getServiceInputs() {
+ return null;
+ }
+
+ @Override
+ public Object getServiceInputLeafValueOfDefaultAsObject(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String getServiceInputLeafValueOfDefault(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String getNodeTemplatePropertyLeafValue(NodeTemplate arg0, String arg1) {
+ return null;
+ }
+
+ @Override
+ public Object getNodeTemplatePropertyAsObject(NodeTemplate arg0, String arg1) {
+ return null;
+ }
+
+ @Override
+ public List<Pair<NodeTemplate, NodeTemplate>> getNodeTemplatePairsByReqName(List<NodeTemplate> arg0,
+ List<NodeTemplate> arg1, String arg2) {
+ return null;
+ }
+
+ @Override
+ public String getNodeTemplateCustomizationUuid(NodeTemplate arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate arg0, SdcTypes arg1) {
+ return null;
+ }
+
+ @Override
+ public String getMetadataPropertyValue(Metadata arg0, String arg1) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getMembersOfVfModule(NodeTemplate arg0, Group arg1) {
+ return null;
+ }
+
+ @Override
+ public String getGroupPropertyLeafValue(Group arg0, String arg1) {
+ return null;
+ }
+
+ @Override
+ public Object getGroupPropertyAsObject(Group arg0, String arg1) {
+ return null;
+ }
+
+ @Override
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate arg0) {
+ return null;
+ }
+
+ @Override
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate arg0) {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getCpListByVf(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String getConformanceLevel() {
+ return null;
+ }
+
+ @Override
+ public List<NodeTemplate> getAllottedResources() {
+ return null;
+ }
+
+ @Override
+ public Map<String, String> filterNodeTemplatePropertiesByValue(NodeTemplate arg0, FilterType arg1,
+ String arg2) {
+ return null;
+ }
+ });
+ // trs.setServiceMetadata(new Metadata(new HashMap<>()));
+ trs.setServiceToResourceCustomization(new ServiceToResourceCustomization());
+ trs.setServiceVersion("1.0");
+ trs.setToscaArtifact(new IArtifactInfo() {
+
+ @Override
+ public List<IArtifactInfo> getRelatedArtifacts() {
+ return null;
+ }
+
+ @Override
+ public IArtifactInfo getGeneratedArtifact() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactVersion() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactUUID() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactURL() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactType() {
+ return null;
+ }
+
+ @Override
+ public Integer getArtifactTimeout() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactName() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactDescription() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactChecksum() {
+ return null;
+ }
+ });
+ trs.setVfTypes(alnt);
+ trs.setVnfAlreadyInstalled(true);
+ trs.setVolHeatEnvTemplateUUID("volHeatEnvTemplateUUID");
+ trs.isVnfAlreadyInstalled();
+
+ trs.updateResourceStructure(artifactInfo1);
+ ToscaResourceInstaller tri = new ToscaResourceInstaller();
+
+ try {
+ tri.installTheResource(trs, vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+ }
}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java
index e2239dc952..04a9ea0a1e 100644
--- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java
@@ -63,218 +63,219 @@ import mockit.Mock;
import mockit.MockUp;
public class VfResourceInstallerTest {
- private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
+ private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- private static String heatExample;
- private static String heatExampleMD5HashBase64;
+ private static String heatExample;
+ private static String heatExampleMD5HashBase64;
- private static INotificationData iNotif;
+ private static INotificationData iNotif;
- private static IDistributionClientDownloadResult downloadResult;
- private static IDistributionClientDownloadResult downloadCorruptedResult;
+ private static IDistributionClientDownloadResult downloadResult;
+ private static IDistributionClientDownloadResult downloadCorruptedResult;
- private static IDistributionClientResult successfulClientInitResult;
- private static IDistributionClientResult unsuccessfulClientInitResult;
+ private static IDistributionClientResult successfulClientInitResult;
+ private static IDistributionClientResult unsuccessfulClientInitResult;
- private static IDistributionClient distributionClient;
+ private static IDistributionClient distributionClient;
- private static IArtifactInfo artifactInfo1;
+ private static IArtifactInfo artifactInfo1;
- private static IResourceInstance resource1;
+ private static IResourceInstance resource1;
- private static VfResourceStructure vrs;
+ private static VfResourceStructure vrs;
- 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 = 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 {
+ @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);
+ 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);
+ iNotif = Mockito.mock(INotificationData.class);
- // Create fake ArtifactInfo
- artifactInfo1 = Mockito.mock(IArtifactInfo.class);
- Mockito.when(artifactInfo1.getArtifactChecksum()).thenReturn(VfResourceInstallerTest.heatExampleMD5HashBase64);
+ // Create fake ArtifactInfo
+ artifactInfo1 = Mockito.mock(IArtifactInfo.class);
+ Mockito.when(artifactInfo1.getArtifactChecksum()).thenReturn(VfResourceInstallerTest.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");
+ 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");
- distributionClient = Mockito.mock(IDistributionClient.class);
+ distributionClient = Mockito.mock(IDistributionClient.class);
- // Now provision the NotificationData mock
- List<IArtifactInfo> listArtifact = new ArrayList<>();
- listArtifact.add(artifactInfo1);
+ // Now provision the NotificationData mock
+ List<IArtifactInfo> listArtifact = new ArrayList<>();
+ listArtifact.add(artifactInfo1);
- // Create fake resource Instance
- resource1 = Mockito.mock(IResourceInstance.class);
+ // 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");
-
- vrs = new VfResourceStructure(iNotif, resource1);
- try {
- vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- try {
- vrs.createVfModuleStructures();
- } catch (ArtifactInstallerException e) {
- e.printStackTrace();
- }
- vrs.getNotification();
- vrs.getArtifactsMapByUUID();
- vrs.getCatalogNetworkResourceCustomization();
- vrs.getCatalogResourceCustomization();
- vrs.getCatalogService();
- vrs.getCatalogServiceToAllottedResources();
- vrs.getCatalogServiceToNetworks();
- vrs.getCatalogVnfResource();
- vrs.getResourceInstance();
- vrs.getVfModulesStructureList();
- vrs.getVfModuleStructure();
- vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
- vrs.setCatalogResourceCustomization(new AllottedResourceCustomization());
- vrs.setCatalogService(new Service());
- vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources());
- vrs.setCatalogServiceToNetworks(new ServiceToNetworks());
- vrs.setCatalogVnfResource(new VnfResource());
- vrs.setSuccessfulDeployment();
-
- AllottedResourceCustomization arc= new AllottedResourceCustomization();
- arc.setModelCustomizationUuid("modelCustomizationUuid");
- List<AllottedResourceCustomization> allottedResources = new ArrayList<>();
- allottedResources.add(arc);
-
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- nrc.setModelCustomizationUuid("modelCustomizationUuid");
- List<NetworkResourceCustomization> networkResources = new ArrayList<>();
- networkResources.add(nrc);
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelUuid(String serviceModelUuid) {
- return allottedResources;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) {
- return networkResources;
- }
- };
-
- // 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 void isResourceAlreadyDeployedAllotedResourceTest() {
-
- Mockito.when(resource1.getResourceType()).thenReturn("VF");
- Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource");
- VfResourceInstaller vfri = new VfResourceInstaller();
-
- try {
- vfri.isResourceAlreadyDeployed(vrs);
- } catch (ArtifactInstallerException e) {
- }
-
- }
-
- @Test
- public void isResourceAlreadyDeployedTest() {
-
- Mockito.when(resource1.getResourceType()).thenReturn("VF");
- Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource");
- VfResourceInstaller vfri = new VfResourceInstaller();
-
- try {
- vfri.isResourceAlreadyDeployed(vrs);
- } catch (ArtifactInstallerException e) {
- }
-
- }
- @Test
- public void isResourceAlreadyDeployedDuplicateNtwrkTest() {
-
- Mockito.when(resource1.getResourceType()).thenReturn("VL");
- Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource");
- VfResourceInstaller vfri = new VfResourceInstaller();
-
- try {
- vfri.isResourceAlreadyDeployed(vrs);
- } catch (ArtifactInstallerException e) {
- }
-
- }
-
- @Test(expected=Exception.class)
- public void installTheResourceTest() {
- VfResourceInstaller vfri = new VfResourceInstaller();
- try {
- vfri.installTheResource(vrs);
- } catch (ArtifactInstallerException e) {
- }
- }
+ 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");
+
+ vrs = new VfResourceStructure(iNotif, resource1);
+ try {
+ vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ try {
+ vrs.createVfModuleStructures();
+ } catch (ArtifactInstallerException e) {
+ e.printStackTrace();
+ }
+ vrs.getNotification();
+ vrs.getArtifactsMapByUUID();
+ vrs.getCatalogNetworkResourceCustomization();
+ vrs.getCatalogResourceCustomization();
+ vrs.getCatalogService();
+ vrs.getCatalogServiceToAllottedResources();
+ vrs.getCatalogServiceToNetworks();
+ vrs.getCatalogVnfResource();
+ vrs.getResourceInstance();
+ vrs.getVfModulesStructureList();
+ vrs.getVfModuleStructure();
+ vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
+ vrs.setCatalogResourceCustomization(new AllottedResourceCustomization());
+ vrs.setCatalogService(new Service());
+ vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources());
+ vrs.setCatalogServiceToNetworks(new ServiceToNetworks());
+ vrs.setCatalogVnfResource(new VnfResource());
+ vrs.setSuccessfulDeployment();
+
+ AllottedResourceCustomization arc = new AllottedResourceCustomization();
+ arc.setModelCustomizationUuid("modelCustomizationUuid");
+ List<AllottedResourceCustomization> allottedResources = new ArrayList<>();
+ allottedResources.add(arc);
+
+ NetworkResourceCustomization nrc = new NetworkResourceCustomization();
+ nrc.setModelCustomizationUuid("modelCustomizationUuid");
+ List<NetworkResourceCustomization> networkResources = new ArrayList<>();
+ networkResources.add(nrc);
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelUuid(String serviceModelUuid) {
+ return allottedResources;
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) {
+ return networkResources;
+ }
+ };
+
+ // 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 void isResourceAlreadyDeployedAllotedResourceTest() {
+
+ Mockito.when(resource1.getResourceType()).thenReturn("VF");
+ Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource");
+ VfResourceInstaller vfri = new VfResourceInstaller();
+
+ try {
+ vfri.isResourceAlreadyDeployed(vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+
+ }
+
+ @Test
+ public void isResourceAlreadyDeployedTest() {
+
+ Mockito.when(resource1.getResourceType()).thenReturn("VF");
+ Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource");
+ VfResourceInstaller vfri = new VfResourceInstaller();
+
+ try {
+ vfri.isResourceAlreadyDeployed(vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+
+ }
+
+ @Test
+ public void isResourceAlreadyDeployedDuplicateNtwrkTest() {
+
+ Mockito.when(resource1.getResourceType()).thenReturn("VL");
+ Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource");
+ VfResourceInstaller vfri = new VfResourceInstaller();
+
+ try {
+ vfri.isResourceAlreadyDeployed(vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+
+ }
+
+ @Test(expected = Exception.class)
+ public void installTheResourceTest() {
+ VfResourceInstaller vfri = new VfResourceInstaller();
+ try {
+ vfri.installTheResource(vrs);
+ } catch (ArtifactInstallerException e) {
+ }
+ }
}
diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/tests/ASDCNotificationLoggingTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/tests/ASDCNotificationLoggingTest.java
index 1d65501ce2..8278769ac9 100644
--- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/tests/ASDCNotificationLoggingTest.java
+++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/tests/ASDCNotificationLoggingTest.java
@@ -34,141 +34,141 @@ import org.openecomp.sdc.api.notification.INotificationData;
import org.openecomp.sdc.api.notification.IResourceInstance;
public class ASDCNotificationLoggingTest {
- @Test
- public void dumpASDCNotificationTestForNull() throws Exception {
- INotificationData asdcNotification = iNotificationDataObject();
-
- String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
-
- assertTrue(!result.equalsIgnoreCase("NULL"));
- }
-
- private INotificationData iNotificationDataObject() {
- INotificationData iNotification = new INotificationData() {
-
- @Override
- public String getServiceVersion() {
- return "DistributionID";
- }
-
- @Override
- public String getServiceUUID() {
- return "12343254";
- }
-
- @Override
- public String getServiceName() {
- return "servername";
- }
-
- @Override
- public String getServiceInvariantUUID() {
- return "ServiceInvariantUUID";
- }
-
- @Override
- public String getServiceDescription() {
- return "Description";
- }
-
- @Override
- public List<IArtifactInfo> getServiceArtifacts() {
- return new ArrayList();
- }
-
- @Override
- public List<IResourceInstance> getResources() {
- return new ArrayList();
- }
-
- @Override
- public String getDistributionID() {
- return "23434";
- }
-
- @Override
- public IArtifactInfo getArtifactMetadataByUUID(String arg0) {
- return null;
- }
- };
- return iNotification;
- }
-
- @Test
- public void dumpASDCNotificationTest() throws Exception {
- INotificationData asdcNotification = iNotificationDataObject();
- String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
-
- assertTrue(!result.equalsIgnoreCase("NULL"));
- }
-
- @Test
- public void dumpVfModuleMetaDataListTest() {
- INotificationData asdcNotification = iNotificationDataObject();
- List<IVfModuleData> list = new ArrayList<>();
- list.add(new VfModuleMetaData());
- String result = null;
- try {
- result = ASDCNotificationLogging.dumpVfModuleMetaDataList(list);
- } catch (Exception e) {
- }
-
- assertTrue(result == null);
-
- }
-
- public IArtifactInfo getIArtifactInfo() {
- return new IArtifactInfo() {
-
- @Override
- public List<IArtifactInfo> getRelatedArtifacts() {
- return null;
- }
-
- @Override
- public IArtifactInfo getGeneratedArtifact() {
- return null;
- }
-
- @Override
- public String getArtifactVersion() {
- return "version";
- }
-
- @Override
- public String getArtifactUUID() {
- return "123";
- }
-
- @Override
- public String getArtifactURL() {
- return "url";
- }
-
- @Override
- public String getArtifactType() {
- return "type";
- }
-
- @Override
- public Integer getArtifactTimeout() {
- return 12;
- }
-
- @Override
- public String getArtifactName() {
- return "name";
- }
-
- @Override
- public String getArtifactDescription() {
- return "desc";
- }
-
- @Override
- public String getArtifactChecksum() {
- return "true";
- }
- };
- }
+ @Test
+ public void dumpASDCNotificationTestForNull() throws Exception {
+ INotificationData asdcNotification = iNotificationDataObject();
+
+ String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
+
+ assertTrue(!result.equalsIgnoreCase("NULL"));
+ }
+
+ private INotificationData iNotificationDataObject() {
+ INotificationData iNotification = new INotificationData() {
+
+ @Override
+ public String getServiceVersion() {
+ return "DistributionID";
+ }
+
+ @Override
+ public String getServiceUUID() {
+ return "12343254";
+ }
+
+ @Override
+ public String getServiceName() {
+ return "servername";
+ }
+
+ @Override
+ public String getServiceInvariantUUID() {
+ return "ServiceInvariantUUID";
+ }
+
+ @Override
+ public String getServiceDescription() {
+ return "Description";
+ }
+
+ @Override
+ public List<IArtifactInfo> getServiceArtifacts() {
+ return new ArrayList();
+ }
+
+ @Override
+ public List<IResourceInstance> getResources() {
+ return new ArrayList();
+ }
+
+ @Override
+ public String getDistributionID() {
+ return "23434";
+ }
+
+ @Override
+ public IArtifactInfo getArtifactMetadataByUUID(String arg0) {
+ return null;
+ }
+ };
+ return iNotification;
+ }
+
+ @Test
+ public void dumpASDCNotificationTest() throws Exception {
+ INotificationData asdcNotification = iNotificationDataObject();
+ String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
+
+ assertTrue(!result.equalsIgnoreCase("NULL"));
+ }
+
+ @Test
+ public void dumpVfModuleMetaDataListTest() {
+ INotificationData asdcNotification = iNotificationDataObject();
+ List<IVfModuleData> list = new ArrayList<>();
+ list.add(new VfModuleMetaData());
+ String result = null;
+ try {
+ result = ASDCNotificationLogging.dumpVfModuleMetaDataList(list);
+ } catch (Exception e) {
+ }
+
+ assertTrue(result == null);
+
+ }
+
+ public IArtifactInfo getIArtifactInfo() {
+ return new IArtifactInfo() {
+
+ @Override
+ public List<IArtifactInfo> getRelatedArtifacts() {
+ return null;
+ }
+
+ @Override
+ public IArtifactInfo getGeneratedArtifact() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactVersion() {
+ return "version";
+ }
+
+ @Override
+ public String getArtifactUUID() {
+ return "123";
+ }
+
+ @Override
+ public String getArtifactURL() {
+ return "url";
+ }
+
+ @Override
+ public String getArtifactType() {
+ return "type";
+ }
+
+ @Override
+ public Integer getArtifactTimeout() {
+ return 12;
+ }
+
+ @Override
+ public String getArtifactName() {
+ return "name";
+ }
+
+ @Override
+ public String getArtifactDescription() {
+ return "desc";
+ }
+
+ @Override
+ public String getArtifactChecksum() {
+ return "true";
+ }
+ };
+ }
}