Integrate controller-2.0.1
[genius.git] / mdsalutil / mdsalutil-testutils / src / main / java / org / opendaylight / genius / datastoreutils / testutils / DataBrokerFailuresModule.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.genius.datastoreutils.testutils;
9
10 import com.google.inject.AbstractModule;
11 import org.opendaylight.mdsal.binding.api.DataBroker;
12 import org.opendaylight.mdsal.binding.testutils.DataBrokerTestModule;
13
14 /**
15  * Guice Module which correctly binds the {@link DataBrokerFailures}.
16  *
17  * @author Michael Vorburger.ch
18  */
19 public class DataBrokerFailuresModule extends AbstractModule {
20
21     private final DataBroker realDataBroker;
22
23     public DataBrokerFailuresModule(DataBroker realDataBroker) {
24         this.realDataBroker = realDataBroker;
25     }
26
27     public DataBrokerFailuresModule() throws Exception {
28         this(DataBrokerTestModule.dataBroker());
29     }
30
31     @Override
32     protected void configure() {
33         DataBrokerFailuresImpl testableDataBroker = new DataBrokerFailuresImpl(realDataBroker);
34         bind(DataBroker.class).toInstance(testableDataBroker);
35         // bind(DataBroker.class).annotatedWith(Reference.class).toInstance(testableDataBroker);
36         bind(DataBrokerFailures.class).toInstance(testableDataBroker);
37     }
38 }