2 * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
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
8 package org.opendaylight.netvirt.aclservice.tests;
10 import static org.mockito.Mockito.mock;
12 import com.google.inject.AbstractModule;
13 import org.mockito.Mockito;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
16 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
17 import org.opendaylight.genius.mdsalutil.interfaces.testutils.TestIMdsalApiManager;
18 import org.opendaylight.netvirt.aclservice.utils.AclClusterUtil;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.config.rev160806.AclserviceConfig;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.config.rev160806.AclserviceConfig.SecurityGroupMode;
23 * Test Dependency Injection (DI) Wiring (currently through Guice).
25 * @author Michael Vorburger
27 public class AclServiceTestModule extends AbstractModule {
30 protected void configure() {
31 install(new AclServiceModule());
33 bind(DataBroker.class).toInstance(DataBrokerTestModule.dataBroker());
34 bind(AclserviceConfig.class).toInstance(aclServiceConfig());
36 bind(AclClusterUtil.class).toInstance(() -> true);
38 TestIMdsalApiManager singleton = TestIMdsalApiManager.newInstance();
39 bind(IMdsalApiManager.class).toInstance(singleton);
40 bind(TestIMdsalApiManager.class).toInstance(singleton);
43 private AclserviceConfig aclServiceConfig() {
44 AclserviceConfig aclServiceConfig = mock(AclserviceConfig.class);
45 Mockito.when(aclServiceConfig.getSecurityGroupMode()).thenReturn(SecurityGroupMode.Stateful);
46 return aclServiceConfig;