2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Samsung. All rights reserved.
6 * Modifications Copyright (C) 2019 Nokia.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.openecomp.sdc.be.config;
26 import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
27 import static org.hamcrest.MatcherAssert.assertThat;
28 import static org.junit.Assert.assertEquals;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.mockito.Mockito;
34 import org.mockito.junit.MockitoJUnitRunner;
35 import org.openecomp.sdc.common.api.ConfigurationListener;
36 import org.openecomp.sdc.common.api.ConfigurationSource;
37 import org.openecomp.sdc.common.config.EcompErrorConfiguration;
38 import org.openecomp.sdc.common.impl.ExternalConfiguration;
39 import org.openecomp.sdc.common.impl.FSConfigurationSource;
41 @RunWith(MockitoJUnitRunner.class)
42 public class ConfigurationManagerTest {
44 private ConfigurationManager configurationManager;
48 String appConfigDir = "src/test/resources/config/common";
49 ConfigurationSource configurationSource =
50 new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
51 configurationManager = new ConfigurationManager(configurationSource);
55 public void validateBean() {
56 assertThat(ConfigurationManager.class,
57 hasValidGettersAndSettersExcluding(
58 "distributionEngineConfiguration",
59 "ecompErrorConfiguration",
61 "neo4jErrorsConfiguration"
64 private class TestErrorConfiguration extends ErrorConfiguration{}
66 public void testGetSetErrorConfiguration() {
67 configurationManager.setErrorConfiguration(new TestErrorConfiguration());
69 configurationManager.getErrorConfiguration().getClass(),
70 TestErrorConfiguration.class);
72 private class TestEcompErrorConfiguration extends EcompErrorConfiguration{}
74 public void testGetSetEcompErrorConfiguration() {
75 configurationManager.setEcompErrorConfiguration(new TestEcompErrorConfiguration());
77 configurationManager.getEcompErrorConfiguration().getClass(),
78 TestEcompErrorConfiguration.class);
81 public void testGetDistributionEngineConfiguration() {
82 assertEquals(configurationManager.getDistributionEngineConfiguration(),
83 ConfigurationManager.getConfigurationManager().configurations
84 .get(DistributionEngineConfiguration.class.getSimpleName()));
86 private class TestConfiguration extends Configuration{}
88 public void testGetConfigurationAndWatch() {
89 ConfigurationListener testListener = Mockito.mock(ConfigurationListener.class);
90 configurationManager.setConfiguration(new TestConfiguration());
92 configurationManager.getConfigurationAndWatch(testListener).getClass(),
93 TestConfiguration.class