Open Kilda Java Documentation
DefaultConfigurationTest.java
Go to the documentation of this file.
1 /* Copyright 2018 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.config;
17 
18 import static java.util.Collections.emptyMap;
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertNull;
21 
22 import com.sabre.oss.conf4j.annotation.Configuration;
23 import com.sabre.oss.conf4j.annotation.Key;
24 import com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory;
25 import com.sabre.oss.conf4j.source.MapConfigurationSource;
26 import org.junit.Test;
27 
29  private JdkProxyStaticConfigurationFactory factory = new JdkProxyStaticConfigurationFactory();
30 
31  @Test
33  // given
34  MapConfigurationSource source = new MapConfigurationSource(emptyMap());
35 
36  // when
37  KafkaTopicsConfig kafkaTopicsConfig = factory.createConfiguration(KafkaTopicsConfig.class, source);
38 
39  // then
40  assertEquals("kilda.ctrl", kafkaTopicsConfig.getCtrlTopic());
41  }
42 
43  @Test
44  public void shouldBeNullIfKeyAbsent() {
45  // given
46  MapConfigurationSource source = new MapConfigurationSource(emptyMap());
47 
48  // when
49  TestConfig testConfig = factory.createConfiguration(TestConfig.class, source);
50 
51  // then
52  assertNull(testConfig.getTestProperty());
53  }
54 
55  @Configuration
56  public interface TestConfig {
57  @Key("test_key")
58  Integer getTestProperty();
59  }
60 }
source
Definition: nodes.py:53