diff options
7 files changed, 297 insertions, 2045 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java index f5891a089b..9920b597a1 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java @@ -20,6 +20,7 @@ package org.openecomp.sdc.be.config; +import com.google.common.annotations.VisibleForTesting; import org.openecomp.sdc.common.api.BasicConfiguration; import org.openecomp.sdc.common.api.ConfigurationListener; import org.openecomp.sdc.common.api.ConfigurationSource; @@ -32,6 +33,12 @@ import java.util.Map; public class ConfigurationManager implements FileChangeCallback, IEcompConfigurationManager { + @VisibleForTesting + public ConfigurationManager() { + super(); + instance = this; + } + private ConfigurationSource configurationSource = null; private static ConfigurationManager instance; @@ -125,23 +132,7 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura return instance; } - public void reconfigure(BasicConfiguration obj) { - - // if (obj != null) { - - // if (obj instanceof Configuration) { - // configurations.put(getKey(Configuration.class), obj); - // } - // if (obj instanceof ErrorConfiguration) { - // configurations.put(getKey(ErrorConfiguration.class), obj); - // } - // - // if (obj instanceof EcompErrorConfiguration) { - // configurations.put(getKey(EcompErrorConfiguration.class), obj); - // } - // } - - } + public void reconfigure(BasicConfiguration obj) { } /** * FOR TEST ONLY diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/CleanComponentsConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/CleanComponentsConfigurationTest.java index fbaaf71053..98d9c85d6d 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/CleanComponentsConfigurationTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/CleanComponentsConfigurationTest.java @@ -3,6 +3,7 @@ * SDC * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nokia. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,50 +21,20 @@ package org.openecomp.sdc.be.config; -import java.util.List; - import org.junit.Test; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; -public class CleanComponentsConfigurationTest { - - private CleanComponentsConfiguration createTestSubject() { - return new CleanComponentsConfiguration(); - } - - - @Test - public void testGetCleanIntervalInMinutes() throws Exception { - CleanComponentsConfiguration testSubject; - long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCleanIntervalInMinutes(); - } - - - - - - @Test - public void testGetComponentsToClean() throws Exception { - CleanComponentsConfiguration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getComponentsToClean(); - } - +public class CleanComponentsConfigurationTest { @Test - public void testSetComponentsToClean() throws Exception { - CleanComponentsConfiguration testSubject; - List<String> componentsToClean = null; - - // default test - testSubject = createTestSubject(); - testSubject.setComponentsToClean(componentsToClean); + public void validateBean() { + assertThat(CleanComponentsConfiguration.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } } diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationManagerTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationManagerTest.java index eedab171b8..a3d34e5ce2 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationManagerTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationManagerTest.java @@ -3,6 +3,7 @@ * ONAP SDC * ================================================================================ * Copyright (C) 2019 Samsung. All rights reserved. + * Modifications Copyright (C) 2019 Nokia. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,21 +23,28 @@ package org.openecomp.sdc.be.config; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.openecomp.sdc.common.api.ConfigurationListener; import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.config.EcompErrorConfiguration; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; +@RunWith(MockitoJUnitRunner.class) public class ConfigurationManagerTest { private ConfigurationManager configurationManager; @Before - public void setConfigurationSource() { + public void setUp() { String appConfigDir = "src/test/resources/config/common"; ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir); @@ -44,31 +52,52 @@ public class ConfigurationManagerTest { } @Test - public void testGetConfiguration() { - assertEquals(configurationManager.getConfiguration(), - ConfigurationManager.getConfigurationManager().getConfigurations() - .get(Configuration.class.getSimpleName())); + public void validateBean() { + assertThat(ConfigurationManager.class, + hasValidGettersAndSettersExcluding( + "distributionEngineConfiguration", + "ecompErrorConfiguration", + "errorConfiguration", + "neo4jErrorsConfiguration" + )); } - + private class TestErrorConfiguration extends ErrorConfiguration{} @Test - public void testGetErrorConfiguration() { - assertEquals(configurationManager.getErrorConfiguration(), - ConfigurationManager.getConfigurationManager().getConfigurations() - .get(ErrorConfiguration.class.getSimpleName())); + public void testGetSetErrorConfiguration() { + configurationManager.setErrorConfiguration(new TestErrorConfiguration()); + assertEquals( + configurationManager.getErrorConfiguration().getClass(), + TestErrorConfiguration.class); } - + private class TestEcompErrorConfiguration extends EcompErrorConfiguration{} @Test - public void testGetEcompErrorConfiguration() { - assertEquals(configurationManager.getEcompErrorConfiguration(), - ConfigurationManager.getConfigurationManager().getConfigurations() - .get(EcompErrorConfiguration.class.getSimpleName())); + public void testGetSetEcompErrorConfiguration() { + configurationManager.setEcompErrorConfiguration(new TestEcompErrorConfiguration()); + assertEquals( + configurationManager.getEcompErrorConfiguration().getClass(), + TestEcompErrorConfiguration.class); } - @Test public void testGetDistributionEngineConfiguration() { assertEquals(configurationManager.getDistributionEngineConfiguration(), ConfigurationManager.getConfigurationManager().getConfigurations() .get(DistributionEngineConfiguration.class.getSimpleName())); } + @Test + public void testGetNeo4jErrorsConfiguration() { + assertEquals(configurationManager.getNeo4jErrorsConfiguration(), + ConfigurationManager.getConfigurationManager().getConfigurations() + .get(Neo4jErrorsConfiguration.class.getSimpleName())); + } + private class TestConfiguration extends Configuration{} + @Test + public void testGetConfigurationAndWatch() { + ConfigurationListener testListener = Mockito.mock(ConfigurationListener.class); + configurationManager.setConfiguration(new TestConfiguration()); + assertEquals( + configurationManager.getConfigurationAndWatch(testListener).getClass(), + TestConfiguration.class + ); + } } diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java index b965f3c264..cb92d355c1 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java @@ -3,6 +3,7 @@ * SDC * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nokia. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,1454 +21,146 @@ package org.openecomp.sdc.be.config; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.junit.Test; -import org.openecomp.sdc.be.config.Configuration.ApplicationL1CacheConfig; -import org.openecomp.sdc.be.config.Configuration.ApplicationL2CacheConfig; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; -import org.openecomp.sdc.be.config.Configuration.BeMonitoringConfig; -import org.openecomp.sdc.be.config.Configuration.CassandrConfig; -import org.openecomp.sdc.be.config.Configuration.EcompPortalConfig; -import org.openecomp.sdc.be.config.Configuration.ElasticSearchConfig; -import org.openecomp.sdc.be.config.Configuration.OnboardingConfig; -import org.openecomp.sdc.be.config.Configuration.SwitchoverDetectorConfig; -import org.openecomp.sdc.be.config.Configuration.ToscaValidatorsConfig; -import org.openecomp.sdc.be.config.Configuration.VfModuleProperty; - - -public class ConfigurationTest { - - private Configuration createTestSubject() { - return new Configuration(); - } - - - @Test - public void testGetGenericAssetNodeTypes() throws Exception { - Configuration testSubject; - Map<String, String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getGenericAssetNodeTypes(); - } - - - @Test - public void testSetGenericAssetNodeTypes() throws Exception { - Configuration testSubject; - Map<String, String> genericAssetNodeTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setGenericAssetNodeTypes(genericAssetNodeTypes); - } - - - @Test - public void testGetSwitchoverDetector() throws Exception { - Configuration testSubject; - SwitchoverDetectorConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getSwitchoverDetector(); - } - - - @Test - public void testSetSwitchoverDetector() throws Exception { - Configuration testSubject; - SwitchoverDetectorConfig switchoverDetector = null; - - // default test - testSubject = createTestSubject(); - testSubject.setSwitchoverDetector(switchoverDetector); - } - - - @Test - public void testGetApplicationL1Cache() throws Exception { - Configuration testSubject; - ApplicationL1CacheConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getApplicationL1Cache(); - } - - - @Test - public void testSetApplicationL1Cache() throws Exception { - Configuration testSubject; - ApplicationL1CacheConfig applicationL1Cache = null; - - // default test - testSubject = createTestSubject(); - testSubject.setApplicationL1Cache(applicationL1Cache); - } - - - @Test - public void testGetApplicationL2Cache() throws Exception { - Configuration testSubject; - ApplicationL2CacheConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getApplicationL2Cache(); - } - - - @Test - public void testSetApplicationL2Cache() throws Exception { - Configuration testSubject; - ApplicationL2CacheConfig applicationL2Cache = null; - - // default test - testSubject = createTestSubject(); - testSubject.setApplicationL2Cache(applicationL2Cache); - } - - - @Test - public void testGetCassandraConfig() throws Exception { - Configuration testSubject; - CassandrConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCassandraConfig(); - } - - - @Test - public void testSetCassandraConfig() throws Exception { - Configuration testSubject; - CassandrConfig cassandraKeySpace = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCassandraConfig(cassandraKeySpace); - } - - - @Test - public void testGetIdentificationHeaderFields() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getIdentificationHeaderFields(); - } - - - @Test - public void testSetIdentificationHeaderFields() throws Exception { - Configuration testSubject; - List<String> identificationHeaderFields = null; - - // default test - testSubject = createTestSubject(); - testSubject.setIdentificationHeaderFields(identificationHeaderFields); - } - - - @Test - public void testGetReleased() throws Exception { - Configuration testSubject; - Date result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getReleased(); - } - - - @Test - public void testGetVersion() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVersion(); - } - - - @Test - public void testSetReleased() throws Exception { - Configuration testSubject; - Date released = null; - - // default test - testSubject = createTestSubject(); - testSubject.setReleased(released); - } - - - @Test - public void testSetVersion() throws Exception { - Configuration testSubject; - String version = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setVersion(version); - } - - - @Test - public void testGetProtocols() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProtocols(); - } - - - @Test - public void testSetProtocols() throws Exception { - Configuration testSubject; - List<String> protocols = null; - - // default test - testSubject = createTestSubject(); - testSubject.setProtocols(protocols); - } - - - @Test - public void testGetUsers() throws Exception { - Configuration testSubject; - Map<String, String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUsers(); - } - - - @Test - public void testSetUsers() throws Exception { - Configuration testSubject; - Map<String, String> users = null; - - // default test - testSubject = createTestSubject(); - testSubject.setUsers(users); - } - - - @Test - public void testGetBeFqdn() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getBeFqdn(); - } - - - @Test - public void testSetBeFqdn() throws Exception { - Configuration testSubject; - String beHost = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setBeFqdn(beHost); - } - - - @Test - public void testGetBeHttpPort() throws Exception { - Configuration testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getBeHttpPort(); - } - - - @Test - public void testSetBeHttpPort() throws Exception { - Configuration testSubject; - Integer beHttpPort = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setBeHttpPort(beHttpPort); - } - - - @Test - public void testGetBeSslPort() throws Exception { - Configuration testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getBeSslPort(); - } - - - @Test - public void testSetBeSslPort() throws Exception { - Configuration testSubject; - Integer beSslPort = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setBeSslPort(beSslPort); - } - - - @Test - public void testGetBeContext() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getBeContext(); - } - - - @Test - public void testSetBeContext() throws Exception { - Configuration testSubject; - String beContext = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setBeContext(beContext); - } - - - @Test - public void testGetBeProtocol() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getBeProtocol(); - } - - @Test - public void testSetBeProtocol() throws Exception { - Configuration testSubject; - String beProtocol = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setBeProtocol(beProtocol); - } - - - @Test - public void testGetNeo4j() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNeo4j(); - } - - - @Test - public void testSetNeo4j() throws Exception { - Configuration testSubject; - Map<String, Object> neo4j = null; - - // default test - testSubject = createTestSubject(); - testSubject.setNeo4j(neo4j); - } - - - @Test - public void testGetElasticSearch() throws Exception { - Configuration testSubject; - ElasticSearchConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getElasticSearch(); - } - - - @Test - public void testSetElasticSearch() throws Exception { - Configuration testSubject; - ElasticSearchConfig elasticSearch = null; - - // default test - testSubject = createTestSubject(); - testSubject.setElasticSearch(elasticSearch); - } - - - @Test - public void testGetJanusGraphCfgFile() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getJanusGraphCfgFile(); - } - - - @Test - public void testSetJanusGraphCfgFile() throws Exception { - Configuration testSubject; - String janusGraphCfgFile = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setJanusGraphCfgFile(janusGraphCfgFile); - } - - - @Test - public void testGetJanusGraphMigrationKeySpaceCfgFile() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getJanusGraphMigrationKeySpaceCfgFile(); - } - - - @Test - public void testSetJanusGraphMigrationKeySpaceCfgFile() throws Exception { - Configuration testSubject; - String janusGraphMigrationKeySpaceCfgFile = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setJanusGraphMigrationKeySpaceCfgFile(janusGraphMigrationKeySpaceCfgFile); - } - - - @Test - public void testGetJanusGraphInMemoryGraph() throws Exception { - Configuration testSubject; - Boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getJanusGraphInMemoryGraph(); - } - - - @Test - public void testSetJanusGraphInMemoryGraph() throws Exception { - Configuration testSubject; - Boolean janusGraphInMemoryGraph = null; - - // default test - testSubject = createTestSubject(); - testSubject.setJanusGraphInMemoryGraph(janusGraphInMemoryGraph); - } - - - @Test - public void testGetStartMigrationFrom() throws Exception { - Configuration testSubject; - int result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getStartMigrationFrom(); - } - - - @Test - public void testSetStartMigrationFrom() throws Exception { - Configuration testSubject; - int startMigrationFrom = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setStartMigrationFrom(startMigrationFrom); - } - - - @Test - public void testGetJanusGraphLockTimeout() throws Exception { - Configuration testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getJanusGraphLockTimeout(); - } - - - @Test - public void testSetJanusGraphLockTimeout() throws Exception { - Configuration testSubject; - Long janusGraphLockTimeout = null; - - // default test - testSubject = createTestSubject(); - testSubject.setJanusGraphLockTimeout(janusGraphLockTimeout); - } - - - @Test - public void testGetJanusGraphHealthCheckReadTimeout() throws Exception { - Configuration testSubject; - Long result; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; - // default test - testSubject = createTestSubject(); - result = testSubject.getJanusGraphHealthCheckReadTimeout(); - } - - - - - @Test - public void testSetJanusGraphHealthCheckReadTimeout() throws Exception { - Configuration testSubject; - Long janusGraphHealthCheckReadTimeout = null; - - // default test - testSubject = createTestSubject(); - testSubject.setJanusGraphHealthCheckReadTimeout(janusGraphHealthCheckReadTimeout); - } - - - @Test - public void testGetJanusGraphReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getJanusGraphReconnectIntervalInSeconds(); - } - - - - - @Test - public void testSetJanusGraphReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long janusGraphReconnectIntervalInSeconds = null; - - // default test - testSubject = createTestSubject(); - testSubject.setJanusGraphReconnectIntervalInSeconds(janusGraphReconnectIntervalInSeconds); - } - - - @Test - public void testGetEsReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getEsReconnectIntervalInSeconds(); - } - - - - - @Test - public void testSetEsReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long esReconnectIntervalInSeconds = null; - - // default test - testSubject = createTestSubject(); - testSubject.setEsReconnectIntervalInSeconds(esReconnectIntervalInSeconds); - } - - - @Test - public void testGetArtifactTypes() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getArtifactTypes(); - } - - - @Test - public void testSetArtifactTypes() throws Exception { - Configuration testSubject; - List<String> artifactTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setArtifactTypes(artifactTypes); - } - - - @Test - public void testGetExcludeResourceCategory() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getExcludeResourceCategory(); - } - - - @Test - public void testSetExcludeResourceCategory() throws Exception { - Configuration testSubject; - List<String> excludeResourceCategory = null; - - // default test - testSubject = createTestSubject(); - testSubject.setExcludeResourceCategory(excludeResourceCategory); - } - - - @Test - public void testGetExcludeResourceType() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getExcludeResourceType(); - } - - - @Test - public void testSetExcludeResourceType() throws Exception { - Configuration testSubject; - List<String> excludeResourceType = null; - - // default test - testSubject = createTestSubject(); - testSubject.setExcludeResourceType(excludeResourceType); - } - - - @Test - public void testGetToscaArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getToscaArtifacts(); - } - - - @Test - public void testSetToscaArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> toscaArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setToscaArtifacts(toscaArtifacts); - } - - - @Test - public void testGetInformationalResourceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInformationalResourceArtifacts(); - } - - @Test - public void testSetInformationalResourceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> informationalResourceArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInformationalResourceArtifacts(informationalResourceArtifacts); - } - - - @Test - public void testGetInformationalServiceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInformationalServiceArtifacts(); - } - - - @Test - public void testSetInformationalServiceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> informationalServiceArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInformationalServiceArtifacts(informationalServiceArtifacts); - } - - - @Test - public void testGetServiceApiArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceApiArtifacts(); - } - - - @Test - public void testSetServiceApiArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> serviceApiArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceApiArtifacts(serviceApiArtifacts); - } - - - @Test - public void testGetServiceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceDeploymentArtifacts(); - } - - - @Test - public void testSetServiceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> serviceDeploymentArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceDeploymentArtifacts(serviceDeploymentArtifacts); - } - - - @Test - public void testGetResourceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceDeploymentArtifacts(); - } - - - @Test - public void testSetResourceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> resourceDeploymentArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceDeploymentArtifacts(resourceDeploymentArtifacts); - } - - - @Test - public void testSetResourceInstanceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> resourceInstanceDeploymentArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceInstanceDeploymentArtifacts(resourceInstanceDeploymentArtifacts); - } - - - @Test - public void testGetResourceInstanceDeploymentArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceInstanceDeploymentArtifacts(); - } - - - @Test - public void testGetExcludeServiceCategory() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getExcludeServiceCategory(); - } - - - @Test - public void testSetExcludeServiceCategory() throws Exception { - Configuration testSubject; - List<String> excludeServiceCategory = null; - - // default test - testSubject = createTestSubject(); - testSubject.setExcludeServiceCategory(excludeServiceCategory); - } - - - @Test - public void testGetLicenseTypes() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getLicenseTypes(); - } - - - @Test - public void testSetLicenseTypes() throws Exception { - Configuration testSubject; - List<String> licenseTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setLicenseTypes(licenseTypes); - } - - - @Test - public void testGetAdditionalInformationMaxNumberOfKeys() throws Exception { - Configuration testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAdditionalInformationMaxNumberOfKeys(); - } - - - @Test - public void testSetAdditionalInformationMaxNumberOfKeys() throws Exception { - Configuration testSubject; - Integer additionalInformationMaxNumberOfKeys = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setAdditionalInformationMaxNumberOfKeys(additionalInformationMaxNumberOfKeys); - } - - - @Test - public void testGetSystemMonitoring() throws Exception { - Configuration testSubject; - BeMonitoringConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getSystemMonitoring(); - } - - - @Test - public void testSetSystemMonitoring() throws Exception { - Configuration testSubject; - BeMonitoringConfig systemMonitoring = null; - - // default test - testSubject = createTestSubject(); - testSubject.setSystemMonitoring(systemMonitoring); - } - - - @Test - public void testGetDefaultHeatArtifactTimeoutMinutes() throws Exception { - Configuration testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDefaultHeatArtifactTimeoutMinutes(); - } - - - @Test - public void testSetDefaultHeatArtifactTimeoutMinutes() throws Exception { - Configuration testSubject; - Integer defaultHeatArtifactTimeoutMinutes = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setDefaultHeatArtifactTimeoutMinutes(defaultHeatArtifactTimeoutMinutes); - } - - - @Test - public void testGetUebHealthCheckReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUebHealthCheckReconnectIntervalInSeconds(); - } - - - @Test - public void testSetUebHealthCheckReconnectIntervalInSeconds() throws Exception { - Configuration testSubject; - Long uebHealthCheckReconnectIntervalInSeconds = null; - - // default test - testSubject = createTestSubject(); - testSubject.setUebHealthCheckReconnectIntervalInSeconds(uebHealthCheckReconnectIntervalInSeconds); - } - - - @Test - public void testGetUebHealthCheckReadTimeout() throws Exception { - Configuration testSubject; - Long result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUebHealthCheckReadTimeout(); - } - - - @Test - public void testSetUebHealthCheckReadTimeout() throws Exception { - Configuration testSubject; - Long uebHealthCheckReadTimeout = null; - - // default test - testSubject = createTestSubject(); - testSubject.setUebHealthCheckReadTimeout(uebHealthCheckReadTimeout); - } - - - @Test - public void testGetCleanComponentsConfiguration() throws Exception { - Configuration testSubject; - CleanComponentsConfiguration result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCleanComponentsConfiguration(); - } - - - @Test - public void testSetCleanComponentsConfiguration() throws Exception { - Configuration testSubject; - CleanComponentsConfiguration cleanComponentsConfiguration = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCleanComponentsConfiguration(cleanComponentsConfiguration); - } - - - @Test - public void testToString() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } - - - @Test - public void testGetUnLoggedUrls() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUnLoggedUrls(); - } - - - @Test - public void testSetUnLoggedUrls() throws Exception { - Configuration testSubject; - List<String> unLoggedUrls = null; - - // default test - testSubject = createTestSubject(); - testSubject.setUnLoggedUrls(unLoggedUrls); - } - - - @Test - public void testGetDeploymentResourceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDeploymentResourceArtifacts(); - } - - - @Test - public void testSetDeploymentResourceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> deploymentResourceArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDeploymentResourceArtifacts(deploymentResourceArtifacts); - } - - - @Test - public void testGetHeatEnvArtifactHeader() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHeatEnvArtifactHeader(); - } - - - @Test - public void testSetHeatEnvArtifactHeader() throws Exception { - Configuration testSubject; - String heatEnvArtifactHeader = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setHeatEnvArtifactHeader(heatEnvArtifactHeader); - } - - - @Test - public void testGetHeatEnvArtifactFooter() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHeatEnvArtifactFooter(); - } - - - @Test - public void testSetHeatEnvArtifactFooter() throws Exception { - Configuration testSubject; - String heatEnvArtifactFooter = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setHeatEnvArtifactFooter(heatEnvArtifactFooter); - } - - - @Test - public void testGetDeploymentResourceInstanceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDeploymentResourceInstanceArtifacts(); - } - - - @Test - public void testSetDeploymentResourceInstanceArtifacts() throws Exception { - Configuration testSubject; - Map<String, Object> deploymentResourceInstanceArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDeploymentResourceInstanceArtifacts(deploymentResourceInstanceArtifacts); - } - - - @Test - public void testGetArtifactsIndex() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getArtifactsIndex(); - } - - - @Test - public void testSetArtifactsIndex() throws Exception { - Configuration testSubject; - String artifactsIndex = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setArtifactsIndex(artifactsIndex); - } - - - @Test - public void testGetResourceInformationalDeployedArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceInformationalDeployedArtifacts(); - } - - - @Test - public void testSetResourceInformationalDeployedArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceInformationalDeployedArtifacts(resourceInformationalDeployedArtifacts); - } - - - @Test - public void testGetResourceTypes() throws Exception { - Configuration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceTypes(); - } - - - @Test - public void testSetResourceTypes() throws Exception { - Configuration testSubject; - List<String> resourceTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceTypes(resourceTypes); - } - - - @Test - public void testGetToscaFilesDir() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getToscaFilesDir(); - } - - - @Test - public void testSetToscaFilesDir() throws Exception { - Configuration testSubject; - String toscaFilesDir = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setToscaFilesDir(toscaFilesDir); - } - - - @Test - public void testGetHeatTranslatorPath() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHeatTranslatorPath(); - } - - - @Test - public void testSetHeatTranslatorPath() throws Exception { - Configuration testSubject; - String heatTranslatorPath = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setHeatTranslatorPath(heatTranslatorPath); - } - - - @Test - public void testGetRequirementsToFulfillBeforeCert() throws Exception { - Configuration testSubject; - Map<String, Set<String>> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRequirementsToFulfillBeforeCert(); - } - - - @Test - public void testSetRequirementsToFulfillBeforeCert() throws Exception { - Configuration testSubject; - Map<String, Set<String>> requirementsToFulfillBeforeCert = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRequirementsToFulfillBeforeCert(requirementsToFulfillBeforeCert); - } - - +public class ConfigurationTest { @Test - public void testGetCapabilitiesToConsumeBeforeCert() throws Exception { - Configuration testSubject; - Map<String, Set<String>> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCapabilitiesToConsumeBeforeCert(); + public void validateBean() { + assertThat(Configuration.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding( + "excludedGroupTypesMapping", + "excludedPolicyTypesMapping", + "skipUpgradeVSPs", + "skipUpgradeVSPsFlag", + "supportAllottedResourcesAndProxy", + "supportAllottedResourcesAndProxyFlag") + )); } - - @Test - public void testSetCapabilitiesToConsumeBeforeCert() throws Exception { - Configuration testSubject; - Map<String, Set<String>> capabilitiesToConsumeBeforeCert = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCapabilitiesToConsumeBeforeCert(capabilitiesToConsumeBeforeCert); + public void validateBeanForElasticSearchConfig() { + assertThat(Configuration.ElasticSearchConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testGetOnboarding() throws Exception { - Configuration testSubject; - OnboardingConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getOnboarding(); + public void validateBeanForCassandrConfig() { + assertThat(Configuration.CassandrConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testSetOnboarding() throws Exception { - Configuration testSubject; - OnboardingConfig onboarding = null; - - // default test - testSubject = createTestSubject(); - testSubject.setOnboarding(onboarding); + public void validateBeanForSwitchoverDetectorConfig() { + assertThat(Configuration.SwitchoverDetectorConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - - @Test - public void testGetEcompPortal() throws Exception { - Configuration testSubject; - EcompPortalConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getEcompPortal(); - } - - @Test - public void testSetEcompPortal() throws Exception { - Configuration testSubject; - EcompPortalConfig ecompPortal = null; - - // default test - testSubject = createTestSubject(); - testSubject.setEcompPortal(ecompPortal); + public void validateBeanForBeMonitoringConfig() { + assertThat(Configuration.BeMonitoringConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testGetToscaValidators() throws Exception { - Configuration testSubject; - ToscaValidatorsConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getToscaValidators(); + public void validateBeanForArtifactTypeConfig() { + assertThat(Configuration.ArtifactTypeConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testSetToscaValidators() throws Exception { - Configuration testSubject; - ToscaValidatorsConfig toscaValidators = null; - - // default test - testSubject = createTestSubject(); - testSubject.setToscaValidators(toscaValidators); + public void validateBeanForOnboardingConfig() { + assertThat(Configuration.OnboardingConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testIsDisableAudit() throws Exception { - Configuration testSubject; - boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.isDisableAudit(); + public void validateBeanForDcaeConfig() { + assertThat(Configuration.DcaeConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testSetDisableAudit() throws Exception { - Configuration testSubject; - boolean enableAudit = false; - - // default test - testSubject = createTestSubject(); - testSubject.setDisableAudit(enableAudit); + public void validateBeanForEcompPortalConfig() { + assertThat(Configuration.EcompPortalConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testGetResourceInformationalArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceInformationalArtifacts(); + public void validateBeanForApplicationL1CacheConfig() { + assertThat(Configuration.ApplicationL1CacheConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testSetResourceInformationalArtifacts() throws Exception { - Configuration testSubject; - Map<String, ArtifactTypeConfig> resourceInformationalArtifacts = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceInformationalArtifacts(resourceInformationalArtifacts); + public void validateBeanForApplicationL2CacheConfig() { + assertThat(Configuration.ApplicationL2CacheConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testGetVfModuleProperties() throws Exception { - Configuration testSubject; - Map<String, VfModuleProperty> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVfModuleProperties(); + public void validateBeanForToscaValidatorsConfig() { + assertThat(Configuration.ToscaValidatorsConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testSetVfModuleProperties() throws Exception { - Configuration testSubject; - Map<String, VfModuleProperty> vfModuleProperties = null; - - // default test - testSubject = createTestSubject(); - testSubject.setVfModuleProperties(vfModuleProperties); + public void validateBeanForApplicationL1CacheInfo() { + assertThat(Configuration.ApplicationL1CacheInfo.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testGetToscaConformanceLevel() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getToscaConformanceLevel(); + public void validateBeanForApplicationL1CacheCatalogInfo() { + assertThat(Configuration.ApplicationL1CacheCatalogInfo.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testSetToscaConformanceLevel() throws Exception { - Configuration testSubject; - String toscaConformanceLevel = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setToscaConformanceLevel(toscaConformanceLevel); + public void validateBeanForQueueInfo() { + assertThat(Configuration.QueueInfo.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testGetMinToscaConformanceLevel() throws Exception { - Configuration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getMinToscaConformanceLevel(); + public void validateBeanForEnvironmentContext() { + assertThat(Configuration.EnvironmentContext.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testSetMinToscaConformanceLevel() throws Exception { - Configuration testSubject; - String toscaConformanceLevel = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setMinToscaConformanceLevel(toscaConformanceLevel); + public void validateBeanForPathsAndNamesDefinition() { + assertThat(Configuration.PathsAndNamesDefinition.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testGetDefaultImports() throws Exception { - Configuration testSubject; - List<Map<String, Map<String, String>>> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDefaultImports(); + public void validateBeanForGabConfig() { + assertThat(Configuration.GabConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding() + )); } - - @Test - public void testSetDefaultImports() throws Exception { - Configuration testSubject; - LinkedList<Map<String, Map<String, String>>> defaultImports = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDefaultImports(defaultImports); - } } diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/DistributionEngineConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/DistributionEngineConfigurationTest.java index e357092529..cd6705dfdf 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/DistributionEngineConfigurationTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/DistributionEngineConfigurationTest.java @@ -3,6 +3,7 @@ * SDC * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nokia. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,568 +22,106 @@ package org.openecomp.sdc.be.config; import org.junit.Test; -import org.openecomp.sdc.be.config.DistributionEngineConfiguration.ComponentArtifactTypesConfig; -import org.openecomp.sdc.be.config.DistributionEngineConfiguration.CreateTopicConfig; -import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionNotificationTopicConfig; -import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionStatusTopicConfig; -import org.openecomp.sdc.common.http.config.ExternalServiceConfig; +import java.util.Collections; import java.util.List; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanToString; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; -public class DistributionEngineConfigurationTest { - - private DistributionEngineConfiguration createTestSubject() { - return new DistributionEngineConfiguration(); - } - - - @Test - public void testGetUebServers() throws Exception { - DistributionEngineConfiguration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUebServers(); - } - - - @Test - public void testSetUebServers() throws Exception { - DistributionEngineConfiguration testSubject; - List<String> uebServers = null; - - // default test - testSubject = createTestSubject(); - testSubject.setUebServers(uebServers); - } - - - @Test - public void testGetDistributionNotifTopicName() throws Exception { - DistributionEngineConfiguration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDistributionNotifTopicName(); - } - - - @Test - public void testSetDistributionNotifTopicName() throws Exception { - DistributionEngineConfiguration testSubject; - String distributionNotifTopicName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDistributionNotifTopicName(distributionNotifTopicName); - } - - - @Test - public void testGetDistributionStatusTopicName() throws Exception { - DistributionEngineConfiguration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDistributionStatusTopicName(); - } - - - @Test - public void testSetDistributionStatusTopicName() throws Exception { - DistributionEngineConfiguration testSubject; - String distributionStatusTopicName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDistributionStatusTopicName(distributionStatusTopicName); - } - - - @Test - public void testGetInitRetryIntervalSec() throws Exception { - DistributionEngineConfiguration testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInitRetryIntervalSec(); - } - - - @Test - public void testSetInitRetryIntervalSec() throws Exception { - DistributionEngineConfiguration testSubject; - Integer initRetryIntervalSec = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setInitRetryIntervalSec(initRetryIntervalSec); - } - - - @Test - public void testGetDistribNotifServiceArtifactTypes() throws Exception { - DistributionEngineConfiguration testSubject; - ComponentArtifactTypesConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDistribNotifServiceArtifactTypes(); - } - - - @Test - public void testSetDistribNotifServiceArtifactTypes() throws Exception { - DistributionEngineConfiguration testSubject; - ComponentArtifactTypesConfig distribNotifServiceArtifactTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDistribNotifServiceArtifactTypes(distribNotifServiceArtifactTypes); - } - - - @Test - public void testGetDistribNotifResourceArtifactTypes() throws Exception { - DistributionEngineConfiguration testSubject; - ComponentArtifactTypesConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDistribNotifResourceArtifactTypes(); - } - - - @Test - public void testSetDistribNotifResourceArtifactTypes() throws Exception { - DistributionEngineConfiguration testSubject; - ComponentArtifactTypesConfig distribNotifResourceArtifactTypes = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDistribNotifResourceArtifactTypes(distribNotifResourceArtifactTypes); - } - - - @Test - public void testGetUebPublicKey() throws Exception { - DistributionEngineConfiguration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUebPublicKey(); - } - - - @Test - public void testSetUebPublicKey() throws Exception { - DistributionEngineConfiguration testSubject; - String uebPublicKey = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setUebPublicKey(uebPublicKey); - } - - - @Test - public void testGetUebSecretKey() throws Exception { - DistributionEngineConfiguration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUebSecretKey(); - } - - - @Test - public void testSetUebSecretKey() throws Exception { - DistributionEngineConfiguration testSubject; - String uebSecretKey = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setUebSecretKey(uebSecretKey); - } - - - @Test - public void testGetEnvironments() throws Exception { - DistributionEngineConfiguration testSubject; - List<String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getEnvironments(); - } - - - - @Test - public void testSetEnvironments() throws Exception { - DistributionEngineConfiguration testSubject; - List<String> environments = null; - - // test 1 - testSubject = createTestSubject(); - environments = null; - testSubject.setEnvironments(environments); - } - - - @Test - public void testGetDistributionStatusTopic() throws Exception { - DistributionEngineConfiguration testSubject; - DistributionStatusTopicConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDistributionStatusTopic(); - } - - - @Test - public void testSetDistributionStatusTopic() throws Exception { - DistributionEngineConfiguration testSubject; - DistributionStatusTopicConfig distributionStatusTopic = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDistributionStatusTopic(distributionStatusTopic); - } - - - @Test - public void testGetInitMaxIntervalSec() throws Exception { - DistributionEngineConfiguration testSubject; - Integer result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInitMaxIntervalSec(); - } - - - @Test - public void testSetInitMaxIntervalSec() throws Exception { - DistributionEngineConfiguration testSubject; - Integer initMaxIntervalSec = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setInitMaxIntervalSec(initMaxIntervalSec); - } - - - @Test - public void testGetCreateTopic() throws Exception { - DistributionEngineConfiguration testSubject; - CreateTopicConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCreateTopic(); - } - - - @Test - public void testSetCreateTopic() throws Exception { - DistributionEngineConfiguration testSubject; - CreateTopicConfig createTopic = null; - - // default test - testSubject = createTestSubject(); - testSubject.setCreateTopic(createTopic); - } - - - @Test - public void testIsStartDistributionEngine() throws Exception { - DistributionEngineConfiguration testSubject; - boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.isStartDistributionEngine(); - } - - - @Test - public void testSetStartDistributionEngine() throws Exception { - DistributionEngineConfiguration testSubject; - boolean startDistributionEngine = false; - - // default test - testSubject = createTestSubject(); - testSubject.setStartDistributionEngine(startDistributionEngine); - } - - - @Test - public void testGetDistributionNotificationTopic() throws Exception { - DistributionEngineConfiguration testSubject; - DistributionNotificationTopicConfig result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDistributionNotificationTopic(); - } - - - @Test - public void testSetDistributionNotificationTopic() throws Exception { - DistributionEngineConfiguration testSubject; - DistributionNotificationTopicConfig distributionNotificationTopic = null; - - // default test - testSubject = createTestSubject(); - testSubject.setDistributionNotificationTopic(distributionNotificationTopic); - } - - - @Test - public void testGetDefaultArtifactInstallationTimeout() throws Exception { - DistributionEngineConfiguration testSubject; - int result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDefaultArtifactInstallationTimeout(); - } - - - @Test - public void testSetDefaultArtifactInstallationTimeout() throws Exception { - DistributionEngineConfiguration testSubject; - int defaultArtifactInstallationTimeout = 0; - - // default test - testSubject = createTestSubject(); - testSubject.setDefaultArtifactInstallationTimeout(defaultArtifactInstallationTimeout); - } - - - @Test - public void testIsUseHttpsWithDmaap() throws Exception { - DistributionEngineConfiguration testSubject; - boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.isUseHttpsWithDmaap(); - } - - - @Test - public void testSetUseHttpsWithDmaap() throws Exception { - DistributionEngineConfiguration testSubject; - boolean useHttpsWithDmaap = false; - - // default test - testSubject = createTestSubject(); - testSubject.setUseHttpsWithDmaap(useHttpsWithDmaap); - } - - - - @Test - public void testGetAaiConfig() throws Exception { - DistributionEngineConfiguration testSubject;ExternalServiceConfig result; - - // default test 1 - testSubject=createTestSubject();result=testSubject.getAaiConfig(); - } - - - - @Test - public void testGetAllowedTimeBeforeStaleSec() throws Exception { - DistributionEngineConfiguration testSubject;Integer result; - - // default test 1 - testSubject=createTestSubject();result=testSubject.getAllowedTimeBeforeStaleSec(); - } - - - - @Test - public void testGetCurrentArtifactInstallationTimeout() throws Exception { - DistributionEngineConfiguration testSubject;int result; - - // default test 1 - testSubject=createTestSubject();result=testSubject.getCurrentArtifactInstallationTimeout(); - } - - - - @Test - public void testGetCurrentArtifactInstallationTimeout_1() throws Exception { - DistributionEngineConfiguration testSubject;int result; - - // default test 1 - testSubject=createTestSubject();result=testSubject.getCurrentArtifactInstallationTimeout(); - } - - - - @Test - public void testSetCurrentArtifactInstallationTimeout() throws Exception { - DistributionEngineConfiguration testSubject;int currentArtifactInstallationTimeout = 0; - - - // default test - testSubject=createTestSubject();testSubject.setCurrentArtifactInstallationTimeout(currentArtifactInstallationTimeout); - } +public class DistributionEngineConfigurationTest { - @Test - public void testGetOpEnvRecoveryIntervalSec() throws Exception { - DistributionEngineConfiguration testSubject;Integer result; - - // default test - testSubject=createTestSubject();result=testSubject.getOpEnvRecoveryIntervalSec(); + public void validateBean() { + assertThat(DistributionEngineConfiguration.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding("environments") + )); } - - @Test - public void testSetOpEnvRecoveryIntervalSec() throws Exception { - DistributionEngineConfiguration testSubject;Integer opEnvRecoveryIntervalSec = 0; - - - // default test - testSubject=createTestSubject();testSubject.setOpEnvRecoveryIntervalSec(opEnvRecoveryIntervalSec); + public void validateDistribNotifServiceArtifactsBean() { + assertThat(DistributionEngineConfiguration.DistribNotifServiceArtifacts.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); } - - @Test - public void testGetAllowedTimeBeforeStaleSec_1() throws Exception { - DistributionEngineConfiguration testSubject;Integer result; - - // default test 1 - testSubject=createTestSubject();result=testSubject.getAllowedTimeBeforeStaleSec(); + public void validateNotifArtifactTypesBean() { + assertThat(DistributionEngineConfiguration.NotifArtifactTypes.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); } - - @Test - public void testSetAllowedTimeBeforeStaleSec() throws Exception { - DistributionEngineConfiguration testSubject;Integer allowedTimeBeforeStaleSec = 0; - - - // default test - testSubject=createTestSubject();testSubject.setAllowedTimeBeforeStaleSec(allowedTimeBeforeStaleSec); + public void validateNotifArtifactTypesResourceBean() { + assertThat(DistributionEngineConfiguration.NotifArtifactTypesResource.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); } - - @Test - public void testGetAaiConfig_1() throws Exception { - DistributionEngineConfiguration testSubject;ExternalServiceConfig result; - - // default test 1 - testSubject=createTestSubject();result=testSubject.getAaiConfig(); + public void validateCreateTopicConfigBean() { + assertThat(DistributionEngineConfiguration.CreateTopicConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters(), + hasValidBeanToString() + )); } - - @Test - public void testSetAaiConfig() throws Exception { - DistributionEngineConfiguration testSubject;ExternalServiceConfig aaiConfig = null; - - - // default test - testSubject=createTestSubject();testSubject.setAaiConfig(aaiConfig); + public void validateEnvironmentConfigBean() { + assertThat(DistributionEngineConfiguration.EnvironmentConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters(), + hasValidBeanToString() + )); } - - @Test - public void testGetMsoConfig() throws Exception { - DistributionEngineConfiguration testSubject;ExternalServiceConfig result; - - // default test - testSubject=createTestSubject();result=testSubject.getMsoConfig(); + public void validateDistributionStatusTopicConfigBean() { + assertThat(DistributionEngineConfiguration.DistributionStatusTopicConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters(), + hasValidBeanToString() + )); } - - @Test - public void testSetMsoConfig() throws Exception { - DistributionEngineConfiguration testSubject;ExternalServiceConfig msoConfig = null; - - - // default test - testSubject=createTestSubject();testSubject.setMsoConfig(msoConfig); - } - - private ComponentArtifactTypesConfig createTestSubject2() { - return new DistributionEngineConfiguration.ComponentArtifactTypesConfig(); + public void validateDistributionNotificationTopicConfigBean() { + assertThat(DistributionEngineConfiguration.DistributionNotificationTopicConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters(), + hasValidBeanToString() + )); } - @Test - public void testGetInfo() throws Exception { - ComponentArtifactTypesConfig testSubject; - List<String> result; - - // default test - testSubject = createTestSubject2(); - result = testSubject.getInfo(); + public void validateComponentArtifactTypesConfigBean() { + assertThat(DistributionEngineConfiguration.ComponentArtifactTypesConfig.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); } - @Test - public void testSetInfo() throws Exception { - ComponentArtifactTypesConfig testSubject; - List<String> info = null; + public void validateSetGetEnvironments() { + final String testEnvironment = "testEnvironment"; + DistributionEngineConfiguration distributionEngineConfiguration = new DistributionEngineConfiguration(); + distributionEngineConfiguration.setEnvironments(Collections.singletonList(testEnvironment)); - // default test - testSubject = createTestSubject2(); - testSubject.setInfo(info); - } - - - @Test - public void testGetLifecycle() throws Exception { - ComponentArtifactTypesConfig testSubject; - List<String> result; - - // default test - testSubject = createTestSubject2(); - result = testSubject.getLifecycle(); - } - - - @Test - public void testSetLifecycle() throws Exception { - ComponentArtifactTypesConfig testSubject; - List<String> lifecycle = null; - - // default test - testSubject = createTestSubject2(); - testSubject.setLifecycle(lifecycle); - } - - - @Test - public void testToString() throws Exception { - ComponentArtifactTypesConfig testSubject; - String result; + List<String> response = distributionEngineConfiguration.getEnvironments(); - // default test - testSubject = createTestSubject2(); - result = testSubject.toString(); + assertEquals(response.size(), 1); + assertEquals(response.get(0), testEnvironment); } - - } diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/DmeConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/DmeConfigurationTest.java new file mode 100644 index 0000000000..c54ec7fa86 --- /dev/null +++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/DmeConfigurationTest.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.config; + +import org.junit.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanToString; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +public class DmeConfigurationTest { + @Test + public void validateBean() { + assertThat(DmeConfiguration.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding(), + hasValidBeanToString() + )); + } +} diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/Neo4jErrorsConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/Neo4jErrorsConfigurationTest.java index 4d636f1196..3ecc802fdb 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/Neo4jErrorsConfigurationTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/Neo4jErrorsConfigurationTest.java @@ -3,6 +3,7 @@ * SDC * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nokia. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,50 +21,38 @@ package org.openecomp.sdc.be.config; +import java.util.Collections; import java.util.Map; import org.junit.Test; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanToString; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; -public class Neo4jErrorsConfigurationTest { - - private Neo4jErrorsConfiguration createTestSubject() { - return new Neo4jErrorsConfiguration(); - } - - - @Test - public void testGetErrors() throws Exception { - Neo4jErrorsConfiguration testSubject; - Map<String, String> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getErrors(); - } - +public class Neo4jErrorsConfigurationTest { @Test - public void testSetErrors() throws Exception { - Neo4jErrorsConfiguration testSubject; - Map<String, String> errors = null; - - // default test - testSubject = createTestSubject(); - testSubject.setErrors(errors); + public void validateBean() { + assertThat(Neo4jErrorsConfiguration.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSettersExcluding(), + hasValidBeanToString() + )); } - - - - - @Test - public void testToString() throws Exception { - Neo4jErrorsConfiguration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); + public void testGetErrorMessage() { + final String testKey = "key"; + final String testValue = "value"; + Neo4jErrorsConfiguration neo4jErrorsConfiguration = new Neo4jErrorsConfiguration(); + neo4jErrorsConfiguration.setErrors(Collections.singletonMap(testKey,testValue)); + + assertEquals( + neo4jErrorsConfiguration.getErrorMessage(testKey), + testValue + ); } } |