Add Unit Tests
[holmes/common.git] / holmes-actions / src / test / java / org / onap / holmes / common / dropwizard / ioc / bundle / AutoConfigBundleTest.java
1 /*
2  * Copyright 2017 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.holmes.common.dropwizard.ioc.bundle;
17
18 import com.codahale.metrics.MetricRegistry;
19 import com.fasterxml.jackson.databind.ObjectMapper;
20 import io.dropwizard.Configuration;
21 import io.dropwizard.setup.Bootstrap;
22 import io.dropwizard.setup.Environment;
23 import org.junit.Test;
24
25 import javax.validation.ConstraintViolation;
26 import javax.validation.Validator;
27 import javax.validation.executable.ExecutableValidator;
28 import javax.validation.metadata.BeanDescriptor;
29
30 import java.util.Set;
31
32 import static org.hamcrest.CoreMatchers.instanceOf;
33 import static org.junit.Assert.assertThat;
34
35 public class AutoConfigBundleTest {
36     @Test
37     public void newBuilder() throws Exception {
38         assertThat(AutoConfigBundle.newBuilder(), instanceOf(AutoConfigBundleBuider.class));
39     }
40
41     @Test
42     public void initialize() throws Exception {
43         AutoConfigBundle.newBuilder().build().initialize(new Bootstrap<>(new IOCApplication<Configuration>() {
44             @Override
45             public void initialize(Bootstrap<Configuration> bootstrap) {
46                 super.initialize(bootstrap);
47             }
48         }));
49     }
50
51     @Test
52     public void run() throws Exception {
53         AutoConfigBundle.newBuilder().build().run(new Configuration(), new Environment(
54                 "Test", new ObjectMapper(), new Validator() {
55             @Override
56             public <T> Set<ConstraintViolation<T>> validate(T t, Class<?>... classes) {
57                 return null;
58             }
59
60             @Override
61             public <T> Set<ConstraintViolation<T>> validateProperty(T t, String s, Class<?>... classes) {
62                 return null;
63             }
64
65             @Override
66             public <T> Set<ConstraintViolation<T>> validateValue(Class<T> aClass, String s, Object o, Class<?>... classes) {
67                 return null;
68             }
69
70             @Override
71             public BeanDescriptor getConstraintsForClass(Class<?> aClass) {
72                 return null;
73             }
74
75             @Override
76             public <T> T unwrap(Class<T> aClass) {
77                 return null;
78             }
79
80             @Override
81             public ExecutableValidator forExecutables() {
82                 return null;
83             }
84         }, new MetricRegistry(), ClassLoader.getSystemClassLoader()
85         ));
86     }
87
88 }