47de56a24b0ef747675ed8c5592d736c39b86821
[genius.git] / networkutils / networkutils / src / test / java / org / opendaylight / genius / networkutils / test / NetworkUtilTestModule.java
1 /*
2  * Copyright © 2018 Ericsson India Global Services Pvt Ltd. 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.networkutils.test;
9
10 import static org.mockito.Mockito.mock;
11
12 import com.google.common.util.concurrent.ListeningExecutorService;
13 import com.google.common.util.concurrent.MoreExecutors;
14 import java.util.concurrent.Executors;
15 import org.opendaylight.daexim.DataImportBootReady;
16 import org.opendaylight.genius.idmanager.IdManager;
17 import org.opendaylight.genius.lockmanager.impl.LockManagerServiceImpl;
18 import org.opendaylight.genius.networkutils.RDUtils;
19 import org.opendaylight.genius.networkutils.VniUtils;
20 import org.opendaylight.genius.networkutils.impl.RDUtilsImpl;
21 import org.opendaylight.genius.networkutils.impl.VniUtilsImpl;
22 import org.opendaylight.infrautils.inject.guice.testutils.AbstractGuiceJsr250Module;
23 import org.opendaylight.mdsal.binding.api.DataBroker;
24 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractBaseDataBrokerTest;
25 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTestCustomizer;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockManagerService;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.networkutils.config.rev181129.NetworkConfig;
29
30 public class NetworkUtilTestModule extends AbstractGuiceJsr250Module {
31
32     @Override
33     protected void configureBindings() throws Exception {
34         AbstractBaseDataBrokerTest test = new AbstractBaseDataBrokerTest() {
35             @Override
36             protected AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
37                 return new AbstractDataBrokerTestCustomizer() {
38                     @Override
39                     public ListeningExecutorService getCommitCoordinatorExecutor() {
40                         return MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
41                     }
42                 };
43             }
44         };
45         test.setup();
46         DataBroker dataBroker = test.getDataBroker();
47         bind(DataBroker.class).toInstance(dataBroker);
48         bind(NetworkConfig.class).toInstance(mock(NetworkConfig.class));
49         bind(IdManagerService.class).to(IdManager.class);
50         bind(DataImportBootReady.class).toInstance(new DataImportBootReady() {});
51         bind(LockManagerService.class).to(LockManagerServiceImpl.class);
52         bind(VniUtils.class).to(VniUtilsImpl.class);
53         bind(RDUtils.class).to(RDUtilsImpl.class);
54     }
55 }