Open Kilda Java Documentation
CompositeConfigurationTest.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 org.junit.Assert.assertEquals;
19 
20 import com.google.common.collect.ImmutableMap;
21 import com.sabre.oss.conf4j.annotation.Configuration;
22 import com.sabre.oss.conf4j.annotation.IgnoreKey;
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(ImmutableMap.of("test_key", "10"));
35 
36  // when
37  TestCompositeConfig testCompositeConfig = factory.createConfiguration(TestCompositeConfig.class, source);
38 
39  // then
40  assertEquals(10, testCompositeConfig.getTestProperty());
41  }
42 
43  @Configuration
44  public interface TestCompositeConfig {
45  @IgnoreKey
47 
48  default int getTestProperty() {
50  }
51  }
52 
53  @Configuration
54  public interface TestComponentConfig {
55  @Key("test_key")
56  int getTestProperty();
57  }
58 }
source
Definition: nodes.py:53