aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller/src/test')
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/ASDCPojoTest.java36
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java6
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java36
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedCatalogDbConfig.java68
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedRequestDbConfig.java62
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java20
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCConfigurationTest.java34
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java113
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerTest.java34
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCElementInfoTest.java179
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCStatusCallBackTest.java96
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/BigDecimalVersionTest.java27
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/DistributionStatusMessageTest.java33
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/YamlTest.java234
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCControllerExceptionTest.java43
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCDownloadExceptionTest.java43
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCParametersExceptionTest.java43
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerExceptionTest.java44
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImplTest.java32
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulatorTest.java286
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonStatusDataTest.java8
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java46
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/NotificationDataImplTest.java53
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImplTest.java34
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java195
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/HealthCheckTest.java37
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/tests/ASDCConfigurationTest.java95
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java165
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java28
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java2
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java623
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImplTest.java55
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/WatchdogDistributionTest.java193
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/util/ASDCNotificationLoggingTest.java300
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/util/NotificationLoggingTest.java71
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingRunner.java32
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java140
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/utils/TreePrinterListener.java112
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/utils/TreeUtils.java26
39 files changed, 1813 insertions, 1871 deletions
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/ASDCPojoTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/ASDCPojoTest.java
index 354b6dac3c..dc51d46888 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/ASDCPojoTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/ASDCPojoTest.java
@@ -29,7 +29,6 @@ import org.onap.so.asdc.client.test.emulators.JsonVfModuleMetaData;
import org.onap.so.asdc.client.test.emulators.NotificationDataImpl;
import org.onap.so.asdc.client.test.emulators.ResourceInfoImpl;
import org.onap.so.asdc.installer.VfResourceStructure;
-
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.impl.PojoClassFactory;
import com.openpojo.validation.Validator;
@@ -38,23 +37,20 @@ import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
public class ASDCPojoTest {
- @Test
- public void pojoStructure() {
- test(PojoClassFactory.getPojoClass(FinalDistributionStatusMessage.class));
- test(PojoClassFactory.getPojoClass(ArtifactInfoImpl.class));
- test(PojoClassFactory.getPojoClass(NotificationDataImpl.class));
- test(PojoClassFactory.getPojoClass(JsonVfModuleMetaData.class));
- test(PojoClassFactory.getPojoClass(ResourceInfoImpl.class));
- test(PojoClassFactory.getPojoClass(DistributionClientEmulator.class));
- test(PojoClassFactory.getPojoClass(JsonStatusData.class));
- test(PojoClassFactory.getPojoClass(VfResourceStructure.class));
- }
-
- private void test(PojoClass pojoClass) {
- Validator validator = ValidatorBuilder.create()
- .with(new SetterTester())
- .with(new GetterTester())
- .build();
- validator.validate(pojoClass);
- }
+ @Test
+ public void pojoStructure() {
+ test(PojoClassFactory.getPojoClass(FinalDistributionStatusMessage.class));
+ test(PojoClassFactory.getPojoClass(ArtifactInfoImpl.class));
+ test(PojoClassFactory.getPojoClass(NotificationDataImpl.class));
+ test(PojoClassFactory.getPojoClass(JsonVfModuleMetaData.class));
+ test(PojoClassFactory.getPojoClass(ResourceInfoImpl.class));
+ test(PojoClassFactory.getPojoClass(DistributionClientEmulator.class));
+ test(PojoClassFactory.getPojoClass(JsonStatusData.class));
+ test(PojoClassFactory.getPojoClass(VfResourceStructure.class));
+ }
+
+ private void test(PojoClass pojoClass) {
+ Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester()).build();
+ validator.validate(pojoClass);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java b/asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java
index a100f26d5a..fb8e5bbc2f 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java
@@ -19,14 +19,14 @@
*/
package org.onap.so.asdc;
-import org.junit.runner.RunWith;
+import org.junit.runner.RunWith;
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
@RunWith(WildcardPatternSuite.class)
@SuiteClasses("**/*Test.class")
public class AllTestsTestSuite {
- // the class remains empty,
- // used only as a holder for the above annotations
+ // the class remains empty,
+ // used only as a holder for the above annotations
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
index 83d60aefea..0fcf9b0559 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
@@ -21,7 +21,6 @@
package org.onap.so.asdc;
import static org.mockito.Mockito.reset;
-
import org.junit.After;
import org.junit.runner.RunWith;
import org.onap.so.asdc.installer.ToscaResourceStructure;
@@ -39,7 +38,6 @@ import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
-
import com.github.tomakehurst.wiremock.WireMockServer;
@RunWith(SpringRunner.class)
@@ -48,23 +46,23 @@ import com.github.tomakehurst.wiremock.WireMockServer;
@ContextConfiguration(classes = SpringContextHelper.class, initializers = ConfigFileApplicationContextInitializer.class)
@AutoConfigureWireMock(port = 0)
public abstract class BaseTest {
- @MockBean
- protected VfResourceStructure vfResourceStructure;
- @MockBean
- protected ToscaResourceStructure toscaResourceStruct;
- @SpyBean
- protected WatchdogDistribution watchdogDistributionSpy;
- @SpyBean
- protected ToscaResourceInstaller toscaInstaller;
- @Autowired
- protected WireMockServer wireMockServer;
-
- @Value("${wiremock.server.port}")
+ @MockBean
+ protected VfResourceStructure vfResourceStructure;
+ @MockBean
+ protected ToscaResourceStructure toscaResourceStruct;
+ @SpyBean
+ protected WatchdogDistribution watchdogDistributionSpy;
+ @SpyBean
+ protected ToscaResourceInstaller toscaInstaller;
+ @Autowired
+ protected WireMockServer wireMockServer;
+
+ @Value("${wiremock.server.port}")
protected String wireMockPort;
- @After
- public void after() {
- reset(vfResourceStructure);
- reset(toscaResourceStruct);
- }
+ @After
+ public void after() {
+ reset(vfResourceStructure);
+ reset(toscaResourceStruct);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedCatalogDbConfig.java b/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedCatalogDbConfig.java
index 27b6c0ab53..e81a318e68 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedCatalogDbConfig.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedCatalogDbConfig.java
@@ -19,10 +19,10 @@
*/
package org.onap.so.asdc;
+
import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
-
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
@@ -36,17 +36,14 @@ import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
-
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
@Profile({"test"})
@EnableTransactionManagement
-@EnableJpaRepositories(
- entityManagerFactoryRef = "entityManagerFactory",
- basePackages = {"org.onap.so.db.catalog.data.repository"}
- )
+@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory",
+ basePackages = {"org.onap.so.db.catalog.data.repository"})
public class EmbeddedCatalogDbConfig {
@Bean
@@ -54,49 +51,36 @@ public class EmbeddedCatalogDbConfig {
return new MariaDB4jSpringService();
}
- @Primary
- @Bean(name = "dataSource")
+ @Primary
+ @Bean(name = "dataSource")
DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService,
- @Value("${mariaDB4j.databaseName}") String databaseName,
- @Value("${spring.datasource.username}") String datasourceUsername,
- @Value("${spring.datasource.password}") String datasourcePassword,
- @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
- //Create our database with default root user and no password
+ @Value("${mariaDB4j.databaseName}") String databaseName,
+ @Value("${spring.datasource.username}") String datasourceUsername,
+ @Value("${spring.datasource.password}") String datasourcePassword,
+ @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
+ // Create our database with default root user and no password
mariaDB4jSpringService.getDB().createDB(databaseName);
DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
- return DataSourceBuilder
- .create()
- .username(datasourceUsername)
- .password(datasourcePassword)
- .url(config.getURL(databaseName))
- .driverClassName(datasourceDriver)
- .build();
+ return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword)
+ .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build();
}
-
- @Primary
- @Bean(name = "entityManagerFactory")
- public LocalContainerEntityManagerFactoryBean
- entityManagerFactory(
- EntityManagerFactoryBuilder builder,
- @Qualifier("dataSource") DataSource dataSource
- ) {
- return builder
- .dataSource(dataSource)
- .packages("org.onap.so.db.catalog.beans")
- .persistenceUnit("catalogDB")
- .build();
- }
- @Primary
- @Bean(name = "transactionManager")
- public PlatformTransactionManager transactionManager(
- @Qualifier("entityManagerFactory") EntityManagerFactory
- entityManagerFactory
- ) {
- return new JpaTransactionManager(entityManagerFactory);
- }
+ @Primary
+ @Bean(name = "entityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
+ @Qualifier("dataSource") DataSource dataSource) {
+ return builder.dataSource(dataSource).packages("org.onap.so.db.catalog.beans").persistenceUnit("catalogDB")
+ .build();
+ }
+
+ @Primary
+ @Bean(name = "transactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("entityManagerFactory") EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedRequestDbConfig.java b/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedRequestDbConfig.java
index 2827f8721e..e60b8fe238 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedRequestDbConfig.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedRequestDbConfig.java
@@ -19,10 +19,10 @@
*/
package org.onap.so.asdc;
+
import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
-
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
@@ -37,17 +37,14 @@ import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
-
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
@Profile({"test"})
@EnableTransactionManagement
-@EnableJpaRepositories(
- entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager",
- basePackages = { "org.onap.so.db.request.data.repository" }
- )
+@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory",
+ transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"})
public class EmbeddedRequestDbConfig {
@Bean
@@ -56,47 +53,34 @@ public class EmbeddedRequestDbConfig {
}
- @Bean(name = "requestDataSource")
- @ConfigurationProperties(prefix = "request.datasource")
+ @Bean(name = "requestDataSource")
+ @ConfigurationProperties(prefix = "request.datasource")
DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService,
- @Value("${mariaDB4j.databaseName2}") String databaseName,
- @Value("${spring.datasource.username}") String datasourceUsername,
- @Value("${spring.datasource.password}") String datasourcePassword,
- @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
- //Create our database with default root user and no password
+ @Value("${mariaDB4j.databaseName2}") String databaseName,
+ @Value("${spring.datasource.username}") String datasourceUsername,
+ @Value("${spring.datasource.password}") String datasourcePassword,
+ @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
+ // Create our database with default root user and no password
mariaDB4jSpringService.getDB().createDB(databaseName);
DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
- return DataSourceBuilder
- .create()
- .username(datasourceUsername)
- .password(datasourcePassword)
- .url(config.getURL(databaseName))
- .driverClassName(datasourceDriver)
- .build();
+ return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword)
+ .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build();
}
- @Bean(name = "requestEntityManagerFactory")
- public LocalContainerEntityManagerFactoryBean
- entityManagerFactory(
- EntityManagerFactoryBuilder builder,
- @Qualifier("requestDataSource") DataSource dataSource
- ) {
- return builder
- .dataSource(dataSource)
- .packages("org.onap.so.db.request.beans")
- .persistenceUnit("requestDB")
- .build();
- }
+ @Bean(name = "requestEntityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
+ @Qualifier("requestDataSource") DataSource dataSource) {
+ return builder.dataSource(dataSource).packages("org.onap.so.db.request.beans").persistenceUnit("requestDB")
+ .build();
+ }
- @Bean(name = "requestTransactionManager")
- public PlatformTransactionManager transactionManager(
- @Qualifier("requestEntityManagerFactory") EntityManagerFactory
- entityManagerFactory
- ) {
- return new JpaTransactionManager(entityManagerFactory);
- }
+ @Bean(name = "requestTransactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java b/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java
index 4298f9c5b5..c35e8e34d6 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java
@@ -31,15 +31,15 @@ import org.springframework.context.annotation.Profile;
@SpringBootApplication
@Profile("test")
-@ComponentScan(basePackages = {"org.onap.so.asdc"}, excludeFilters = {
- @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class),
- @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = RequestsDBHelper.class),
- @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = InfraActiveRequestsRepositoryImpl.class) })
+@ComponentScan(basePackages = {"org.onap.so.asdc"},
+ excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class),
+ @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = RequestsDBHelper.class),
+ @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = InfraActiveRequestsRepositoryImpl.class)})
public class TestApplication {
- public static void main(String... args) {
- SpringApplication.run(TestApplication.class, args);
- System.getProperties().setProperty("mso.db", "MARIADB");
- System.getProperties().setProperty("server.name", "Springboot");
- System.getProperties().setProperty("mso.config.path", "src/test/resources/");
- }
+ public static void main(String... args) {
+ SpringApplication.run(TestApplication.class, args);
+ System.getProperties().setProperty("mso.db", "MARIADB");
+ System.getProperties().setProperty("server.name", "Springboot");
+ System.getProperties().setProperty("mso.config.path", "src/test/resources/");
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCConfigurationTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCConfigurationTest.java
index 16bd97b409..40c403fd72 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCConfigurationTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCConfigurationTest.java
@@ -23,9 +23,7 @@ package org.onap.so.asdc.client;
import static org.junit.Assert.assertTrue;
-
import javax.transaction.Transactional;
-
import org.junit.Test;
import org.onap.so.asdc.BaseTest;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,24 +34,24 @@ import org.springframework.beans.factory.annotation.Autowired;
*
*/
public class ASDCConfigurationTest extends BaseTest {
-
+
@Autowired
private ASDCConfiguration config;
-
+
@Test
- @Transactional
- public void testInitASDCConfiguration() throws Exception {
- assertTrue("msopreist".equals(config.getUser()));
- assertTrue("msoasdc-id-local".equals(config.getConsumerGroup()));
- assertTrue("msoasdc-id-local".equals(config.getConsumerID()));
- assertTrue("Pre-IST".equals(config.getEnvironmentName()));
- assertTrue("localhost:8443".equals(config.getAsdcAddress()));
- assertTrue("msopreist".equals(config.getPassword()));
- assertTrue(config.getPollingInterval() == 30);
- assertTrue(config.getPollingTimeout() == 30);
- assertTrue(config.getRelevantArtifactTypes().size() == config.SUPPORTED_ARTIFACT_TYPES_LIST.size());
- assertTrue(config.getWatchDogTimeout() == 1);
- assertTrue(config.isUseHttpsWithDmaap() == true);
+ @Transactional
+ public void testInitASDCConfiguration() throws Exception {
+ assertTrue("msopreist".equals(config.getUser()));
+ assertTrue("msoasdc-id-local".equals(config.getConsumerGroup()));
+ assertTrue("msoasdc-id-local".equals(config.getConsumerID()));
+ assertTrue("Pre-IST".equals(config.getEnvironmentName()));
+ assertTrue("localhost:8443".equals(config.getAsdcAddress()));
+ assertTrue("msopreist".equals(config.getPassword()));
+ assertTrue(config.getPollingInterval() == 30);
+ assertTrue(config.getPollingTimeout() == 30);
+ assertTrue(config.getRelevantArtifactTypes().size() == config.SUPPORTED_ARTIFACT_TYPES_LIST.size());
+ assertTrue(config.getWatchDogTimeout() == 1);
+ assertTrue(config.isUseHttpsWithDmaap() == true);
}
-
+
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
index 51559c2ffe..0681cd8aed 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
@@ -1,20 +1,15 @@
/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix
+ * Foundation. ================================================================================ Licensed under the
+ * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
+ * obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language governing permissions and limitations under the
+ * License.
*
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
+ * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
*/
package org.onap.so.asdc.client;
@@ -26,15 +21,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
-
import javax.persistence.EntityNotFoundException;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -120,7 +112,7 @@ public class ASDCControllerITTest extends BaseTest {
distributionId = UUID.randomUUID().toString();
artifactUuid = UUID.randomUUID().toString();
logger.info("Using distributionId: {}, artifactUUID: {} for testcase: {}", distributionId, artifactUuid,
- testName.getMethodName());
+ testName.getMethodName());
distributionClient = new DistributionClientEmulator();
distributionClient.setResourcePath("src/test/resources");
@@ -148,7 +140,7 @@ public class ASDCControllerITTest extends BaseTest {
*/
private void initMockAaiServer(final String serviceUuid, final String serviceInvariantUuid) {
String modelEndpoint = "/aai/v15/service-design-and-creation/models/model/" + serviceInvariantUuid
- + "/model-vers/model-ver/" + serviceUuid + "?depth=0";
+ + "/model-vers/model-ver/" + serviceUuid + "?depth=0";
wireMockServer.stubFor(post(urlEqualTo(modelEndpoint)).willReturn(ok()));
}
@@ -191,7 +183,7 @@ public class ASDCControllerITTest extends BaseTest {
* Check the tosca csar entity, it should be the same as provided from NotficationData.
*/
ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid)
- .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
assertEquals("tosca csar name", "service-Testservice140-csar.csar", toscaCsar.getName());
assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
@@ -200,17 +192,18 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("toscar csar URL", "/download/service-Testservice140-csar.csar", toscaCsar.getUrl());
/**
- * Check the service entity, it should be the same as global metadata information in service-Testservice140-template.yml inside csar.
+ * Check the service entity, it should be the same as global metadata information in
+ * service-Testservice140-template.yml inside csar.
*/
Service service = serviceRepository.findById(serviceUuid)
- .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
assertEquals("model UUID", "efaea486-561f-4159-9191-a8d3cb346728", service.getModelUUID());
assertEquals("model name", "TestService140", service.getModelName());
assertEquals("model invariantUUID", "f2edfbf4-bb0a-4fe7-a57a-71362d4b0b23",
- service.getModelInvariantUUID());
+ service.getModelInvariantUUID());
assertEquals("model version", "1.0", service.getModelVersion());
assertEquals("description", "Test Service for extended attributes of PNF resource",
- service.getDescription().trim());
+ service.getDescription().trim());
assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID());
assertEquals("service type", "Network", service.getServiceType());
assertEquals("service role", "nfv", service.getServiceRole());
@@ -220,18 +213,17 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("resource order", "Test140PNF", service.getResourceOrder());
/**
- * Check PNF resource, it should be the same as metadata in the topology template in service-Testservice140-template.yml
- * OR
- * global metadata in the resource-Test140pnf-template.yml
+ * Check PNF resource, it should be the same as metadata in the topology template in
+ * service-Testservice140-template.yml OR global metadata in the resource-Test140pnf-template.yml
*/
String pnfResourceKey = "9c54e269-122b-4e8a-8b2a-6eac849b441a";
PnfResource pnfResource = pnfResourceRepository.findById(pnfResourceKey)
- .orElseThrow(() -> new EntityNotFoundException("PNF resource:" + pnfResourceKey + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("PNF resource:" + pnfResourceKey + " not found"));
assertNull("orchestration mode", pnfResource.getOrchestrationMode());
assertEquals("Description", "Oracle", pnfResource.getDescription().trim());
assertEquals("model UUID", pnfResourceKey, pnfResource.getModelUUID());
assertEquals("model invariant UUID", "d832a027-75f3-455d-9de4-f02fcdee7e7e",
- pnfResource.getModelInvariantUUID());
+ pnfResource.getModelInvariantUUID());
assertEquals("model version", "1.0", pnfResource.getModelVersion());
assertEquals("model name", "Test140PNF", pnfResource.getModelName());
assertEquals("tosca node type", "org.openecomp.resource.pnf.Test140pnf", pnfResource.getToscaNodeType());
@@ -239,15 +231,13 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("resource sub category", "Call Control", pnfResource.getSubCategory());
/**
- * Check PNF resource customization, it should be the same as metadata in the topology template in service-Testservice140-template.yml
- * OR
- * global metadata in the resource-Test140pnf-template.yml
+ * Check PNF resource customization, it should be the same as metadata in the topology template in
+ * service-Testservice140-template.yml OR global metadata in the resource-Test140pnf-template.yml
*/
String pnfCustomizationKey = "428a3d73-f962-4cc2-ba62-2483c45d6b12";
- PnfResourceCustomization pnfCustomization = pnfCustomizationRepository
- .findById(pnfCustomizationKey).orElseThrow(
- () -> new EntityNotFoundException(
- "PNF resource customization: " + pnfCustomizationKey + " not found"));
+ PnfResourceCustomization pnfCustomization = pnfCustomizationRepository.findById(pnfCustomizationKey)
+ .orElseThrow(() -> new EntityNotFoundException(
+ "PNF resource customization: " + pnfCustomizationKey + " not found"));
assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID());
assertEquals("model instance name", "Test140PNF 0", pnfCustomization.getModelInstanceName());
assertEquals("NF type", "", pnfCustomization.getNfType());
@@ -258,9 +248,9 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("Multi stage design", "", pnfCustomization.getMultiStageDesign());
assertNull("resource input", pnfCustomization.getResourceInput());
assertEquals("cds blueprint name(sdnc_model_name property)", pnfCustomization.getBlueprintName(),
- pnfCustomization.getBlueprintName());
+ pnfCustomization.getBlueprintName());
assertEquals("cds blueprint version(sdnc_model_version property)", pnfCustomization.getBlueprintVersion(),
- pnfCustomization.getBlueprintVersion());
+ pnfCustomization.getBlueprintVersion());
/**
* Check the pnf resource customization with service mapping
@@ -272,8 +262,8 @@ public class ASDCControllerITTest extends BaseTest {
/**
* Check the watchdog for component distribution status
*/
- List<WatchdogComponentDistributionStatus> distributionList = watchdogCDStatusRepository
- .findByDistributionId(this.distributionId);
+ List<WatchdogComponentDistributionStatus> distributionList =
+ watchdogCDStatusRepository.findByDistributionId(this.distributionId);
assertNotNull(distributionList);
assertEquals(1, distributionList.size());
WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0);
@@ -353,7 +343,7 @@ public class ASDCControllerITTest extends BaseTest {
* Check the tosca csar entity, it should be the same as provided from NotficationData.
*/
ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid)
- .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
assertEquals("tosca csar name", "service-Svc140-VF-csar.csar", toscaCsar.getName());
assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
@@ -362,17 +352,16 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("toscar csar URL", "/download/service-Svc140-VF-csar.csar", toscaCsar.getUrl());
/**
- * Check the service entity, it should be the same as global metadata information in service-Testservice140-template.yml inside csar.
+ * Check the service entity, it should be the same as global metadata information in
+ * service-Testservice140-template.yml inside csar.
*/
Service service = serviceRepository.findById(serviceUuid)
- .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
assertEquals("model UUID", serviceUuid, service.getModelUUID());
assertEquals("model name", "SVC140", service.getModelName());
- assertEquals("model invariantUUID", serviceInvariantUuid,
- service.getModelInvariantUUID());
+ assertEquals("model invariantUUID", serviceInvariantUuid, service.getModelInvariantUUID());
assertEquals("model version", "1.0", service.getModelVersion());
- assertEquals("description", "SVC140",
- service.getDescription().trim());
+ assertEquals("description", "SVC140", service.getDescription().trim());
assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID());
assertEquals("service type", "ST", service.getServiceType());
assertEquals("service role", "Sr", service.getServiceRole());
@@ -382,18 +371,17 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("resource order", "TestVF140", service.getResourceOrder());
/**
- * Check VNF resource, it should be the same as metadata in the topology template in service-Testservice140-template.yml
- * OR
- * global metadata in the resource-Testservice140-template.yml
+ * Check VNF resource, it should be the same as metadata in the topology template in
+ * service-Testservice140-template.yml OR global metadata in the resource-Testservice140-template.yml
*/
String vnfResourceKey = "d20d3ea9-2f54-4071-8b5c-fd746dde245e";
VnfResource vnfResource = vnfResourceRepository.findById(vnfResourceKey)
- .orElseThrow(() -> new EntityNotFoundException("VNF resource:" + vnfResourceKey + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("VNF resource:" + vnfResourceKey + " not found"));
assertEquals("orchestration mode", "HEAT", vnfResource.getOrchestrationMode());
assertEquals("Description", "TestPNF140", vnfResource.getDescription().trim());
assertEquals("model UUID", vnfResourceKey, vnfResource.getModelUUID());
assertEquals("model invariant UUID", "7a4bffa2-fac5-4b8b-b348-0bdf313a1aeb",
- vnfResource.getModelInvariantUUID());
+ vnfResource.getModelInvariantUUID());
assertEquals("model version", "1.0", vnfResource.getModelVersion());
assertEquals("model name", "TestVF140", vnfResource.getModelName());
assertEquals("tosca node type", "org.openecomp.resource.vf.Testvf140", vnfResource.getToscaNodeType());
@@ -401,15 +389,14 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("resource sub category", "Database", vnfResource.getSubCategory());
/**
- * Check VNF resource customization, it should be the same as metadata in the topology template in service-Testservice140-template.yml
- * OR
- * global metadata in the resource-Testservice140-template.yml
+ * Check VNF resource customization, it should be the same as metadata in the topology template in
+ * service-Testservice140-template.yml OR global metadata in the resource-Testservice140-template.yml
*/
String vnfCustomizationKey = "ca1c8455-8ce2-4a76-a037-3f4cf01cffa0";
- VnfResourceCustomization vnfCustomization = Optional.ofNullable(vnfCustomizationRepository
- .findOneByModelCustomizationUUID(vnfCustomizationKey)).orElseThrow(
- () -> new EntityNotFoundException(
- "VNF resource customization: " + vnfCustomizationKey + " not found"));
+ VnfResourceCustomization vnfCustomization =
+ Optional.ofNullable(vnfCustomizationRepository.findOneByModelCustomizationUUID(vnfCustomizationKey))
+ .orElseThrow(() -> new EntityNotFoundException(
+ "VNF resource customization: " + vnfCustomizationKey + " not found"));
assertEquals("model customizationUUID", vnfCustomizationKey, vnfCustomization.getModelCustomizationUUID());
assertEquals("model instance name", "TestVF140 0", vnfCustomization.getModelInstanceName());
assertNull("NF type", vnfCustomization.getNfType());
@@ -420,9 +407,9 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("Multi stage design", "false", vnfCustomization.getMultiStageDesign());
assertNull("resource input", vnfCustomization.getResourceInput());
assertEquals("cds blueprint name(sdnc_model_name property)", vnfCustomization.getBlueprintName(),
- vnfCustomization.getBlueprintName());
+ vnfCustomization.getBlueprintName());
assertEquals("cds blueprint version(sdnc_model_version property)", vnfCustomization.getBlueprintVersion(),
- vnfCustomization.getBlueprintVersion());
+ vnfCustomization.getBlueprintVersion());
/**
* Check the vnf resource customization with service mapping
*/
@@ -433,8 +420,8 @@ public class ASDCControllerITTest extends BaseTest {
/**
* Check the watchdog for component distribution status
*/
- List<WatchdogComponentDistributionStatus> distributionList = watchdogCDStatusRepository
- .findByDistributionId(this.distributionId);
+ List<WatchdogComponentDistributionStatus> distributionList =
+ watchdogCDStatusRepository.findByDistributionId(this.distributionId);
assertNotNull(distributionList);
assertEquals(1, distributionList.size());
WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0);
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerTest.java
index 580220aabb..104eed7c90 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerTest.java
@@ -28,21 +28,21 @@ import org.onap.so.asdc.client.exceptions.ASDCControllerException;
import org.springframework.beans.factory.annotation.Autowired;
public class ASDCControllerTest extends BaseTest {
- @Autowired
- private ASDCController asdcController;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Test
- public void initASDCExceptionTest() throws Exception {
- expectedException.expect(ASDCControllerException.class);
-
- asdcController.changeControllerStatus(ASDCControllerStatus.IDLE);
-
- try {
- asdcController.initASDC();
- } finally {
- asdcController.closeASDC();
- }
- }
+ @Autowired
+ private ASDCController asdcController;
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void initASDCExceptionTest() throws Exception {
+ expectedException.expect(ASDCControllerException.class);
+
+ asdcController.changeControllerStatus(ASDCControllerStatus.IDLE);
+
+ try {
+ asdcController.initASDC();
+ } finally {
+ asdcController.closeASDC();
+ }
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCElementInfoTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCElementInfoTest.java
index fec3ae6362..6196691807 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCElementInfoTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCElementInfoTest.java
@@ -27,10 +27,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-
import java.util.Collections;
import java.util.UUID;
-
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.sdc.api.notification.IArtifactInfo;
@@ -46,129 +44,132 @@ import org.onap.so.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/onap/so/asdc/client/ASDCStatusCallBackTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCStatusCallBackTest.java
index ba95a6ea24..24b1736fad 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCStatusCallBackTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCStatusCallBackTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -41,51 +40,52 @@ import org.onap.so.asdc.client.test.emulators.JsonStatusData;
import org.springframework.beans.factory.annotation.Autowired;
public class ASDCStatusCallBackTest extends BaseTest {
- @Autowired
- private ASDCStatusCallBack statusCallback;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void before() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void activateCallbackTest() throws Exception {
- JsonStatusData statusData = new JsonStatusData();
-
- doNothing().when(toscaInstaller).installTheComponentStatus(isA(JsonStatusData.class));
-
- statusCallback.activateCallback(statusData);
-
- verify(toscaInstaller, times(1)).installTheComponentStatus(statusData);
- }
-
- @Test
- public void activateCallbackDoneErrorStatusTest() throws Exception {
- IStatusData statusData = mock(IStatusData.class);
-
- doReturn("distributionId").when(statusData).getDistributionID();
- doReturn("componentName").when(statusData).getComponentName();
- doReturn(DistributionStatusEnum.COMPONENT_DONE_ERROR).when(statusData).getStatus();
- doNothing().when(toscaInstaller).installTheComponentStatus(isA(IStatusData.class));
-
- statusCallback.activateCallback(statusData);
-
- verify(toscaInstaller, times(1)).installTheComponentStatus(statusData);
- }
-
- @Test
- public void activateCallbackExceptionTest() throws Exception {
- IStatusData statusData = mock(IStatusData.class);
-
- doReturn("distributionId").when(statusData).getDistributionID();
- doReturn("componentName").when(statusData).getComponentName();
- doReturn(DistributionStatusEnum.COMPONENT_DONE_OK).when(statusData).getStatus();
- doThrow(ArtifactInstallerException.class).when(toscaInstaller).installTheComponentStatus(isA(IStatusData.class));
-
- statusCallback.activateCallback(statusData);
- }
+ @Autowired
+ private ASDCStatusCallBack statusCallback;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void activateCallbackTest() throws Exception {
+ JsonStatusData statusData = new JsonStatusData();
+
+ doNothing().when(toscaInstaller).installTheComponentStatus(isA(JsonStatusData.class));
+
+ statusCallback.activateCallback(statusData);
+
+ verify(toscaInstaller, times(1)).installTheComponentStatus(statusData);
+ }
+
+ @Test
+ public void activateCallbackDoneErrorStatusTest() throws Exception {
+ IStatusData statusData = mock(IStatusData.class);
+
+ doReturn("distributionId").when(statusData).getDistributionID();
+ doReturn("componentName").when(statusData).getComponentName();
+ doReturn(DistributionStatusEnum.COMPONENT_DONE_ERROR).when(statusData).getStatus();
+ doNothing().when(toscaInstaller).installTheComponentStatus(isA(IStatusData.class));
+
+ statusCallback.activateCallback(statusData);
+
+ verify(toscaInstaller, times(1)).installTheComponentStatus(statusData);
+ }
+
+ @Test
+ public void activateCallbackExceptionTest() throws Exception {
+ IStatusData statusData = mock(IStatusData.class);
+
+ doReturn("distributionId").when(statusData).getDistributionID();
+ doReturn("componentName").when(statusData).getComponentName();
+ doReturn(DistributionStatusEnum.COMPONENT_DONE_OK).when(statusData).getStatus();
+ doThrow(ArtifactInstallerException.class).when(toscaInstaller)
+ .installTheComponentStatus(isA(IStatusData.class));
+
+ statusCallback.activateCallback(statusData);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/BigDecimalVersionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/BigDecimalVersionTest.java
index 4eb9ed5619..090f2e8968 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/BigDecimalVersionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/BigDecimalVersionTest.java
@@ -24,30 +24,29 @@ package org.onap.so.asdc.client;
import static org.junit.Assert.assertTrue;
import java.math.BigDecimal;
import org.junit.Test;
-
import org.onap.so.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/onap/so/asdc/client/DistributionStatusMessageTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/DistributionStatusMessageTest.java
index 0c6476ddef..9c8929b76a 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/DistributionStatusMessageTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/DistributionStatusMessageTest.java
@@ -21,25 +21,24 @@
package org.onap.so.asdc.client;
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
import org.onap.sdc.utils.DistributionStatusEnum;
public class DistributionStatusMessageTest {
-
- @Test
- public void distributionStatusMessageTest() {
- String artifactUrl = "artifactUrl";
- String consumerId = "consumerId";
- String distributionId = "distributionId";
- Long timestamp = 123L;
- DistributionStatusMessage distributionStatusMessage = new DistributionStatusMessage(
- artifactUrl, consumerId, distributionId, DistributionStatusEnum.DEPLOY_OK, timestamp);
-
- assertEquals(artifactUrl, distributionStatusMessage.getArtifactURL());
- assertEquals(consumerId, distributionStatusMessage.getConsumerID());
- assertEquals(distributionId, distributionStatusMessage.getDistributionID());
- assertEquals(DistributionStatusEnum.DEPLOY_OK, distributionStatusMessage.getStatus());
- assertEquals(123L, distributionStatusMessage.getTimestamp());
- }
+
+ @Test
+ public void distributionStatusMessageTest() {
+ String artifactUrl = "artifactUrl";
+ String consumerId = "consumerId";
+ String distributionId = "distributionId";
+ Long timestamp = 123L;
+ DistributionStatusMessage distributionStatusMessage = new DistributionStatusMessage(artifactUrl, consumerId,
+ distributionId, DistributionStatusEnum.DEPLOY_OK, timestamp);
+
+ assertEquals(artifactUrl, distributionStatusMessage.getArtifactURL());
+ assertEquals(consumerId, distributionStatusMessage.getConsumerID());
+ assertEquals(distributionId, distributionStatusMessage.getDistributionID());
+ assertEquals(DistributionStatusEnum.DEPLOY_OK, distributionStatusMessage.getStatus());
+ assertEquals(123L, distributionStatusMessage.getTimestamp());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/YamlTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/YamlTest.java
index ed761c7f4d..d7316e57bd 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/YamlTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/YamlTest.java
@@ -22,7 +22,6 @@ package org.onap.so.asdc.client;
import static org.junit.Assert.*;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -36,118 +35,123 @@ import org.onap.so.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 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);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCControllerExceptionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCControllerExceptionTest.java
index e2aee6080e..927779c485 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCControllerExceptionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCControllerExceptionTest.java
@@ -22,29 +22,28 @@ package org.onap.so.asdc.client.exceptions;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-
import org.junit.Test;
public class ASDCControllerExceptionTest {
- private String exceptionMessage = "test message for exception";
- private String throwableMessage = "separate throwable that caused asdcDownloadException";
-
- @Test
- public void asdcParametersExceptionTest() {
- ASDCControllerException asdcDownloadException = new ASDCControllerException(exceptionMessage);
-
- Exception expectedException = new Exception(exceptionMessage);
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
-
- @Test
- public void asdcParametersExceptionThrowableTest() {
- Throwable throwableCause = new Throwable(throwableMessage);
- ASDCControllerException asdcDownloadException = new ASDCControllerException(exceptionMessage, throwableCause);
-
- Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
+ private String exceptionMessage = "test message for exception";
+ private String throwableMessage = "separate throwable that caused asdcDownloadException";
+
+ @Test
+ public void asdcParametersExceptionTest() {
+ ASDCControllerException asdcDownloadException = new ASDCControllerException(exceptionMessage);
+
+ Exception expectedException = new Exception(exceptionMessage);
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
+
+ @Test
+ public void asdcParametersExceptionThrowableTest() {
+ Throwable throwableCause = new Throwable(throwableMessage);
+ ASDCControllerException asdcDownloadException = new ASDCControllerException(exceptionMessage, throwableCause);
+
+ Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCDownloadExceptionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCDownloadExceptionTest.java
index 98deb52a08..b022ed91d7 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCDownloadExceptionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCDownloadExceptionTest.java
@@ -22,29 +22,28 @@ package org.onap.so.asdc.client.exceptions;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-
import org.junit.Test;
public class ASDCDownloadExceptionTest {
- private String exceptionMessage = "test message for exception";
- private String throwableMessage = "separate throwable that caused asdcDownloadException";
-
- @Test
- public void asdcDownloadExceptionTest() {
- ASDCDownloadException asdcDownloadException = new ASDCDownloadException(exceptionMessage);
-
- Exception expectedException = new Exception(exceptionMessage);
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
-
- @Test
- public void asdcDownloadExceptionThrowableTest() {
- Throwable throwableCause = new Throwable(throwableMessage);
- ASDCDownloadException asdcDownloadException = new ASDCDownloadException(exceptionMessage, throwableCause);
-
- Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
+ private String exceptionMessage = "test message for exception";
+ private String throwableMessage = "separate throwable that caused asdcDownloadException";
+
+ @Test
+ public void asdcDownloadExceptionTest() {
+ ASDCDownloadException asdcDownloadException = new ASDCDownloadException(exceptionMessage);
+
+ Exception expectedException = new Exception(exceptionMessage);
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
+
+ @Test
+ public void asdcDownloadExceptionThrowableTest() {
+ Throwable throwableCause = new Throwable(throwableMessage);
+ ASDCDownloadException asdcDownloadException = new ASDCDownloadException(exceptionMessage, throwableCause);
+
+ Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCParametersExceptionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCParametersExceptionTest.java
index bac05bd47c..2b4a0c956e 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCParametersExceptionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCParametersExceptionTest.java
@@ -22,29 +22,28 @@ package org.onap.so.asdc.client.exceptions;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-
import org.junit.Test;
public class ASDCParametersExceptionTest {
- private String exceptionMessage = "test message for exception";
- private String throwableMessage = "separate throwable that caused asdcDownloadException";
-
- @Test
- public void asdcParametersExceptionTest() {
- ASDCParametersException asdcDownloadException = new ASDCParametersException(exceptionMessage);
-
- Exception expectedException = new Exception(exceptionMessage);
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
-
- @Test
- public void asdcParametersExceptionThrowableTest() {
- Throwable throwableCause = new Throwable(throwableMessage);
- ASDCParametersException asdcDownloadException = new ASDCParametersException(exceptionMessage, throwableCause);
-
- Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
+ private String exceptionMessage = "test message for exception";
+ private String throwableMessage = "separate throwable that caused asdcDownloadException";
+
+ @Test
+ public void asdcParametersExceptionTest() {
+ ASDCParametersException asdcDownloadException = new ASDCParametersException(exceptionMessage);
+
+ Exception expectedException = new Exception(exceptionMessage);
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
+
+ @Test
+ public void asdcParametersExceptionThrowableTest() {
+ Throwable throwableCause = new Throwable(throwableMessage);
+ ASDCParametersException asdcDownloadException = new ASDCParametersException(exceptionMessage, throwableCause);
+
+ Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerExceptionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerExceptionTest.java
index f2227908f5..3e0dd27d07 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerExceptionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerExceptionTest.java
@@ -22,29 +22,29 @@ package org.onap.so.asdc.client.exceptions;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-
import org.junit.Test;
public class ArtifactInstallerExceptionTest {
- private String exceptionMessage = "test message for exception";
- private String throwableMessage = "separate throwable that caused asdcDownloadException";
-
- @Test
- public void asdcParametersExceptionTest() {
- ArtifactInstallerException asdcDownloadException = new ArtifactInstallerException(exceptionMessage);
-
- Exception expectedException = new Exception(exceptionMessage);
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
-
- @Test
- public void asdcParametersExceptionThrowableTest() {
- Throwable throwableCause = new Throwable(throwableMessage);
- ArtifactInstallerException asdcDownloadException = new ArtifactInstallerException(exceptionMessage, throwableCause);
-
- Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
+ private String exceptionMessage = "test message for exception";
+ private String throwableMessage = "separate throwable that caused asdcDownloadException";
+
+ @Test
+ public void asdcParametersExceptionTest() {
+ ArtifactInstallerException asdcDownloadException = new ArtifactInstallerException(exceptionMessage);
+
+ Exception expectedException = new Exception(exceptionMessage);
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
+
+ @Test
+ public void asdcParametersExceptionThrowableTest() {
+ Throwable throwableCause = new Throwable(throwableMessage);
+ ArtifactInstallerException asdcDownloadException =
+ new ArtifactInstallerException(exceptionMessage, throwableCause);
+
+ Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImplTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImplTest.java
index 3dc323559d..69d3fd103d 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImplTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImplTest.java
@@ -22,28 +22,26 @@ package org.onap.so.asdc.client.test.emulators;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.mockito.Mock;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.so.asdc.BaseTest;
-public class ArtifactInfoImplTest extends BaseTest {
- @Mock
- private IArtifactInfo iArtifactInfo;
-
- @Test
- public void convertToArtifactInfoImplTest() {
- List<IArtifactInfo> list = new ArrayList<IArtifactInfo>();
- list.add(iArtifactInfo);
- assertEquals(1, ArtifactInfoImpl.convertToArtifactInfoImpl(list).size());
- }
-
- @Test
- public void convertToArtifactInfoImplNullListTest() {
- assertTrue(ArtifactInfoImpl.convertToArtifactInfoImpl(null).isEmpty());
- }
+public class ArtifactInfoImplTest extends BaseTest {
+ @Mock
+ private IArtifactInfo iArtifactInfo;
+
+ @Test
+ public void convertToArtifactInfoImplTest() {
+ List<IArtifactInfo> list = new ArrayList<IArtifactInfo>();
+ list.add(iArtifactInfo);
+ assertEquals(1, ArtifactInfoImpl.convertToArtifactInfoImpl(list).size());
+ }
+
+ @Test
+ public void convertToArtifactInfoImplNullListTest() {
+ assertTrue(ArtifactInfoImpl.convertToArtifactInfoImpl(null).isEmpty());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulatorTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulatorTest.java
index 38c2564241..cfbf7724cc 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulatorTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulatorTest.java
@@ -21,13 +21,11 @@
package org.onap.so.asdc.client.test.emulators;
import static org.junit.Assert.assertEquals;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.LinkedList;
import java.util.List;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.sdc.api.consumer.IDistributionStatusMessage;
@@ -43,136 +41,156 @@ import org.onap.so.asdc.client.ASDCStatusCallBack;
import org.onap.so.asdc.client.DistributionStatusMessage;
public class DistributionClientEmulatorTest {
-
- private DistributionClientEmulator distClientEmulator;
-
- @Before
- public void before() {
- distClientEmulator = new DistributionClientEmulator();
- }
-
- @Test
- public void getDistributionMessageReceived() {
- List<IDistributionStatusMessage> receivedMessages = distClientEmulator.getDistributionMessageReceived();
- assertEquals(new LinkedList<>(), receivedMessages);
-
- IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId", "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
- distClientEmulator.sendDeploymentStatus(message);
- assertEquals(message, receivedMessages.get(0));
-
- IDistributionStatusMessage message2 = new DistributionStatusMessage("testArtifactUrl2", "testConsumerId2", "testDistributionId2", DistributionStatusEnum.DOWNLOAD_OK, 1234567);
- distClientEmulator.sendDeploymentStatus(message2);
- assertEquals(message2, receivedMessages.get(1));
- }
-
- @Test
- public void sendDeploymentStatusPrimary() {
- IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId", "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
- IDistributionClientResult result = distClientEmulator.sendDeploymentStatus(message);
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void sendDeploymentStatusSecondary() {
- IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId", "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
- IDistributionClientResult result = distClientEmulator.sendDeploymentStatus(message, "test");
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void sendDownloadStatusPrimary() {
- IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId", "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
- IDistributionClientResult result = distClientEmulator.sendDownloadStatus(message);
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void sendDownloadStatusSecondary() {
- IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId", "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
- IDistributionClientResult result = distClientEmulator.sendDownloadStatus(message, "test");
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void initPrimary() {
- IDistributionClientResult result = distClientEmulator.init(new ASDCConfiguration(), new ASDCNotificationCallBack());
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void initSecondary() {
- IDistributionClientResult result = distClientEmulator.init(new ASDCConfiguration(), new ASDCNotificationCallBack(), new ASDCStatusCallBack());
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void start() {
- IDistributionClientResult result = distClientEmulator.start();
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void stop() {
- IDistributionClientResult result = distClientEmulator.stop();
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void updateConfiguration() {
- IDistributionClientResult result = distClientEmulator.updateConfiguration(new ASDCConfiguration());
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void getResourcePath() {
- String testResourcePath = "testResourcePath";
- distClientEmulator = new DistributionClientEmulator(testResourcePath);
- assertEquals(testResourcePath, distClientEmulator.getResourcePath());
- }
-
- @Test
- public void setResourcePath() {
- String testResourcePath = "testResourcePath";
- distClientEmulator.setResourcePath(testResourcePath);
- assertEquals(testResourcePath, distClientEmulator.getResourcePath());
- }
-
- @Test
- public void downloadSuccess() throws IOException {
- ArtifactInfoImpl info = new ArtifactInfoImpl();
- info.setArtifactURL("mso.json");
- info.setArtifactName("testArtifactName");
-
- distClientEmulator.setResourcePath("src/test/resources/");
-
- IDistributionClientDownloadResult result = distClientEmulator.download(info);
-
- byte[] expectedInputStream = Files.readAllBytes(Paths.get(distClientEmulator.getResourcePath() + info.getArtifactURL()));
- IDistributionClientDownloadResult expectedResult = new DistributionClientDownloadResultImpl(DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name(), info.getArtifactName(), expectedInputStream);
-
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
+
+ private DistributionClientEmulator distClientEmulator;
+
+ @Before
+ public void before() {
+ distClientEmulator = new DistributionClientEmulator();
+ }
+
+ @Test
+ public void getDistributionMessageReceived() {
+ List<IDistributionStatusMessage> receivedMessages = distClientEmulator.getDistributionMessageReceived();
+ assertEquals(new LinkedList<>(), receivedMessages);
+
+ IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId",
+ "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
+ distClientEmulator.sendDeploymentStatus(message);
+ assertEquals(message, receivedMessages.get(0));
+
+ IDistributionStatusMessage message2 = new DistributionStatusMessage("testArtifactUrl2", "testConsumerId2",
+ "testDistributionId2", DistributionStatusEnum.DOWNLOAD_OK, 1234567);
+ distClientEmulator.sendDeploymentStatus(message2);
+ assertEquals(message2, receivedMessages.get(1));
+ }
+
+ @Test
+ public void sendDeploymentStatusPrimary() {
+ IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId",
+ "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
+ IDistributionClientResult result = distClientEmulator.sendDeploymentStatus(message);
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void sendDeploymentStatusSecondary() {
+ IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId",
+ "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
+ IDistributionClientResult result = distClientEmulator.sendDeploymentStatus(message, "test");
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void sendDownloadStatusPrimary() {
+ IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId",
+ "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
+ IDistributionClientResult result = distClientEmulator.sendDownloadStatus(message);
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void sendDownloadStatusSecondary() {
+ IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId",
+ "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
+ IDistributionClientResult result = distClientEmulator.sendDownloadStatus(message, "test");
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void initPrimary() {
+ IDistributionClientResult result =
+ distClientEmulator.init(new ASDCConfiguration(), new ASDCNotificationCallBack());
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void initSecondary() {
+ IDistributionClientResult result = distClientEmulator.init(new ASDCConfiguration(),
+ new ASDCNotificationCallBack(), new ASDCStatusCallBack());
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void start() {
+ IDistributionClientResult result = distClientEmulator.start();
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void stop() {
+ IDistributionClientResult result = distClientEmulator.stop();
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void updateConfiguration() {
+ IDistributionClientResult result = distClientEmulator.updateConfiguration(new ASDCConfiguration());
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void getResourcePath() {
+ String testResourcePath = "testResourcePath";
+ distClientEmulator = new DistributionClientEmulator(testResourcePath);
+ assertEquals(testResourcePath, distClientEmulator.getResourcePath());
+ }
+
+ @Test
+ public void setResourcePath() {
+ String testResourcePath = "testResourcePath";
+ distClientEmulator.setResourcePath(testResourcePath);
+ assertEquals(testResourcePath, distClientEmulator.getResourcePath());
+ }
+
+ @Test
+ public void downloadSuccess() throws IOException {
+ ArtifactInfoImpl info = new ArtifactInfoImpl();
+ info.setArtifactURL("mso.json");
+ info.setArtifactName("testArtifactName");
+
+ distClientEmulator.setResourcePath("src/test/resources/");
+
+ IDistributionClientDownloadResult result = distClientEmulator.download(info);
+
+ byte[] expectedInputStream =
+ Files.readAllBytes(Paths.get(distClientEmulator.getResourcePath() + info.getArtifactURL()));
+ IDistributionClientDownloadResult expectedResult =
+ new DistributionClientDownloadResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name(), info.getArtifactName(), expectedInputStream);
+
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonStatusDataTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonStatusDataTest.java
index 5e2f1ad828..cf54656271 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonStatusDataTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonStatusDataTest.java
@@ -21,7 +21,6 @@
package org.onap.so.asdc.client.test.emulators;
import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
public class JsonStatusDataTest {
@@ -39,17 +38,16 @@ public class JsonStatusDataTest {
}
@Test
- public void setGetAttributes()
- {
+ public void setGetAttributes() {
JsonStatusData jsonStatusData = new JsonStatusData();
- jsonStatusData.setAttribute("test","test");
+ jsonStatusData.setAttribute("test", "test");
jsonStatusData.getStatus();
jsonStatusData.getTimestamp();
jsonStatusData.getComponentName();
jsonStatusData.getConsumerID();
jsonStatusData.getDistributionID();
String errReason = jsonStatusData.getErrorReason();
- assertEquals(errReason,"MSO FAILURE");
+ assertEquals(errReason, "MSO FAILURE");
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java
index 6da3a2c18c..bcef94336b 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java
@@ -21,32 +21,30 @@
package org.onap.so.asdc.client.test.emulators;
import static org.junit.Assert.assertEquals;
-
import java.util.HashMap;
-
import org.junit.Test;
public class JsonVfModuleMetaDataTest {
-
- @Test
- public void attributesMapTest() {
- JsonVfModuleMetaData vfModuleMetadata = new JsonVfModuleMetaData();
- vfModuleMetadata.setAttribute("vfModuleModelDescription", "vfModuleModelDescription");
- vfModuleMetadata.setAttribute("vfModuleModelInvariantUUID", "vfModuleModelInvariantUUID");
- vfModuleMetadata.setAttribute("vfModuleModelCustomizationUUID", "vfModuleModelCustomizationUUID");
- vfModuleMetadata.setAttribute("vfModuleModelName", "vfModuleModelName");
- vfModuleMetadata.setAttribute("vfModuleModelUUID", "vfModuleModelUUID");
- vfModuleMetadata.setAttribute("vfModuleModelVersion", "vfModuleModelVersion");
- vfModuleMetadata.setAttribute("isBase", true);
-
- assertEquals("vfModuleModelDescription", vfModuleMetadata.getVfModuleModelDescription());
- assertEquals("vfModuleModelInvariantUUID", vfModuleMetadata.getVfModuleModelInvariantUUID());
- assertEquals("vfModuleModelCustomizationUUID", vfModuleMetadata.getVfModuleModelCustomizationUUID());
- assertEquals("vfModuleModelName", vfModuleMetadata.getVfModuleModelName());
- assertEquals("vfModuleModelUUID", vfModuleMetadata.getVfModuleModelUUID());
- assertEquals("vfModuleModelVersion", vfModuleMetadata.getVfModuleModelVersion());
- assertEquals(true, vfModuleMetadata.isBase());
- assertEquals(null, vfModuleMetadata.getArtifacts());
- assertEquals(new HashMap<String, String>(), vfModuleMetadata.getProperties());
- }
+
+ @Test
+ public void attributesMapTest() {
+ JsonVfModuleMetaData vfModuleMetadata = new JsonVfModuleMetaData();
+ vfModuleMetadata.setAttribute("vfModuleModelDescription", "vfModuleModelDescription");
+ vfModuleMetadata.setAttribute("vfModuleModelInvariantUUID", "vfModuleModelInvariantUUID");
+ vfModuleMetadata.setAttribute("vfModuleModelCustomizationUUID", "vfModuleModelCustomizationUUID");
+ vfModuleMetadata.setAttribute("vfModuleModelName", "vfModuleModelName");
+ vfModuleMetadata.setAttribute("vfModuleModelUUID", "vfModuleModelUUID");
+ vfModuleMetadata.setAttribute("vfModuleModelVersion", "vfModuleModelVersion");
+ vfModuleMetadata.setAttribute("isBase", true);
+
+ assertEquals("vfModuleModelDescription", vfModuleMetadata.getVfModuleModelDescription());
+ assertEquals("vfModuleModelInvariantUUID", vfModuleMetadata.getVfModuleModelInvariantUUID());
+ assertEquals("vfModuleModelCustomizationUUID", vfModuleMetadata.getVfModuleModelCustomizationUUID());
+ assertEquals("vfModuleModelName", vfModuleMetadata.getVfModuleModelName());
+ assertEquals("vfModuleModelUUID", vfModuleMetadata.getVfModuleModelUUID());
+ assertEquals("vfModuleModelVersion", vfModuleMetadata.getVfModuleModelVersion());
+ assertEquals(true, vfModuleMetadata.isBase());
+ assertEquals(null, vfModuleMetadata.getArtifacts());
+ assertEquals(new HashMap<String, String>(), vfModuleMetadata.getProperties());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/NotificationDataImplTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/NotificationDataImplTest.java
index b1524e015f..94ba54db29 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/NotificationDataImplTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/NotificationDataImplTest.java
@@ -21,39 +21,38 @@
package org.onap.so.asdc.client.test.emulators;
import static org.junit.Assert.assertEquals;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.mockito.Mock;
import org.onap.so.asdc.BaseTest;
import org.springframework.beans.factory.annotation.Autowired;
public class NotificationDataImplTest extends BaseTest {
- @Autowired
- private NotificationDataImpl notificationDataImpl;
-
- @Mock
- private ArtifactInfoImpl artifactInfoImpl;
-
- private static final String NOTIFICATION_DATA_IMPL_STRING = "NotificationDataImpl [distributionID=distributionID, serviceName=serviceName, "
- + "serviceVersion=serviceVersion, serviceUUID=serviceUUID, serviceDescription=serviceDescription, "
- + "serviceInvariantUUID=serviceInvariantUUID, resources=null, serviceArtifacts=[artifactInfoImpl], workloadContext=workloadContext]";
-
- @Test
- public void toStringTest() {
- List<ArtifactInfoImpl> relevantServiceArtifacts = new ArrayList<ArtifactInfoImpl>();
- relevantServiceArtifacts.add(artifactInfoImpl);
- notificationDataImpl.setDistributionID("distributionID");
- notificationDataImpl.setServiceName("serviceName");
- notificationDataImpl.setServiceVersion("serviceVersion");
- notificationDataImpl.setServiceDescription("serviceDescription");
- notificationDataImpl.setServiceUUID("serviceUUID");
- notificationDataImpl.setServiceInvariantUUID("serviceInvariantUUID");
- notificationDataImpl.setWorkloadContext("workloadContext");
- notificationDataImpl.setServiceArtifacts(relevantServiceArtifacts);
-
- assertEquals(NOTIFICATION_DATA_IMPL_STRING, notificationDataImpl.toString());
- }
+ @Autowired
+ private NotificationDataImpl notificationDataImpl;
+
+ @Mock
+ private ArtifactInfoImpl artifactInfoImpl;
+
+ private static final String NOTIFICATION_DATA_IMPL_STRING =
+ "NotificationDataImpl [distributionID=distributionID, serviceName=serviceName, "
+ + "serviceVersion=serviceVersion, serviceUUID=serviceUUID, serviceDescription=serviceDescription, "
+ + "serviceInvariantUUID=serviceInvariantUUID, resources=null, serviceArtifacts=[artifactInfoImpl], workloadContext=workloadContext]";
+
+ @Test
+ public void toStringTest() {
+ List<ArtifactInfoImpl> relevantServiceArtifacts = new ArrayList<ArtifactInfoImpl>();
+ relevantServiceArtifacts.add(artifactInfoImpl);
+ notificationDataImpl.setDistributionID("distributionID");
+ notificationDataImpl.setServiceName("serviceName");
+ notificationDataImpl.setServiceVersion("serviceVersion");
+ notificationDataImpl.setServiceDescription("serviceDescription");
+ notificationDataImpl.setServiceUUID("serviceUUID");
+ notificationDataImpl.setServiceInvariantUUID("serviceInvariantUUID");
+ notificationDataImpl.setWorkloadContext("workloadContext");
+ notificationDataImpl.setServiceArtifacts(relevantServiceArtifacts);
+
+ assertEquals(NOTIFICATION_DATA_IMPL_STRING, notificationDataImpl.toString());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImplTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImplTest.java
index 423661770b..47662daab7 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImplTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImplTest.java
@@ -22,30 +22,28 @@ package org.onap.so.asdc.client.test.emulators;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.mockito.Mock;
import org.onap.sdc.api.notification.IResourceInstance;
import org.onap.so.asdc.BaseTest;
public class ResourceInfoImplTest extends BaseTest {
- @Mock
- private IResourceInstance iResourceInstance;
-
- @Test
- public void convertToJsonContainerTest() {
- List<IResourceInstance> resources = new ArrayList<IResourceInstance>();
- resources.add(iResourceInstance);
- ResourceInfoImpl.convertToJsonContainer(resources);
-
- assertEquals(1, ResourceInfoImpl.convertToJsonContainer(resources).size());
- }
-
- @Test
- public void convertToJsonContainerNullListTest() {
- assertTrue(ResourceInfoImpl.convertToJsonContainer(null).isEmpty());
- }
+ @Mock
+ private IResourceInstance iResourceInstance;
+
+ @Test
+ public void convertToJsonContainerTest() {
+ List<IResourceInstance> resources = new ArrayList<IResourceInstance>();
+ resources.add(iResourceInstance);
+ ResourceInfoImpl.convertToJsonContainer(resources);
+
+ assertEquals(1, ResourceInfoImpl.convertToJsonContainer(resources).size());
+ }
+
+ @Test
+ public void convertToJsonContainerNullListTest() {
+ assertTrue(ResourceInfoImpl.convertToJsonContainer(null).isEmpty());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
index 947da4f492..815f419c40 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
@@ -27,14 +27,11 @@ import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-
import java.io.File;
import java.util.HashSet;
import java.util.Set;
-
import javax.transaction.Transactional;
import javax.ws.rs.core.Response;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -55,105 +52,103 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-
import com.fasterxml.jackson.databind.ObjectMapper;
public class ASDCRestInterfaceTest extends BaseTest {
- @Autowired
- private AllottedResourceRepository allottedRepo;
-
- @Autowired
- private ServiceRepository serviceRepo;
-
- @Autowired
- private NetworkResourceRepository networkRepo;
-
- @Autowired
- private ASDCRestInterface asdcRestInterface;
-
- private TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
-
- private HttpHeaders headers = new HttpHeaders();
-
- @Spy
- DistributionClientEmulator spyClient = new DistributionClientEmulator();
-
- @LocalServerPort
- private int port;
-
-
- @Rule
- public TemporaryFolder folder= new TemporaryFolder();
-
-
- @Before
- public void setUp() {
- //ASDC Controller writes to this path
- System.setProperty("mso.config.path", folder.getRoot().toString());
- }
-
- @Test
- @Transactional
- public void testAllottedResourceService() throws Exception {
-
- wireMockServer.stubFor(post(urlPathMatching("/aai/.*"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")));
-
- ObjectMapper mapper = new ObjectMapper();
- NotificationDataImpl request = mapper.readValue(new File("src/test/resources/resource-examples/allottedresource/notif-portm.json"), NotificationDataImpl.class);
- headers.add("resource-location", "src/test/resources/resource-examples/allottedresource/");
- HttpEntity<NotificationDataImpl> entity = new HttpEntity<NotificationDataImpl>(request, headers);
-
- ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"), HttpMethod.POST,
- entity, String.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
-
- AllottedResource expectedService = new AllottedResource();
- expectedService.setDescription("rege1802pnf");
- expectedService.setModelInvariantUUID("b8f83c3f-077c-4e2c-b489-c66382060436");
- expectedService.setModelName("rege1802pnf");
- expectedService.setModelUUID("5b18c75e-2d08-4bf2-ad58-4ea704ec648d");
- expectedService.setModelVersion("1.0");
- expectedService.setSubcategory("Contrail Route");
- expectedService.setToscaNodeType("org.openecomp.resource.pnf.Rege1802pnf");
- Set<AllottedResourceCustomization> arCustomizationSet = new HashSet<AllottedResourceCustomization>();
- AllottedResourceCustomization arCustomization = new AllottedResourceCustomization();
- arCustomization.setModelCustomizationUUID("f62bb612-c5d4-4406-865c-0abec30631ba");
- arCustomization.setModelInstanceName("rege1802pnf 0");
- arCustomizationSet.add(arCustomization);
-
- arCustomization.setAllottedResource(expectedService);
-
-
- expectedService.setAllotedResourceCustomization(arCustomizationSet);
-
- AllottedResource actualResponse = allottedRepo.findResourceByModelUUID("5b18c75e-2d08-4bf2-ad58-4ea704ec648d");
-
-
- if(actualResponse == null)
- throw new Exception("No Allotted Resource Written to database");
-
-
- assertThat(actualResponse, sameBeanAs(expectedService).ignoring("0x1.created").ignoring("0x1.allotedResourceCustomization.created"));
- }
-
- @Test
- public void invokeASDCStatusDataNullTest() {
- String request = "";
- Response response = asdcRestInterface.invokeASDCStatusData(request);
- assertNull(response);
-
- }
-
-
-
-
-
- protected String createURLWithPort(String uri) {
- return "http://localhost:" + port + uri;
- }
+ @Autowired
+ private AllottedResourceRepository allottedRepo;
+
+ @Autowired
+ private ServiceRepository serviceRepo;
+
+ @Autowired
+ private NetworkResourceRepository networkRepo;
+
+ @Autowired
+ private ASDCRestInterface asdcRestInterface;
+
+ private TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
+
+ private HttpHeaders headers = new HttpHeaders();
+
+ @Spy
+ DistributionClientEmulator spyClient = new DistributionClientEmulator();
+
+ @LocalServerPort
+ private int port;
+
+
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder();
+
+
+ @Before
+ public void setUp() {
+ // ASDC Controller writes to this path
+ System.setProperty("mso.config.path", folder.getRoot().toString());
+ }
+
+ @Test
+ @Transactional
+ public void testAllottedResourceService() throws Exception {
+
+ wireMockServer.stubFor(post(urlPathMatching("/aai/.*"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")));
+
+ ObjectMapper mapper = new ObjectMapper();
+ NotificationDataImpl request =
+ mapper.readValue(new File("src/test/resources/resource-examples/allottedresource/notif-portm.json"),
+ NotificationDataImpl.class);
+ headers.add("resource-location", "src/test/resources/resource-examples/allottedresource/");
+ HttpEntity<NotificationDataImpl> entity = new HttpEntity<NotificationDataImpl>(request, headers);
+
+ ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"),
+ HttpMethod.POST, entity, String.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+
+ AllottedResource expectedService = new AllottedResource();
+ expectedService.setDescription("rege1802pnf");
+ expectedService.setModelInvariantUUID("b8f83c3f-077c-4e2c-b489-c66382060436");
+ expectedService.setModelName("rege1802pnf");
+ expectedService.setModelUUID("5b18c75e-2d08-4bf2-ad58-4ea704ec648d");
+ expectedService.setModelVersion("1.0");
+ expectedService.setSubcategory("Contrail Route");
+ expectedService.setToscaNodeType("org.openecomp.resource.pnf.Rege1802pnf");
+ Set<AllottedResourceCustomization> arCustomizationSet = new HashSet<AllottedResourceCustomization>();
+ AllottedResourceCustomization arCustomization = new AllottedResourceCustomization();
+ arCustomization.setModelCustomizationUUID("f62bb612-c5d4-4406-865c-0abec30631ba");
+ arCustomization.setModelInstanceName("rege1802pnf 0");
+ arCustomizationSet.add(arCustomization);
+
+ arCustomization.setAllottedResource(expectedService);
+
+
+ expectedService.setAllotedResourceCustomization(arCustomizationSet);
+
+ AllottedResource actualResponse = allottedRepo.findResourceByModelUUID("5b18c75e-2d08-4bf2-ad58-4ea704ec648d");
+
+
+ if (actualResponse == null)
+ throw new Exception("No Allotted Resource Written to database");
+
+
+ assertThat(actualResponse, sameBeanAs(expectedService).ignoring("0x1.created")
+ .ignoring("0x1.allotedResourceCustomization.created"));
+ }
+
+ @Test
+ public void invokeASDCStatusDataNullTest() {
+ String request = "";
+ Response response = asdcRestInterface.invokeASDCStatusData(request);
+ assertNull(response);
+
+ }
+
+
+
+ protected String createURLWithPort(String uri) {
+ return "http://localhost:" + port + uri;
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/HealthCheckTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/HealthCheckTest.java
index cd2c3ee7e6..adc55937b6 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/HealthCheckTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/HealthCheckTest.java
@@ -38,28 +38,27 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
public class HealthCheckTest extends BaseTest {
-
- @LocalServerPort
- private int port;
- TestRestTemplate restTemplate = new TestRestTemplate();
+ @LocalServerPort
+ private int port;
- HttpHeaders headers = new HttpHeaders();
-
- @Test
- public void testHealthcheck() throws JSONException {
+ TestRestTemplate restTemplate = new TestRestTemplate();
- HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+ HttpHeaders headers = new HttpHeaders();
- ResponseEntity<String> response = restTemplate.exchange(
- createURLWithPort("/manage/health"),
- HttpMethod.GET, entity, String.class);
-
- assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
- }
-
- private String createURLWithPort(String uri) {
- return "http://localhost:" + port + uri;
- }
+ @Test
+ public void testHealthcheck() throws JSONException {
+
+ HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+
+ ResponseEntity<String> response =
+ restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+ }
+
+ private String createURLWithPort(String uri) {
+ return "http://localhost:" + port + uri;
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/tests/ASDCConfigurationTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/tests/ASDCConfigurationTest.java
index db797cff29..992d495369 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/tests/ASDCConfigurationTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/tests/ASDCConfigurationTest.java
@@ -24,12 +24,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import java.util.ArrayList;
import java.util.List;
-
import javax.transaction.Transactional;
-
import org.junit.Test;
import org.onap.so.asdc.BaseTest;
import org.onap.so.asdc.client.ASDCConfiguration;
@@ -42,111 +39,111 @@ import org.springframework.beans.factory.annotation.Autowired;
*/
@Transactional
public class ASDCConfigurationTest extends BaseTest {
-
+
@Autowired
private ASDCConfiguration config;
-
+
private List<String> msgBusAddressList = new ArrayList<String>();
-
+
private static final String MSO_PRE_IST = "msopreist";
private static final String MSO_ASDC_ID_LOCAL = "msoasdc-id-local";
private static final String PRE_IST = "Pre-IST";
private static final String ASDC_ADDRESS = "localhost:8443";
-
+
@Test
public void isUseHttpsWithDmaapTest() {
- assertTrue(config.isUseHttpsWithDmaap());
+ assertTrue(config.isUseHttpsWithDmaap());
}
-
+
@Test
public void isConsumeProduceStatusTopicTest() {
- assertTrue(config.isConsumeProduceStatusTopic());
+ assertTrue(config.isConsumeProduceStatusTopic());
}
-
+
@Test
public void getUserTest() {
- assertTrue(MSO_PRE_IST.equals(config.getUser()));
+ assertTrue(MSO_PRE_IST.equals(config.getUser()));
}
-
+
@Test
public void getConsumerGroupTest() {
- assertTrue(MSO_ASDC_ID_LOCAL.equals(config.getConsumerGroup()));
+ assertTrue(MSO_ASDC_ID_LOCAL.equals(config.getConsumerGroup()));
}
-
+
@Test
public void getConsumerIDTest() {
- assertTrue(MSO_ASDC_ID_LOCAL.equals(config.getConsumerID()));
+ assertTrue(MSO_ASDC_ID_LOCAL.equals(config.getConsumerID()));
}
-
+
@Test
public void getEnvironmentNameTest() {
- assertTrue(PRE_IST.equals(config.getEnvironmentName()));
+ assertTrue(PRE_IST.equals(config.getEnvironmentName()));
}
-
+
@Test
public void getAsdcAddress() {
- assertTrue(ASDC_ADDRESS.equals(config.getAsdcAddress()));
+ assertTrue(ASDC_ADDRESS.equals(config.getAsdcAddress()));
}
-
+
@Test
public void getPasswordTest() {
- assertTrue(MSO_PRE_IST.equals(config.getPassword()));
+ assertTrue(MSO_PRE_IST.equals(config.getPassword()));
}
-
+
@Test
public void getPollingIntervalTest() {
- assertTrue(config.getPollingInterval() == 30);
+ assertTrue(config.getPollingInterval() == 30);
}
-
+
@Test
public void getPollingTimeoutTest() {
- assertTrue(config.getPollingTimeout() == 30);
+ assertTrue(config.getPollingTimeout() == 30);
}
-
+
@Test
public void getRelevantArtifactTypesTest() {
- assertTrue(config.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size());
+ assertTrue(config.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size());
}
-
+
@Test
public void getWatchDogTimeoutTest() {
- assertTrue(config.getWatchDogTimeout() == 1);
+ assertTrue(config.getWatchDogTimeout() == 1);
}
-
+
@Test
public void activateServerTLSAuthTest() {
- assertFalse(config.activateServerTLSAuth());
+ assertFalse(config.activateServerTLSAuth());
}
-
+
@Test
public void getKeyStorePasswordTest() {
- assertNull(config.getKeyStorePassword());
+ assertNull(config.getKeyStorePassword());
}
-
+
@Test
public void getKeyStorePathTest() {
- assertNull(config.getKeyStorePath());
+ assertNull(config.getKeyStorePath());
}
-
+
@Test
public void isFilterInEmptyResourcesTest() {
- assertTrue(config.isFilterInEmptyResources());
+ assertTrue(config.isFilterInEmptyResources());
}
-
+
@Test
public void setGetAsdcControllerNameTest() {
- String asdcControllerName = "testAsdcControllerName";
- config.setAsdcControllerName(asdcControllerName);
- String actualAsdcControllerName = config.getAsdcControllerName();
- assertEquals(asdcControllerName, actualAsdcControllerName);
+ String asdcControllerName = "testAsdcControllerName";
+ config.setAsdcControllerName(asdcControllerName);
+ String actualAsdcControllerName = config.getAsdcControllerName();
+ assertEquals(asdcControllerName, actualAsdcControllerName);
}
-
+
@Test
public void getMsgBusAddressTest() {
- msgBusAddressList.add("localhost");
- msgBusAddressList.add("localhost");
-
- List<String> actualMsgBusAddress = config.getMsgBusAddress();
- assertEquals(msgBusAddressList, actualMsgBusAddress);
+ msgBusAddressList.add("localhost");
+ msgBusAddressList.add("localhost");
+
+ List<String> actualMsgBusAddress = config.getMsgBusAddress();
+ assertEquals(msgBusAddressList, actualMsgBusAddress);
}
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java
index 1e8b72d145..d3990b9e7d 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java
@@ -26,10 +26,8 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
-
import java.util.ArrayList;
import java.util.HashMap;
-
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -50,84 +48,89 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
public class ToscaResourceStructureTest {
- private ArtifactInfoImpl artifactInfo;
- private SdcCsarHelperImpl sdcCsarHelper;
-
- private ToscaResourceStructure toscaResourceStructure;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Test
- public void toscaResourceStructureBeanTest() {
- artifactInfo = mock(ArtifactInfoImpl.class);
- sdcCsarHelper = mock(SdcCsarHelperImpl.class);
-
- toscaResourceStructure = new ToscaResourceStructure();
- toscaResourceStructure.setHeatTemplateUUID("heatTemplateUUID");
- toscaResourceStructure.setAllottedList(new ArrayList<NodeTemplate>());
- toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
- toscaResourceStructure.setServiceMetadata(new Metadata(new HashMap<>()));
- toscaResourceStructure.setCatalogService(new Service());
- toscaResourceStructure.setNetworkTypes(new ArrayList<>());
- toscaResourceStructure.setVfTypes(new ArrayList<>());
- toscaResourceStructure.setCatalogResourceCustomization(new AllottedResourceCustomization());
- toscaResourceStructure.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
- toscaResourceStructure.setCatalogNetworkResource(new NetworkResource());
- toscaResourceStructure.setCatalogVfModule(new VfModule());
- toscaResourceStructure.setVnfResourceCustomization(new VnfResourceCustomization());
- toscaResourceStructure.setVfModuleCustomization(new VfModuleCustomization());
- toscaResourceStructure.setAllottedResource(new AllottedResource());
- toscaResourceStructure.setAllottedResourceCustomization(new AllottedResourceCustomization());
- toscaResourceStructure.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
- toscaResourceStructure.setHeatFilesUUID("heatFilesUUID");
- toscaResourceStructure.setToscaArtifact(artifactInfo);
- toscaResourceStructure.setToscaCsar(new ToscaCsar());
- toscaResourceStructure.setVolHeatTemplateUUID("volHeatTemplateUUID");
- toscaResourceStructure.setEnvHeatTemplateUUID("envHeatTemplateUUID");
- toscaResourceStructure.setServiceVersion("serviceVersion");
- toscaResourceStructure.setWorkloadPerformance("workloadPerformance");
- toscaResourceStructure.setVfModule(new VfModule());
- toscaResourceStructure.setTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
- toscaResourceStructure.setSuccessfulDeployment();
-
- assertEquals("heatTemplateUUID", toscaResourceStructure.getHeatTemplateUUID());
- assertThat(toscaResourceStructure.getAllottedList(), sameBeanAs(new ArrayList<NodeTemplate>()));
- assertEquals(sdcCsarHelper, toscaResourceStructure.getSdcCsarHelper());
- assertThat(toscaResourceStructure.getServiceMetadata(), sameBeanAs(new Metadata(new HashMap<>())));
- assertThat(toscaResourceStructure.getCatalogService(), sameBeanAs(new Service()));
- assertThat(toscaResourceStructure.getNetworkTypes(), sameBeanAs(new ArrayList<>()));
- assertThat(toscaResourceStructure.getVfTypes(), sameBeanAs(new ArrayList<>()));
- assertThat(toscaResourceStructure.getCatalogResourceCustomization(), sameBeanAs(new AllottedResourceCustomization()));
- assertThat(toscaResourceStructure.getCatalogNetworkResourceCustomization(), sameBeanAs(new NetworkResourceCustomization()));
- assertThat(toscaResourceStructure.getCatalogNetworkResource(), sameBeanAs(new NetworkResource()));
- assertThat(toscaResourceStructure.getCatalogVfModule(), sameBeanAs(new VfModule()));
- assertThat(toscaResourceStructure.getVnfResourceCustomization(), sameBeanAs(new VnfResourceCustomization()));
- assertThat(toscaResourceStructure.getVfModuleCustomization(), sameBeanAs(new VfModuleCustomization()));
- assertThat(toscaResourceStructure.getAllottedResource(), sameBeanAs(new AllottedResource()));
- assertThat(toscaResourceStructure.getAllottedResourceCustomization(), sameBeanAs(new AllottedResourceCustomization()));
- assertThat(toscaResourceStructure.getCatalogTempNetworkHeatTemplateLookup(), sameBeanAs(new TempNetworkHeatTemplateLookup()));
- assertEquals("heatFilesUUID", toscaResourceStructure.getHeatFilesUUID());
- assertEquals(artifactInfo, toscaResourceStructure.getToscaArtifact());
- assertThat(toscaResourceStructure.getToscaCsar(), sameBeanAs(new ToscaCsar()));
- assertEquals("volHeatTemplateUUID", toscaResourceStructure.getVolHeatTemplateUUID());
- assertEquals("envHeatTemplateUUID", toscaResourceStructure.getEnvHeatTemplateUUID());
- assertEquals("serviceVersion", toscaResourceStructure.getServiceVersion());
- assertEquals("workloadPerformance", toscaResourceStructure.getWorkloadPerformance());
- assertThat(toscaResourceStructure.getVfModule(), sameBeanAs(new VfModule()));
- assertThat(toscaResourceStructure.getTempNetworkHeatTemplateLookup(), sameBeanAs(new TempNetworkHeatTemplateLookup()));
- assertEquals(true, toscaResourceStructure.isDeployedSuccessfully());
- }
-
- @Test
- public void updateResourceStructureExceptionTest() throws Exception {
- expectedException.expect(ASDCDownloadException.class);
-
- artifactInfo = mock(ArtifactInfoImpl.class);
- toscaResourceStructure = new ToscaResourceStructure();
+ private ArtifactInfoImpl artifactInfo;
+ private SdcCsarHelperImpl sdcCsarHelper;
+
+ private ToscaResourceStructure toscaResourceStructure;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void toscaResourceStructureBeanTest() {
+ artifactInfo = mock(ArtifactInfoImpl.class);
+ sdcCsarHelper = mock(SdcCsarHelperImpl.class);
+
+ toscaResourceStructure = new ToscaResourceStructure();
+ toscaResourceStructure.setHeatTemplateUUID("heatTemplateUUID");
+ toscaResourceStructure.setAllottedList(new ArrayList<NodeTemplate>());
+ toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
+ toscaResourceStructure.setServiceMetadata(new Metadata(new HashMap<>()));
+ toscaResourceStructure.setCatalogService(new Service());
+ toscaResourceStructure.setNetworkTypes(new ArrayList<>());
+ toscaResourceStructure.setVfTypes(new ArrayList<>());
+ toscaResourceStructure.setCatalogResourceCustomization(new AllottedResourceCustomization());
+ toscaResourceStructure.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
+ toscaResourceStructure.setCatalogNetworkResource(new NetworkResource());
+ toscaResourceStructure.setCatalogVfModule(new VfModule());
+ toscaResourceStructure.setVnfResourceCustomization(new VnfResourceCustomization());
+ toscaResourceStructure.setVfModuleCustomization(new VfModuleCustomization());
+ toscaResourceStructure.setAllottedResource(new AllottedResource());
+ toscaResourceStructure.setAllottedResourceCustomization(new AllottedResourceCustomization());
+ toscaResourceStructure.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
+ toscaResourceStructure.setHeatFilesUUID("heatFilesUUID");
+ toscaResourceStructure.setToscaArtifact(artifactInfo);
+ toscaResourceStructure.setToscaCsar(new ToscaCsar());
+ toscaResourceStructure.setVolHeatTemplateUUID("volHeatTemplateUUID");
+ toscaResourceStructure.setEnvHeatTemplateUUID("envHeatTemplateUUID");
+ toscaResourceStructure.setServiceVersion("serviceVersion");
+ toscaResourceStructure.setWorkloadPerformance("workloadPerformance");
+ toscaResourceStructure.setVfModule(new VfModule());
+ toscaResourceStructure.setTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
+ toscaResourceStructure.setSuccessfulDeployment();
+
+ assertEquals("heatTemplateUUID", toscaResourceStructure.getHeatTemplateUUID());
+ assertThat(toscaResourceStructure.getAllottedList(), sameBeanAs(new ArrayList<NodeTemplate>()));
+ assertEquals(sdcCsarHelper, toscaResourceStructure.getSdcCsarHelper());
+ assertThat(toscaResourceStructure.getServiceMetadata(), sameBeanAs(new Metadata(new HashMap<>())));
+ assertThat(toscaResourceStructure.getCatalogService(), sameBeanAs(new Service()));
+ assertThat(toscaResourceStructure.getNetworkTypes(), sameBeanAs(new ArrayList<>()));
+ assertThat(toscaResourceStructure.getVfTypes(), sameBeanAs(new ArrayList<>()));
+ assertThat(toscaResourceStructure.getCatalogResourceCustomization(),
+ sameBeanAs(new AllottedResourceCustomization()));
+ assertThat(toscaResourceStructure.getCatalogNetworkResourceCustomization(),
+ sameBeanAs(new NetworkResourceCustomization()));
+ assertThat(toscaResourceStructure.getCatalogNetworkResource(), sameBeanAs(new NetworkResource()));
+ assertThat(toscaResourceStructure.getCatalogVfModule(), sameBeanAs(new VfModule()));
+ assertThat(toscaResourceStructure.getVnfResourceCustomization(), sameBeanAs(new VnfResourceCustomization()));
+ assertThat(toscaResourceStructure.getVfModuleCustomization(), sameBeanAs(new VfModuleCustomization()));
+ assertThat(toscaResourceStructure.getAllottedResource(), sameBeanAs(new AllottedResource()));
+ assertThat(toscaResourceStructure.getAllottedResourceCustomization(),
+ sameBeanAs(new AllottedResourceCustomization()));
+ assertThat(toscaResourceStructure.getCatalogTempNetworkHeatTemplateLookup(),
+ sameBeanAs(new TempNetworkHeatTemplateLookup()));
+ assertEquals("heatFilesUUID", toscaResourceStructure.getHeatFilesUUID());
+ assertEquals(artifactInfo, toscaResourceStructure.getToscaArtifact());
+ assertThat(toscaResourceStructure.getToscaCsar(), sameBeanAs(new ToscaCsar()));
+ assertEquals("volHeatTemplateUUID", toscaResourceStructure.getVolHeatTemplateUUID());
+ assertEquals("envHeatTemplateUUID", toscaResourceStructure.getEnvHeatTemplateUUID());
+ assertEquals("serviceVersion", toscaResourceStructure.getServiceVersion());
+ assertEquals("workloadPerformance", toscaResourceStructure.getWorkloadPerformance());
+ assertThat(toscaResourceStructure.getVfModule(), sameBeanAs(new VfModule()));
+ assertThat(toscaResourceStructure.getTempNetworkHeatTemplateLookup(),
+ sameBeanAs(new TempNetworkHeatTemplateLookup()));
+ assertEquals(true, toscaResourceStructure.isDeployedSuccessfully());
+ }
+
+ @Test
+ public void updateResourceStructureExceptionTest() throws Exception {
+ expectedException.expect(ASDCDownloadException.class);
+
+ artifactInfo = mock(ArtifactInfoImpl.class);
+ toscaResourceStructure = new ToscaResourceStructure();
+
+ doReturn("artifactName").when(artifactInfo).getArtifactName();
- doReturn("artifactName").when(artifactInfo).getArtifactName();
-
- toscaResourceStructure.updateResourceStructure(artifactInfo);
- }
+ toscaResourceStructure.updateResourceStructure(artifactInfo);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java
index e780a259ea..6efb04fc35 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java
@@ -32,7 +32,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -77,27 +76,26 @@ public class BpmnInstallerTest {
public static void cleanup() {
System.clearProperty("mso.config.path");
}
-
+
@Test
public void buildMimeMultiPart_Test() throws Exception {
- Path tempFilePath = Paths.get(tempDirectoryPath.toAbsolutePath().toString(), "TestBB.bpmn");
- Files.createFile(tempFilePath);
- HttpEntity entity = bpmnInstaller.buildMimeMultipart("TestBB.bpmn");
- String mimeMultipartBodyFilePath = "src/test/resources" + "/mime-multipart-body.txt";
-
- File mimeMultipartBody = new File(mimeMultipartBodyFilePath);
- InputStream expectedContent = new FileInputStream(mimeMultipartBody);
-
- assertThat(IOUtils.contentEquals(expectedContent, entity.getContent()));
-
- IOUtils.closeQuietly(expectedContent);
+ Path tempFilePath = Paths.get(tempDirectoryPath.toAbsolutePath().toString(), "TestBB.bpmn");
+ Files.createFile(tempFilePath);
+ HttpEntity entity = bpmnInstaller.buildMimeMultipart("TestBB.bpmn");
+ String mimeMultipartBodyFilePath = "src/test/resources" + "/mime-multipart-body.txt";
+
+ File mimeMultipartBody = new File(mimeMultipartBodyFilePath);
+ InputStream expectedContent = new FileInputStream(mimeMultipartBody);
+
+ assertThat(IOUtils.contentEquals(expectedContent, entity.getContent()));
+
+ IOUtils.closeQuietly(expectedContent);
}
@Test
public void installBpmn_Test() throws Exception {
BpmnInstaller bpmnInstallerSpy = spy(bpmnInstaller);
- HttpResponse response = new BasicHttpResponse(
- new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, ""));
+ HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, ""));
HttpClient httpClient = mock(HttpClient.class);
doReturn(response).when(httpClient).execute(any(HttpPost.class));
bpmnInstallerSpy.installBpmn(TEST_CSAR);
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
index bc9275bb51..844adeede2 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
@@ -33,12 +33,10 @@ import org.onap.sdc.toscaparser.api.parameters.Input;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
import org.onap.so.asdc.installer.ToscaResourceStructure;
import org.onap.so.db.catalog.beans.Service;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
-
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
index e4eb09782a..99833da3a3 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
@@ -30,11 +30,9 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-
import org.hibernate.exception.LockAcquisitionException;
import org.junit.Before;
import org.junit.Rule;
@@ -69,310 +67,319 @@ import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatu
import org.springframework.beans.factory.annotation.Autowired;
public class ToscaResourceInstallerTest extends BaseTest {
- @Autowired
- private ToscaResourceInstaller toscaInstaller;
- @Autowired
- private WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
- @Autowired
- private AllottedResourceRepository allottedRepo;
- @Autowired
- private AllottedResourceCustomizationRepository allottedCustomizationRepo;
- @Autowired
- private ServiceRepository serviceRepo;
- @Mock
- private SdcCsarHelperImpl sdcCsarHelper;
- @Mock
- private Metadata metadata;
- @Mock
- private ArtifactInfoImpl artifactInfo;
- @Mock
- private List<Group> vfGroups;
- @Mock
- private IResourceInstance resourceInstance;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
- @Mock
- private NodeTemplate nodeTemplate;
- @Mock
- private ToscaResourceStructure toscaResourceStructure;
- @Mock
- private ServiceProxyResourceCustomization spResourceCustomization;
- @Mock
- private ISdcCsarHelper csarHelper;
- @Mock
- private StatefulEntityType entityType;
-
- private NotificationDataImpl notificationData;
- private JsonStatusData statusData;
- private static final String MSO = "SO";
-
- @Before
- public void before() {
- MockitoAnnotations.initMocks(this);
-
- notificationData = new NotificationDataImpl();
- statusData = new JsonStatusData();
- }
-
- @Test
- public void isResourceAlreadyDeployedTest() throws Exception {
- notificationData.setServiceName("serviceName");
- notificationData.setServiceVersion("123456");
- notificationData.setServiceUUID("serviceUUID");
- notificationData.setDistributionID("testStatusSuccessTosca");
-
- WatchdogComponentDistributionStatus expectedComponentDistributionStatus =
- new WatchdogComponentDistributionStatus(notificationData.getDistributionID(), MSO);
- expectedComponentDistributionStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
-
- doReturn(true).when(vfResourceStructure).isDeployedSuccessfully();
- doReturn(notificationData).when(vfResourceStructure).getNotification();
- doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
- doReturn("resourceInstanceName").when(resourceInstance).getResourceInstanceName();
- doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
- doReturn("resourceName").when(resourceInstance).getResourceName();
-
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
-
- WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = getWatchdogCDStatusWithName(watchdogCDStatusRepository.findByDistributionId(notificationData.getDistributionID()), MSO);
-
- verify(vfResourceStructure, times(3)).getResourceInstance();
- verify(vfResourceStructure, times(5)).getNotification();
- assertThat(actualWatchdogComponentDistributionStatus, sameBeanAs(expectedComponentDistributionStatus)
- .ignoring("createTime")
- .ignoring("modifyTime"));
- }
-
- @Test
- public void isResourceAlreadyDeployedFalseTest() throws Exception {
- notificationData.setServiceName("serviceName");
- notificationData.setServiceVersion("123456");
- notificationData.setServiceUUID("serviceUUID");
- notificationData.setDistributionID("testStatusSuccess");
-
- doThrow(RuntimeException.class).when(vfResourceStructure).isDeployedSuccessfully();
- doReturn(notificationData).when(vfResourceStructure).getNotification();
- doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
- doReturn("resourceInstanceName").when(resourceInstance).getResourceInstanceName();
- doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
- doReturn("resourceName").when(resourceInstance).getResourceName();
-
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
-
- verify(vfResourceStructure, times(3)).getResourceInstance();
- verify(vfResourceStructure, times(4)).getNotification();
- }
-
- @Test
- public void isResourceAlreadyDeployedExceptionTest() throws ArtifactInstallerException {
- expectedException.expect(ArtifactInstallerException.class);
-
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
- }
-
- @Test
- public void installTheComponentStatusTest() throws Exception {
- String distributionId = "testStatusSuccessTosca";
- String componentName = "testComponentName";
-
- statusData = spy(JsonStatusData.class);
- doReturn(distributionId).when(statusData).getDistributionID();
- doReturn(componentName).when(statusData).getComponentName();
-
- WatchdogComponentDistributionStatus expectedWatchdogComponentDistributionStatus =
- new WatchdogComponentDistributionStatus(distributionId, componentName);
- expectedWatchdogComponentDistributionStatus.setComponentDistributionStatus(statusData.getStatus().toString());
-
- WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(statusData.getDistributionID(),
- statusData.getComponentName());
-
- toscaInstaller.installTheComponentStatus(statusData);
-
- WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = getWatchdogCDStatusWithName(watchdogCDStatusRepository.findByDistributionId("testStatusSuccessTosca"), statusData.getComponentName());
-
- assertEquals(statusData.getDistributionID(), cdStatus.getDistributionId());
- assertEquals(statusData.getComponentName(), cdStatus.getComponentName());
- assertThat(actualWatchdogComponentDistributionStatus, sameBeanAs(expectedWatchdogComponentDistributionStatus)
- .ignoring("createTime")
- .ignoring("modifyTime"));
- }
-
- @Test
- public void installTheComponentStatusExceptionTest() throws ArtifactInstallerException {
- expectedException.expect(ArtifactInstallerException.class);
-
- statusData = spy(JsonStatusData.class);
- doReturn(null).when(statusData).getStatus();
-
- toscaInstaller.installTheComponentStatus(statusData);
- }
-
- @Test
- public void installTheResourceExceptionTest() throws Exception {
- expectedException.expect(ArtifactInstallerException.class);
-
- notificationData.setDistributionID("testStatusFailureTosca");
- notificationData.setServiceVersion("123456");
- notificationData.setServiceUUID("serviceUUID");
- notificationData.setWorkloadContext("workloadContext");
-
- doReturn(notificationData).when(vfResourceStructure).getNotification();
- doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
-
- toscaInstaller.installTheResource(toscaResourceStruct, vfResourceStructure);
- }
-
- @Test
- public void installTheResourceDBExceptionTest() throws Exception {
- notificationData.setDistributionID("testStatusSuccessTosca");
- notificationData.setServiceVersion("123456");
- notificationData.setServiceUUID("serviceUUID");
- notificationData.setWorkloadContext("workloadContext");
-
- doReturn(notificationData).when(vfResourceStructure).getNotification();
- doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
- doThrow(LockAcquisitionException.class).when(toscaResourceStruct).getToscaArtifact();
-
- toscaInstaller.installTheResource(toscaResourceStruct, vfResourceStructure);
- }
-
- @Test
- public void verifyTheFilePrefixInStringTest() {
- String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
- String filenameToVerify = "testfile.txt";
- String expectedFileBody = "abcabcabctestfile.txtabcbabacbcabc";
-
- String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
-
- assertEquals(expectedFileBody, newFileBody);
- }
-
- @Test
- public void verifyTheFilePrefixInStringNullBodyTest() {
- String body = null;
- String filenameToVerify = "testfile.txt";
-
- String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
-
- assertEquals(body, newFileBody);
- }
-
- @Test
- public void verifyTheFilePrefixInStringEmptyBodyTest() {
- String body = "";
- String filenameToVerify = "testfile.txt";
-
- String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
-
- assertEquals(body, newFileBody);
- }
-
- @Test
- public void verifyTheFilePrefixInStringNullFilenameTest() {
- String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
- String filenameToVerify = null;
-
- String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
-
- assertEquals(body, newFileBody);
- }
-
- @Test
- public void verifyTheFilePrefixInStringEmptyFilenameTest() {
- String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
- String filenameToVerify = "";
-
- String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
-
- assertEquals(body, newFileBody);
- }
-
- private WatchdogComponentDistributionStatus getWatchdogCDStatusWithName(List<WatchdogComponentDistributionStatus> watchdogComponentDistributionStatuses, String componentName) {
- WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = new WatchdogComponentDistributionStatus();
- for(WatchdogComponentDistributionStatus watchdogComponentDistributionStatus : watchdogComponentDistributionStatuses) {
- if(componentName.equals(watchdogComponentDistributionStatus.getComponentName())) {
- actualWatchdogComponentDistributionStatus = watchdogComponentDistributionStatus;
- break;
- }
- }
- return actualWatchdogComponentDistributionStatus;
- }
-
-
-
-
- private void prepareConfigurationResource() {
- doReturn(metadata).when(nodeTemplate).getMetaData();
- doReturn(MockConstants.TEMPLATE_TYPE).when(nodeTemplate).getType();
-
- doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
- doReturn(MockConstants.MODEL_INVARIANT_UUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
- doReturn(MockConstants.MODEL_UUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
- doReturn(MockConstants.MODEL_VERSION).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_VERSION);
- doReturn(MockConstants.MODEL_DESCRIPTION).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION);
- doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
- doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
- }
-
- @Test
- public void getConfigurationResourceTest() {
- prepareConfigurationResource();
-
- ConfigurationResource configResource=toscaInstaller.getConfigurationResource(nodeTemplate);
-
- assertNotNull(configResource);
- assertEquals(MockConstants.MODEL_NAME, configResource.getModelName());
- assertEquals(MockConstants.MODEL_INVARIANT_UUID, configResource.getModelInvariantUUID());
- assertEquals(MockConstants.MODEL_UUID, configResource.getModelUUID());
- assertEquals(MockConstants.MODEL_VERSION, configResource.getModelVersion());
- assertEquals(MockConstants.MODEL_DESCRIPTION, configResource.getDescription());
- assertEquals(MockConstants.TEMPLATE_TYPE, nodeTemplate.getType());
- }
-
- private void prepareConfigurationResourceCustomization() {
- prepareConfigurationResource();
- doReturn(MockConstants.MODEL_CUSTOMIZATIONUUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- doReturn(csarHelper).when(toscaResourceStructure).getSdcCsarHelper();
- doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION);
- doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE);
- doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE);
- doReturn(MockConstants.MODEL_CUSTOMIZATIONUUID).when(spResourceCustomization).getModelCustomizationUUID();
- }
-
-
- @Test
- public void getConfigurationResourceCustomizationTest() {
- prepareConfigurationResourceCustomization();
-
- ConfigurationResourceCustomization configurationResourceCustomization = toscaInstaller.getConfigurationResourceCustomization(
- nodeTemplate, toscaResourceStructure, spResourceCustomization);
- assertNotNull(configurationResourceCustomization);
- assertNotNull(configurationResourceCustomization.getConfigurationResource());
- assertEquals(MockConstants.MODEL_CUSTOMIZATIONUUID, configurationResourceCustomization.getServiceProxyResourceCustomizationUUID());
- }
-
- @Test
- public void getVnrNodeTemplateTest() {
- prepareConfigurationResourceCustomization();
- List<NodeTemplate> nodeTemplateList = new ArrayList<>();
- doReturn(ToscaResourceInstaller.VLAN_NETWORK_RECEPTOR).when(entityType).getType();
- doReturn(entityType).when(nodeTemplate).getTypeDefinition();
- nodeTemplateList.add(nodeTemplate);
- Optional<ConfigurationResourceCustomization> vnrResourceCustomization=
- toscaInstaller.getVnrNodeTemplate(nodeTemplateList, toscaResourceStructure, spResourceCustomization);
- assertTrue(vnrResourceCustomization.isPresent());
- assertEquals(ToscaResourceInstaller.VLAN_NETWORK_RECEPTOR, entityType.getType());
- }
-
- class MockConstants{
- public final static String MODEL_NAME = "VLAN Network Receptor Configuration";
- public final static String MODEL_INVARIANT_UUID = "1608eef4-de53-4334-a8d2-ba79cab4bde0";
- public final static String MODEL_UUID = "212ca27b-554c-474c-96b9-ddc2f1b1ddba";
- public final static String MODEL_VERSION = "30.0";
- public final static String MODEL_DESCRIPTION = "VLAN network receptor configuration object";
- public final static String MODEL_CUSTOMIZATIONUUID = "2db953e8-679d-437b-bff7-cb262638a8cd";
- public final static String TEMPLATE_TYPE = "org.openecomp.nodes.VLANNetworkReceptor";
- public final static String TEMPLATE_NAME = "VLAN Network Receptor Configuration 0";
-
- }
+ @Autowired
+ private ToscaResourceInstaller toscaInstaller;
+ @Autowired
+ private WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
+ @Autowired
+ private AllottedResourceRepository allottedRepo;
+ @Autowired
+ private AllottedResourceCustomizationRepository allottedCustomizationRepo;
+ @Autowired
+ private ServiceRepository serviceRepo;
+ @Mock
+ private SdcCsarHelperImpl sdcCsarHelper;
+ @Mock
+ private Metadata metadata;
+ @Mock
+ private ArtifactInfoImpl artifactInfo;
+ @Mock
+ private List<Group> vfGroups;
+ @Mock
+ private IResourceInstance resourceInstance;
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+ @Mock
+ private NodeTemplate nodeTemplate;
+ @Mock
+ private ToscaResourceStructure toscaResourceStructure;
+ @Mock
+ private ServiceProxyResourceCustomization spResourceCustomization;
+ @Mock
+ private ISdcCsarHelper csarHelper;
+ @Mock
+ private StatefulEntityType entityType;
+
+ private NotificationDataImpl notificationData;
+ private JsonStatusData statusData;
+ private static final String MSO = "SO";
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+
+ notificationData = new NotificationDataImpl();
+ statusData = new JsonStatusData();
+ }
+
+ @Test
+ public void isResourceAlreadyDeployedTest() throws Exception {
+ notificationData.setServiceName("serviceName");
+ notificationData.setServiceVersion("123456");
+ notificationData.setServiceUUID("serviceUUID");
+ notificationData.setDistributionID("testStatusSuccessTosca");
+
+ WatchdogComponentDistributionStatus expectedComponentDistributionStatus =
+ new WatchdogComponentDistributionStatus(notificationData.getDistributionID(), MSO);
+ expectedComponentDistributionStatus
+ .setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+
+ doReturn(true).when(vfResourceStructure).isDeployedSuccessfully();
+ doReturn(notificationData).when(vfResourceStructure).getNotification();
+ doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
+ doReturn("resourceInstanceName").when(resourceInstance).getResourceInstanceName();
+ doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
+ doReturn("resourceName").when(resourceInstance).getResourceName();
+
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+
+ WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = getWatchdogCDStatusWithName(
+ watchdogCDStatusRepository.findByDistributionId(notificationData.getDistributionID()), MSO);
+
+ verify(vfResourceStructure, times(3)).getResourceInstance();
+ verify(vfResourceStructure, times(5)).getNotification();
+ assertThat(actualWatchdogComponentDistributionStatus,
+ sameBeanAs(expectedComponentDistributionStatus).ignoring("createTime").ignoring("modifyTime"));
+ }
+
+ @Test
+ public void isResourceAlreadyDeployedFalseTest() throws Exception {
+ notificationData.setServiceName("serviceName");
+ notificationData.setServiceVersion("123456");
+ notificationData.setServiceUUID("serviceUUID");
+ notificationData.setDistributionID("testStatusSuccess");
+
+ doThrow(RuntimeException.class).when(vfResourceStructure).isDeployedSuccessfully();
+ doReturn(notificationData).when(vfResourceStructure).getNotification();
+ doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
+ doReturn("resourceInstanceName").when(resourceInstance).getResourceInstanceName();
+ doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
+ doReturn("resourceName").when(resourceInstance).getResourceName();
+
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+
+ verify(vfResourceStructure, times(3)).getResourceInstance();
+ verify(vfResourceStructure, times(4)).getNotification();
+ }
+
+ @Test
+ public void isResourceAlreadyDeployedExceptionTest() throws ArtifactInstallerException {
+ expectedException.expect(ArtifactInstallerException.class);
+
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+ }
+
+ @Test
+ public void installTheComponentStatusTest() throws Exception {
+ String distributionId = "testStatusSuccessTosca";
+ String componentName = "testComponentName";
+
+ statusData = spy(JsonStatusData.class);
+ doReturn(distributionId).when(statusData).getDistributionID();
+ doReturn(componentName).when(statusData).getComponentName();
+
+ WatchdogComponentDistributionStatus expectedWatchdogComponentDistributionStatus =
+ new WatchdogComponentDistributionStatus(distributionId, componentName);
+ expectedWatchdogComponentDistributionStatus.setComponentDistributionStatus(statusData.getStatus().toString());
+
+ WatchdogComponentDistributionStatus cdStatus =
+ new WatchdogComponentDistributionStatus(statusData.getDistributionID(), statusData.getComponentName());
+
+ toscaInstaller.installTheComponentStatus(statusData);
+
+ WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus =
+ getWatchdogCDStatusWithName(watchdogCDStatusRepository.findByDistributionId("testStatusSuccessTosca"),
+ statusData.getComponentName());
+
+ assertEquals(statusData.getDistributionID(), cdStatus.getDistributionId());
+ assertEquals(statusData.getComponentName(), cdStatus.getComponentName());
+ assertThat(actualWatchdogComponentDistributionStatus,
+ sameBeanAs(expectedWatchdogComponentDistributionStatus).ignoring("createTime").ignoring("modifyTime"));
+ }
+
+ @Test
+ public void installTheComponentStatusExceptionTest() throws ArtifactInstallerException {
+ expectedException.expect(ArtifactInstallerException.class);
+
+ statusData = spy(JsonStatusData.class);
+ doReturn(null).when(statusData).getStatus();
+
+ toscaInstaller.installTheComponentStatus(statusData);
+ }
+
+ @Test
+ public void installTheResourceExceptionTest() throws Exception {
+ expectedException.expect(ArtifactInstallerException.class);
+
+ notificationData.setDistributionID("testStatusFailureTosca");
+ notificationData.setServiceVersion("123456");
+ notificationData.setServiceUUID("serviceUUID");
+ notificationData.setWorkloadContext("workloadContext");
+
+ doReturn(notificationData).when(vfResourceStructure).getNotification();
+ doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
+
+ toscaInstaller.installTheResource(toscaResourceStruct, vfResourceStructure);
+ }
+
+ @Test
+ public void installTheResourceDBExceptionTest() throws Exception {
+ notificationData.setDistributionID("testStatusSuccessTosca");
+ notificationData.setServiceVersion("123456");
+ notificationData.setServiceUUID("serviceUUID");
+ notificationData.setWorkloadContext("workloadContext");
+
+ doReturn(notificationData).when(vfResourceStructure).getNotification();
+ doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
+ doThrow(LockAcquisitionException.class).when(toscaResourceStruct).getToscaArtifact();
+
+ toscaInstaller.installTheResource(toscaResourceStruct, vfResourceStructure);
+ }
+
+ @Test
+ public void verifyTheFilePrefixInStringTest() {
+ String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
+ String filenameToVerify = "testfile.txt";
+ String expectedFileBody = "abcabcabctestfile.txtabcbabacbcabc";
+
+ String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
+
+ assertEquals(expectedFileBody, newFileBody);
+ }
+
+ @Test
+ public void verifyTheFilePrefixInStringNullBodyTest() {
+ String body = null;
+ String filenameToVerify = "testfile.txt";
+
+ String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
+
+ assertEquals(body, newFileBody);
+ }
+
+ @Test
+ public void verifyTheFilePrefixInStringEmptyBodyTest() {
+ String body = "";
+ String filenameToVerify = "testfile.txt";
+
+ String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
+
+ assertEquals(body, newFileBody);
+ }
+
+ @Test
+ public void verifyTheFilePrefixInStringNullFilenameTest() {
+ String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
+ String filenameToVerify = null;
+
+ String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
+
+ assertEquals(body, newFileBody);
+ }
+
+ @Test
+ public void verifyTheFilePrefixInStringEmptyFilenameTest() {
+ String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
+ String filenameToVerify = "";
+
+ String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
+
+ assertEquals(body, newFileBody);
+ }
+
+ private WatchdogComponentDistributionStatus getWatchdogCDStatusWithName(
+ List<WatchdogComponentDistributionStatus> watchdogComponentDistributionStatuses, String componentName) {
+ WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus =
+ new WatchdogComponentDistributionStatus();
+ for (WatchdogComponentDistributionStatus watchdogComponentDistributionStatus : watchdogComponentDistributionStatuses) {
+ if (componentName.equals(watchdogComponentDistributionStatus.getComponentName())) {
+ actualWatchdogComponentDistributionStatus = watchdogComponentDistributionStatus;
+ break;
+ }
+ }
+ return actualWatchdogComponentDistributionStatus;
+ }
+
+
+
+ private void prepareConfigurationResource() {
+ doReturn(metadata).when(nodeTemplate).getMetaData();
+ doReturn(MockConstants.TEMPLATE_TYPE).when(nodeTemplate).getType();
+
+ doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
+ doReturn(MockConstants.MODEL_INVARIANT_UUID).when(metadata)
+ .getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
+ doReturn(MockConstants.MODEL_UUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+ doReturn(MockConstants.MODEL_VERSION).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_VERSION);
+ doReturn(MockConstants.MODEL_DESCRIPTION).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION);
+ doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
+ doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
+ }
+
+ @Test
+ public void getConfigurationResourceTest() {
+ prepareConfigurationResource();
+
+ ConfigurationResource configResource = toscaInstaller.getConfigurationResource(nodeTemplate);
+
+ assertNotNull(configResource);
+ assertEquals(MockConstants.MODEL_NAME, configResource.getModelName());
+ assertEquals(MockConstants.MODEL_INVARIANT_UUID, configResource.getModelInvariantUUID());
+ assertEquals(MockConstants.MODEL_UUID, configResource.getModelUUID());
+ assertEquals(MockConstants.MODEL_VERSION, configResource.getModelVersion());
+ assertEquals(MockConstants.MODEL_DESCRIPTION, configResource.getDescription());
+ assertEquals(MockConstants.TEMPLATE_TYPE, nodeTemplate.getType());
+ }
+
+ private void prepareConfigurationResourceCustomization() {
+ prepareConfigurationResource();
+ doReturn(MockConstants.MODEL_CUSTOMIZATIONUUID).when(metadata)
+ .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ doReturn(csarHelper).when(toscaResourceStructure).getSdcCsarHelper();
+ doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NFFUNCTION);
+ doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NFROLE);
+ doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NFTYPE);
+ doReturn(MockConstants.MODEL_CUSTOMIZATIONUUID).when(spResourceCustomization).getModelCustomizationUUID();
+ }
+
+
+ @Test
+ public void getConfigurationResourceCustomizationTest() {
+ prepareConfigurationResourceCustomization();
+
+ ConfigurationResourceCustomization configurationResourceCustomization = toscaInstaller
+ .getConfigurationResourceCustomization(nodeTemplate, toscaResourceStructure, spResourceCustomization);
+ assertNotNull(configurationResourceCustomization);
+ assertNotNull(configurationResourceCustomization.getConfigurationResource());
+ assertEquals(MockConstants.MODEL_CUSTOMIZATIONUUID,
+ configurationResourceCustomization.getServiceProxyResourceCustomizationUUID());
+ }
+
+ @Test
+ public void getVnrNodeTemplateTest() {
+ prepareConfigurationResourceCustomization();
+ List<NodeTemplate> nodeTemplateList = new ArrayList<>();
+ doReturn(ToscaResourceInstaller.VLAN_NETWORK_RECEPTOR).when(entityType).getType();
+ doReturn(entityType).when(nodeTemplate).getTypeDefinition();
+ nodeTemplateList.add(nodeTemplate);
+ Optional<ConfigurationResourceCustomization> vnrResourceCustomization =
+ toscaInstaller.getVnrNodeTemplate(nodeTemplateList, toscaResourceStructure, spResourceCustomization);
+ assertTrue(vnrResourceCustomization.isPresent());
+ assertEquals(ToscaResourceInstaller.VLAN_NETWORK_RECEPTOR, entityType.getType());
+ }
+
+ class MockConstants {
+ public final static String MODEL_NAME = "VLAN Network Receptor Configuration";
+ public final static String MODEL_INVARIANT_UUID = "1608eef4-de53-4334-a8d2-ba79cab4bde0";
+ public final static String MODEL_UUID = "212ca27b-554c-474c-96b9-ddc2f1b1ddba";
+ public final static String MODEL_VERSION = "30.0";
+ public final static String MODEL_DESCRIPTION = "VLAN network receptor configuration object";
+ public final static String MODEL_CUSTOMIZATIONUUID = "2db953e8-679d-437b-bff7-cb262638a8cd";
+ public final static String TEMPLATE_TYPE = "org.openecomp.nodes.VLANNetworkReceptor";
+ public final static String TEMPLATE_NAME = "VLAN Network Receptor Configuration 0";
+
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImplTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImplTest.java
index a20f6de579..9aad96cbc4 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImplTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImplTest.java
@@ -21,38 +21,37 @@
package org.onap.so.asdc.tenantIsolation;
import static org.junit.Assert.assertEquals;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.so.asdc.BaseTest;
import org.onap.so.client.aai.AAIVersion;
public class AaiClientPropertiesImplTest extends BaseTest {
-
- private static final String SYSTEM_NAME = "MSO";
- private static final String LOCAL_HOST = "http://localhost:";
-
- @BeforeClass
- public static void setup() throws Exception {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void getEndpointTest() throws Exception {
- AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
- String aaiEndpoint = aaiClientPropertiesImpl.getEndpoint().toString();
- assertEquals(LOCAL_HOST + wireMockPort, aaiEndpoint);
- }
-
- @Test
- public void getSystemNameTest() {
- AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
- assertEquals(SYSTEM_NAME, aaiClientPropertiesImpl.getSystemName());
- }
-
- @Test
- public void getDefaultVersionTest() {
- AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
- assertEquals(AAIVersion.LATEST, aaiClientPropertiesImpl.getDefaultVersion());
- }
+
+ private static final String SYSTEM_NAME = "MSO";
+ private static final String LOCAL_HOST = "http://localhost:";
+
+ @BeforeClass
+ public static void setup() throws Exception {
+ System.setProperty("mso.config.path", "src/test/resources");
+ }
+
+ @Test
+ public void getEndpointTest() throws Exception {
+ AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
+ String aaiEndpoint = aaiClientPropertiesImpl.getEndpoint().toString();
+ assertEquals(LOCAL_HOST + wireMockPort, aaiEndpoint);
+ }
+
+ @Test
+ public void getSystemNameTest() {
+ AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
+ assertEquals(SYSTEM_NAME, aaiClientPropertiesImpl.getSystemName());
+ }
+
+ @Test
+ public void getDefaultVersionTest() {
+ AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
+ assertEquals(AAIVersion.LATEST, aaiClientPropertiesImpl.getDefaultVersion());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/WatchdogDistributionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/WatchdogDistributionTest.java
index cfce0f6a17..9ef41c7cbf 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/WatchdogDistributionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/WatchdogDistributionTest.java
@@ -27,9 +27,7 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.HashMap;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -43,99 +41,100 @@ import org.onap.so.db.catalog.beans.Service;
import org.springframework.beans.factory.annotation.Autowired;
public class WatchdogDistributionTest extends BaseTest {
- @Autowired
- private WatchdogDistribution watchdogDistribution;
-
- @Mock
- private AAIResourcesClient aaiResourceClient;
-
- private static final String SUCCESS_TEST = "watchdogTestStatusSuccess";
- private static final String FAILURE_TEST = "watchdogTestStatusFailure";
- private static final String TIMEOUT_TEST = "watchdogTestStatusTimeout";
- private static final String INCOMPLETE_TEST = "watchdogTestStatusIncomplete";
- private static final String EXCEPTION_TEST = "watchdogTestStatusException";
- private static final String NULL_TEST = "watchdogTestStatusNull";
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void before() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void getOverallDistributionStatusTimeoutTest() throws Exception {
- String status = watchdogDistribution.getOverallDistributionStatus(TIMEOUT_TEST);
- assertEquals(DistributionStatus.TIMEOUT.toString(), status);
- }
-
- @Test
- public void getOverallDistributionStatusSuccessTest() throws Exception {
- String status = watchdogDistribution.getOverallDistributionStatus(SUCCESS_TEST);
- assertEquals(DistributionStatus.SUCCESS.toString(), status);
- }
-
- @Test
- public void getOverallDistributionStatusFailureTest() throws Exception {
- String status = watchdogDistribution.getOverallDistributionStatus(FAILURE_TEST);
- assertEquals(DistributionStatus.FAILURE.toString(), status);
- }
-
- @Test
- public void getOverallDistributionStatusIncompleteTest() throws Exception {
- String status = watchdogDistribution.getOverallDistributionStatus(INCOMPLETE_TEST);
- assertEquals(DistributionStatus.INCOMPLETE.toString(), status);
- }
-
- @Test
- public void getOverallDistributionStatusInvalidComponentExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- watchdogDistribution.getOverallDistributionStatus(EXCEPTION_TEST);
- }
-
- @Test
- public void getOverallDistributionStatusNewStatusTest() throws Exception {
- String status = watchdogDistribution.getOverallDistributionStatus("newDistrubutionStatus");
- assertEquals(DistributionStatus.INCOMPLETE.toString(), status);
- }
-
- @Test
- public void getOverallDistributionStatusExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- watchdogDistribution.getOverallDistributionStatus(null);
- }
-
- @Test
- public void executePatchAAITest() throws Exception {
- Service service = new Service();
- service.setModelInvariantUUID("9647dfc4-2083-11e7-93ae-92361f002671");
-
- doReturn(aaiResourceClient).when(watchdogDistributionSpy).getAaiClient();
- doNothing().when(aaiResourceClient).update(isA(AAIResourceUri.class), isA(HashMap.class));
-
- watchdogDistribution.executePatchAAI(SUCCESS_TEST, service.getModelInvariantUUID(), DistributionStatus.SUCCESS.toString());
-
- verify(aaiResourceClient, times(1)).update(any(AAIResourceUri.class), any(HashMap.class));
- }
-
- @Test
- public void executePatchAAINullDistrubutionIdTest() throws Exception {
- expectedException.expect(Exception.class);
- watchdogDistribution.executePatchAAI(null, "", DistributionStatus.SUCCESS.toString());
- }
-
- @Test
- public void executePatchAAINullServiceTest() throws Exception {
- expectedException.expect(Exception.class);
- watchdogDistribution.executePatchAAI(NULL_TEST, null, DistributionStatus.SUCCESS.toString());
- }
-
- @Test
- public void getSetAaiClientTest() {
- aaiResourceClient = watchdogDistribution.getAaiClient();
- watchdogDistribution.setAaiClient(aaiResourceClient);
- AAIResourcesClient aaiResourceClient2 = watchdogDistribution.getAaiClient();
- assertEquals(aaiResourceClient, aaiResourceClient2);
- }
+ @Autowired
+ private WatchdogDistribution watchdogDistribution;
+
+ @Mock
+ private AAIResourcesClient aaiResourceClient;
+
+ private static final String SUCCESS_TEST = "watchdogTestStatusSuccess";
+ private static final String FAILURE_TEST = "watchdogTestStatusFailure";
+ private static final String TIMEOUT_TEST = "watchdogTestStatusTimeout";
+ private static final String INCOMPLETE_TEST = "watchdogTestStatusIncomplete";
+ private static final String EXCEPTION_TEST = "watchdogTestStatusException";
+ private static final String NULL_TEST = "watchdogTestStatusNull";
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void getOverallDistributionStatusTimeoutTest() throws Exception {
+ String status = watchdogDistribution.getOverallDistributionStatus(TIMEOUT_TEST);
+ assertEquals(DistributionStatus.TIMEOUT.toString(), status);
+ }
+
+ @Test
+ public void getOverallDistributionStatusSuccessTest() throws Exception {
+ String status = watchdogDistribution.getOverallDistributionStatus(SUCCESS_TEST);
+ assertEquals(DistributionStatus.SUCCESS.toString(), status);
+ }
+
+ @Test
+ public void getOverallDistributionStatusFailureTest() throws Exception {
+ String status = watchdogDistribution.getOverallDistributionStatus(FAILURE_TEST);
+ assertEquals(DistributionStatus.FAILURE.toString(), status);
+ }
+
+ @Test
+ public void getOverallDistributionStatusIncompleteTest() throws Exception {
+ String status = watchdogDistribution.getOverallDistributionStatus(INCOMPLETE_TEST);
+ assertEquals(DistributionStatus.INCOMPLETE.toString(), status);
+ }
+
+ @Test
+ public void getOverallDistributionStatusInvalidComponentExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ watchdogDistribution.getOverallDistributionStatus(EXCEPTION_TEST);
+ }
+
+ @Test
+ public void getOverallDistributionStatusNewStatusTest() throws Exception {
+ String status = watchdogDistribution.getOverallDistributionStatus("newDistrubutionStatus");
+ assertEquals(DistributionStatus.INCOMPLETE.toString(), status);
+ }
+
+ @Test
+ public void getOverallDistributionStatusExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ watchdogDistribution.getOverallDistributionStatus(null);
+ }
+
+ @Test
+ public void executePatchAAITest() throws Exception {
+ Service service = new Service();
+ service.setModelInvariantUUID("9647dfc4-2083-11e7-93ae-92361f002671");
+
+ doReturn(aaiResourceClient).when(watchdogDistributionSpy).getAaiClient();
+ doNothing().when(aaiResourceClient).update(isA(AAIResourceUri.class), isA(HashMap.class));
+
+ watchdogDistribution.executePatchAAI(SUCCESS_TEST, service.getModelInvariantUUID(),
+ DistributionStatus.SUCCESS.toString());
+
+ verify(aaiResourceClient, times(1)).update(any(AAIResourceUri.class), any(HashMap.class));
+ }
+
+ @Test
+ public void executePatchAAINullDistrubutionIdTest() throws Exception {
+ expectedException.expect(Exception.class);
+ watchdogDistribution.executePatchAAI(null, "", DistributionStatus.SUCCESS.toString());
+ }
+
+ @Test
+ public void executePatchAAINullServiceTest() throws Exception {
+ expectedException.expect(Exception.class);
+ watchdogDistribution.executePatchAAI(NULL_TEST, null, DistributionStatus.SUCCESS.toString());
+ }
+
+ @Test
+ public void getSetAaiClientTest() {
+ aaiResourceClient = watchdogDistribution.getAaiClient();
+ watchdogDistribution.setAaiClient(aaiResourceClient);
+ AAIResourcesClient aaiResourceClient2 = watchdogDistribution.getAaiClient();
+ assertEquals(aaiResourceClient, aaiResourceClient2);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/util/ASDCNotificationLoggingTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/util/ASDCNotificationLoggingTest.java
index 3abc2e7a62..6fd853915e 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/util/ASDCNotificationLoggingTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/util/ASDCNotificationLoggingTest.java
@@ -21,10 +21,8 @@
package org.onap.so.asdc.util;
import static org.junit.Assert.assertTrue;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
@@ -34,153 +32,153 @@ import org.onap.so.asdc.installer.VfModuleMetaData;
import org.onap.so.asdc.util.ASDCNotificationLogging;
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;
- }
-
- @Override
- public String getWorkloadContext() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setWorkloadContext(String arg0) {
- // TODO Auto-generated method stub
-
- }
- };
- 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;
+ }
+
+ @Override
+ public String getWorkloadContext() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setWorkloadContext(String arg0) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+ 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";
+ }
+ };
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/util/NotificationLoggingTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/util/NotificationLoggingTest.java
index 8bd11d9f52..0bdb3a8bab 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/util/NotificationLoggingTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/util/NotificationLoggingTest.java
@@ -22,46 +22,45 @@ package org.onap.so.asdc.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.so.asdc.client.test.emulators.NotificationDataImpl;
public class NotificationLoggingTest {
- private NotificationDataImpl notificationData;
-
- @Before
- public void before() {
- notificationData = new NotificationDataImpl();
- }
-
- @Test
- public void logNotificationTest() {
- notificationData.setDistributionID("distributionID");
- notificationData.setServiceVersion("123456");
- notificationData.setServiceUUID("serviceUUID");
- notificationData.setWorkloadContext("workloadContext");
-
- String response = NotificationLogging.logNotification(notificationData);
+ private NotificationDataImpl notificationData;
+
+ @Before
+ public void before() {
+ notificationData = new NotificationDataImpl();
+ }
+
+ @Test
+ public void logNotificationTest() {
+ notificationData.setDistributionID("distributionID");
+ notificationData.setServiceVersion("123456");
+ notificationData.setServiceUUID("serviceUUID");
+ notificationData.setWorkloadContext("workloadContext");
+
+ String response = NotificationLogging.logNotification(notificationData);
+
+ assertTrue(response.contains("ASDC Notification"));
+ assertTrue(response.contains("ResourcesType not recognized"));
+ assertTrue(response.contains("ServiceNameNULL"));
+ assertTrue(response.contains("ServiceUUIDserviceUUID"));
+ assertTrue(response.contains("ResourcesImplNULL"));
+ assertTrue(response.contains("ServiceArtifactsType not recognized"));
+ assertTrue(response.contains("ServiceDescriptionNULL"));
+ assertTrue(response.contains("DistributionIDdistributionID"));
+ assertTrue(response.contains("ServiceInvariantUUIDNULL"));
+ assertTrue(response.contains("WorkloadContextworkloadContext"));
+ }
+
+ @Test
+ public void logNotificationNullTest() {
+ notificationData = null;
+
+ String response = NotificationLogging.logNotification(notificationData);
- assertTrue(response.contains("ASDC Notification"));
- assertTrue(response.contains("ResourcesType not recognized"));
- assertTrue(response.contains("ServiceNameNULL"));
- assertTrue(response.contains("ServiceUUIDserviceUUID"));
- assertTrue(response.contains("ResourcesImplNULL"));
- assertTrue(response.contains("ServiceArtifactsType not recognized"));
- assertTrue(response.contains("ServiceDescriptionNULL"));
- assertTrue(response.contains("DistributionIDdistributionID"));
- assertTrue(response.contains("ServiceInvariantUUIDNULL"));
- assertTrue(response.contains("WorkloadContextworkloadContext"));
- }
-
- @Test
- public void logNotificationNullTest() {
- notificationData = null;
-
- String response = NotificationLogging.logNotification(notificationData);
-
- assertEquals("NULL", response);
- }
+ assertEquals("NULL", response);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingRunner.java b/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingRunner.java
index 2a77664714..b344f6230a 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingRunner.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingRunner.java
@@ -22,35 +22,31 @@ package org.onap.so.asdc.utils;
import java.nio.file.Files;
import java.nio.file.Paths;
-
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
-
import com.fasterxml.jackson.databind.JsonNode;
-public class ASDCLoggingRunner
-{
- public static void main( String[] args) throws Exception
- {
+public class ASDCLoggingRunner {
+ public static void main(String[] args) throws Exception {
String content = new String(Files.readAllBytes(Paths.get("src/test/resources/Heat_Nested_Notification.txt")));
ASDCLoggingLexer lexer = new ASDCLoggingLexer(CharStreams.fromString(content));
- CommonTokenStream tokens = new CommonTokenStream(lexer);
+ CommonTokenStream tokens = new CommonTokenStream(lexer);
+
+ ASDCLoggingParser parser = new ASDCLoggingParser(tokens);
+
+ ParseTree tree = parser.doc();
+
+ System.out.println(TreeUtils.printTree(tree, parser)); // print LISP-style tree
+
+ ASDCLoggingVisitorImpl v = new ASDCLoggingVisitorImpl();
- ASDCLoggingParser parser = new ASDCLoggingParser(tokens);
-
- ParseTree tree = parser.doc();
+ JsonNode node = v.visit(tree);
- System.out.println(TreeUtils.printTree(tree, parser)); // print LISP-style tree
-
- ASDCLoggingVisitorImpl v = new ASDCLoggingVisitorImpl();
-
- JsonNode node = v.visit(tree);
-
- System.out.println(node.toString());
+ System.out.println(node.toString());
- }
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java b/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java
index 51036e2a18..53d163a5bc 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java
@@ -22,7 +22,6 @@ package org.onap.so.asdc.utils;
import java.util.ArrayDeque;
import java.util.Deque;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ContainerNode;
@@ -32,73 +31,74 @@ import com.google.common.base.CaseFormat;
public class ASDCLoggingVisitorImpl extends ASDCLoggingBaseVisitor<ContainerNode> {
- private final ObjectMapper mapper = new ObjectMapper();
- private ObjectNode doc;
- private Deque<ContainerNode> nodeStore = new ArrayDeque<>();
-
- @Override
- public ContainerNode visitDoc(ASDCLoggingParser.DocContext ctx) {
- doc = mapper.createObjectNode();
- nodeStore.addFirst(doc);
- this.visitChildren(ctx);
- return doc;
- }
-
- @Override
- public ContainerNode visitValue(ASDCLoggingParser.ValueContext ctx) {
-
- return this.visitChildren(ctx);
-
- }
- @Override
- public ContainerNode visitSimplePair(ASDCLoggingParser.SimplePairContext ctx) {
- ObjectNode node = mapper.createObjectNode();
- ((ObjectNode)nodeStore.peekFirst()).put(this.toLowerCamel(ctx.key().getText()), ctx.keyValue().getText());
-
- return node;
- }
-
- @Override
- public ContainerNode visitComplexPair(ASDCLoggingParser.ComplexPairContext ctx) {
- ContainerNode container = nodeStore.peekFirst();
- if (container.isArray()) {
- ArrayNode array = (ArrayNode) container;
- ObjectNode node = mapper.createObjectNode();
- array.add(node);
- nodeStore.addFirst(node);
- } else {
- nodeStore.addFirst(((ObjectNode)nodeStore.peekFirst()).putObject(this.toLowerCamel(ctx.key().getText())));
- }
- this.visitChildren(ctx);
- return nodeStore.removeFirst();
-
-
- }
-
- @Override
- public ContainerNode visitList(ASDCLoggingParser.ListContext ctx) {
- nodeStore.addFirst(((ObjectNode)nodeStore.peekFirst()).putArray(this.keyMapper(ctx.listName().getText())));
- this.visitChildren(ctx);
- return nodeStore.removeFirst();
- }
-
- private String keyMapper(String key) {
- if ("Service Artifacts List".equals(key)) {
- return "serviceArtifacts";
- } else if ("Resource Instances List".equals(key)) {
- return "resources";
- } else if ("Resource Artifacts List".equals(key)) {
- return "artifacts";
- } else {
- return key;
- }
- }
-
- private String toLowerCamel(String key) {
- String result = key.replaceAll("\\s", "");
- if ("ServiceArtifactsInfo".equals(result)) {
- return "artifactInfo";
- }
- return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, result);
- }
+ private final ObjectMapper mapper = new ObjectMapper();
+ private ObjectNode doc;
+ private Deque<ContainerNode> nodeStore = new ArrayDeque<>();
+
+ @Override
+ public ContainerNode visitDoc(ASDCLoggingParser.DocContext ctx) {
+ doc = mapper.createObjectNode();
+ nodeStore.addFirst(doc);
+ this.visitChildren(ctx);
+ return doc;
+ }
+
+ @Override
+ public ContainerNode visitValue(ASDCLoggingParser.ValueContext ctx) {
+
+ return this.visitChildren(ctx);
+
+ }
+
+ @Override
+ public ContainerNode visitSimplePair(ASDCLoggingParser.SimplePairContext ctx) {
+ ObjectNode node = mapper.createObjectNode();
+ ((ObjectNode) nodeStore.peekFirst()).put(this.toLowerCamel(ctx.key().getText()), ctx.keyValue().getText());
+
+ return node;
+ }
+
+ @Override
+ public ContainerNode visitComplexPair(ASDCLoggingParser.ComplexPairContext ctx) {
+ ContainerNode container = nodeStore.peekFirst();
+ if (container.isArray()) {
+ ArrayNode array = (ArrayNode) container;
+ ObjectNode node = mapper.createObjectNode();
+ array.add(node);
+ nodeStore.addFirst(node);
+ } else {
+ nodeStore.addFirst(((ObjectNode) nodeStore.peekFirst()).putObject(this.toLowerCamel(ctx.key().getText())));
+ }
+ this.visitChildren(ctx);
+ return nodeStore.removeFirst();
+
+
+ }
+
+ @Override
+ public ContainerNode visitList(ASDCLoggingParser.ListContext ctx) {
+ nodeStore.addFirst(((ObjectNode) nodeStore.peekFirst()).putArray(this.keyMapper(ctx.listName().getText())));
+ this.visitChildren(ctx);
+ return nodeStore.removeFirst();
+ }
+
+ private String keyMapper(String key) {
+ if ("Service Artifacts List".equals(key)) {
+ return "serviceArtifacts";
+ } else if ("Resource Instances List".equals(key)) {
+ return "resources";
+ } else if ("Resource Artifacts List".equals(key)) {
+ return "artifacts";
+ } else {
+ return key;
+ }
+ }
+
+ private String toLowerCamel(String key) {
+ String result = key.replaceAll("\\s", "");
+ if ("ServiceArtifactsInfo".equals(result)) {
+ return "artifactInfo";
+ }
+ return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, result);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreePrinterListener.java b/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreePrinterListener.java
index c4a84c0540..39119c7dca 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreePrinterListener.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreePrinterListener.java
@@ -25,7 +25,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.RuleContext;
@@ -38,7 +37,7 @@ import org.antlr.v4.runtime.tree.Trees;
public class TreePrinterListener implements ParseTreeListener {
private final List<String> ruleNames;
private final StringBuilder builder = new StringBuilder();
- Map<RuleContext,ArrayList<String>> stack = new HashMap<RuleContext,ArrayList<String>>();
+ Map<RuleContext, ArrayList<String>> stack = new HashMap<RuleContext, ArrayList<String>>();
public TreePrinterListener(Parser parser) {
this.ruleNames = Arrays.asList(parser.getRuleNames());
@@ -50,10 +49,10 @@ public class TreePrinterListener implements ParseTreeListener {
@Override
public void visitTerminal(TerminalNode node) {
- String text = Utils.escapeWhitespace(Trees.getNodeText(node, ruleNames), false);
- if(text.startsWith(" ") || text.endsWith(" ")){
- text = "'" + text + "'";
- }
+ String text = Utils.escapeWhitespace(Trees.getNodeText(node, ruleNames), false);
+ if (text.startsWith(" ") || text.endsWith(" ")) {
+ text = "'" + text + "'";
+ }
stack.get(node.getParent()).add(text);
}
@@ -64,20 +63,19 @@ public class TreePrinterListener implements ParseTreeListener {
@Override
public void enterEveryRule(ParserRuleContext ctx) {
- if(!stack.containsKey(ctx.parent)){
- stack.put(ctx.parent, new ArrayList<String>());
- }
- if(!stack.containsKey(ctx)){
- stack.put(ctx, new ArrayList<String>());
- }
+ if (!stack.containsKey(ctx.parent)) {
+ stack.put(ctx.parent, new ArrayList<String>());
+ }
+ if (!stack.containsKey(ctx)) {
+ stack.put(ctx, new ArrayList<String>());
+ }
- final StringBuilder sb = new StringBuilder();
- int ruleIndex = ctx.getRuleIndex();
+ final StringBuilder sb = new StringBuilder();
+ int ruleIndex = ctx.getRuleIndex();
String ruleName;
if (ruleIndex >= 0 && ruleIndex < ruleNames.size()) {
ruleName = ruleNames.get(ruleIndex);
- }
- else {
+ } else {
ruleName = Integer.toString(ruleIndex);
}
sb.append(ruleName);
@@ -86,52 +84,52 @@ public class TreePrinterListener implements ParseTreeListener {
@Override
public void exitEveryRule(ParserRuleContext ctx) {
- ArrayList<String> ruleStack = stack.remove(ctx);
- StringBuilder sb = new StringBuilder();
- boolean brackit =ruleStack.size()>1;
- if(brackit){
- sb.append("(");
- }
- sb.append(ruleStack.get(0));
- for(int i=1; i<ruleStack.size(); i++){
- sb.append(" ");
- sb.append(ruleStack.get(i));
- }
- if(brackit){
- sb.append(")");
- }
- if(sb.length() < 80){
- stack.get(ctx.parent).add(sb.toString());
- }else{
- // Current line is too long, regenerate it using 1 line per item.
- sb.setLength(0);
- if(brackit){
- sb.append("(");
- }
- if(!ruleStack.isEmpty()){
- sb.append(ruleStack.remove(0)).append("\r\n");
- }
- while(!ruleStack.isEmpty()){
- sb.append(indent(ruleStack.remove(0))).append("\r\n");
- }
- if(brackit){
- sb.append(")");
- }
- stack.get(ctx.parent).add(sb.toString());
- }
- if(ctx.parent == null){
- builder.append(sb.toString());
- }
+ ArrayList<String> ruleStack = stack.remove(ctx);
+ StringBuilder sb = new StringBuilder();
+ boolean brackit = ruleStack.size() > 1;
+ if (brackit) {
+ sb.append("(");
+ }
+ sb.append(ruleStack.get(0));
+ for (int i = 1; i < ruleStack.size(); i++) {
+ sb.append(" ");
+ sb.append(ruleStack.get(i));
+ }
+ if (brackit) {
+ sb.append(")");
+ }
+ if (sb.length() < 80) {
+ stack.get(ctx.parent).add(sb.toString());
+ } else {
+ // Current line is too long, regenerate it using 1 line per item.
+ sb.setLength(0);
+ if (brackit) {
+ sb.append("(");
+ }
+ if (!ruleStack.isEmpty()) {
+ sb.append(ruleStack.remove(0)).append("\r\n");
+ }
+ while (!ruleStack.isEmpty()) {
+ sb.append(indent(ruleStack.remove(0))).append("\r\n");
+ }
+ if (brackit) {
+ sb.append(")");
+ }
+ stack.get(ctx.parent).add(sb.toString());
+ }
+ if (ctx.parent == null) {
+ builder.append(sb.toString());
+ }
}
-
- static String indent(String input){
- return " " + input.replaceAll("\r\n(.)","\r\n $1");
+
+ static String indent(String input) {
+ return " " + input.replaceAll("\r\n(.)", "\r\n $1");
}
@Override
public String toString() {
return builder.toString();
}
-
-
+
+
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreeUtils.java b/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreeUtils.java
index 8de9f362b7..5a03b91959 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreeUtils.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreeUtils.java
@@ -21,7 +21,6 @@
package org.onap.so.asdc.utils;
import java.util.Arrays;
-
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
@@ -29,19 +28,20 @@ import org.antlr.v4.runtime.tree.ParseTreeWalker;
public class TreeUtils {
- /**
- * Print the tree, splitting at appropriate points, instead of rendering a single long line.
- * @param parseTree
- * @param parser
- * @return
- */
- public static String printTree(final ParseTree parseTree, final Parser parser){
- final TreePrinterListener listener = new TreePrinterListener(Arrays.asList(parser.getRuleNames()));
+ /**
+ * Print the tree, splitting at appropriate points, instead of rendering a single long line.
+ *
+ * @param parseTree
+ * @param parser
+ * @return
+ */
+ public static String printTree(final ParseTree parseTree, final Parser parser) {
+ final TreePrinterListener listener = new TreePrinterListener(Arrays.asList(parser.getRuleNames()));
ParseTreeWalker.DEFAULT.walk(listener, parseTree);
return listener.toString();
- }
-
- public static String normalizeWhiteSpace(String input){
- return input.replaceAll("\\s+", " ").replaceAll("([^\\w])\\s+", "$1");
+ }
+
+ public static String normalizeWhiteSpace(String input) {
+ return input.replaceAll("\\s+", " ").replaceAll("([^\\w])\\s+", "$1");
}
}