Open Kilda Java Documentation
SecondsToMilisConverterTest.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.wfm.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.Converter;
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 
30  private JdkProxyStaticConfigurationFactory factory = new JdkProxyStaticConfigurationFactory();
31 
32  @Test
33  public void shouldConvertToMillis() {
34  // given
35  MapConfigurationSource source = new MapConfigurationSource(ImmutableMap.of("test_key", "10"));
36 
37  // when
38  TestConfig config = factory.createConfiguration(TestConfig.class, source);
39 
40  // then
41  assertEquals(10000, config.getTestProperty());
42  }
43 
44  @Configuration
45  public interface TestConfig {
46  @Key("test_key")
47  @Converter(SecondsToMilisConverter.class)
48  int getTestProperty();
49  }
50 }
source
Definition: nodes.py:53