2 * Copyright 2017 ZTE Corporation.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onap.holmes.common.dropwizard.ioc.bundle;
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;
25 import javax.validation.ConstraintViolation;
26 import javax.validation.Validator;
27 import javax.validation.executable.ExecutableValidator;
28 import javax.validation.metadata.BeanDescriptor;
32 import static org.hamcrest.CoreMatchers.instanceOf;
33 import static org.junit.Assert.assertThat;
35 public class AutoConfigBundleTest {
37 public void newBuilder() throws Exception {
38 assertThat(AutoConfigBundle.newBuilder(), instanceOf(AutoConfigBundleBuider.class));
42 public void initialize() throws Exception {
43 AutoConfigBundle.newBuilder().build().initialize(new Bootstrap<>(new IOCApplication<Configuration>() {
45 public void initialize(Bootstrap<Configuration> bootstrap) {
46 super.initialize(bootstrap);
52 public void run() throws Exception {
53 AutoConfigBundle.newBuilder().build().run(new Configuration(), new Environment(
54 "Test", new ObjectMapper(), new Validator() {
56 public <T> Set<ConstraintViolation<T>> validate(T t, Class<?>... classes) {
61 public <T> Set<ConstraintViolation<T>> validateProperty(T t, String s, Class<?>... classes) {
66 public <T> Set<ConstraintViolation<T>> validateValue(Class<T> aClass, String s, Object o, Class<?>... classes) {
71 public BeanDescriptor getConstraintsForClass(Class<?> aClass) {
76 public <T> T unwrap(Class<T> aClass) {
81 public ExecutableValidator forExecutables() {
84 }, new MetricRegistry(), ClassLoader.getSystemClassLoader()