Rename class LockManager to LockManagerServiceImpl and move package
[genius.git] / interfacemanager / interfacemanager-impl / src / test / java / org / opendaylight / genius / interfacemanager / test / InterfaceManagerTestModule.java
index b4940be5cffd0e9614c24d5100a44546357195a6..f99f8985758bced8935c7a8ade315c7e54fac65e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
+ * Copyright (c) 2016, 2017 Red Hat, Inc. and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -12,10 +12,12 @@ import static org.mockito.Mockito.mock;
 import java.net.UnknownHostException;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.daexim.DataImportBootReady;
+import org.opendaylight.genius.datastoreutils.testutils.JobCoordinatorEventsWaiter;
+import org.opendaylight.genius.datastoreutils.testutils.TestableJobCoordinatorEventsWaiter;
 import org.opendaylight.genius.idmanager.IdManager;
-import org.opendaylight.genius.idmanager.IdUtils;
+import org.opendaylight.genius.interfacemanager.InterfacemgrProvider;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.interfacemanager.listeners.CacheBridgeEntryConfigListener;
 import org.opendaylight.genius.interfacemanager.listeners.CacheBridgeRefEntryListener;
 import org.opendaylight.genius.interfacemanager.listeners.HwVTEPConfigListener;
@@ -29,40 +31,30 @@ import org.opendaylight.genius.interfacemanager.listeners.VlanMemberConfigListen
 import org.opendaylight.genius.interfacemanager.rpcservice.InterfaceManagerRpcService;
 import org.opendaylight.genius.interfacemanager.servicebindings.flowbased.listeners.FlowBasedServicesConfigListener;
 import org.opendaylight.genius.interfacemanager.servicebindings.flowbased.listeners.FlowBasedServicesInterfaceStateListener;
-import org.opendaylight.genius.interfacemanager.test.infra.TestEntityOwnershipService;
+import org.opendaylight.genius.lockmanager.impl.LockListener;
+import org.opendaylight.genius.lockmanager.impl.LockManagerServiceImpl;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.genius.mdsalutil.interfaces.testutils.TestIMdsalApiManager;
-import org.opendaylight.infrautils.inject.ModuleSetupRuntimeException;
 import org.opendaylight.infrautils.inject.guice.testutils.AbstractGuiceJsr250Module;
-import org.opendaylight.lockmanager.LockManager;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.AlivenessMonitorService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockManagerService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Dependency Injection Wiring for {@link InterfaceManagerConfigurationTest}.
  *
- * <p>This class looks a little bit more complicated than it could and later will be
- * just because interfacemanager is still using CSS instead of BP with @Inject.
- *
- * <p>Please DO NOT copy/paste this class as-is into other projects; this is intended
- * to be temporary, until interfacemanager is switch from CSS to BP.
- *
- * <p>For "proper" *Module examples, please see the AclServiceModule and
+ * <p>
+ * For other *Module examples, please see the AclServiceModule and
  * AclServiceTestModule or ElanServiceTestModule instead.
  *
  * @author Michael Vorburger
  */
 public class InterfaceManagerTestModule extends AbstractGuiceJsr250Module {
 
-    private static final Logger LOG = LoggerFactory.getLogger(InterfaceManagerTestModule.class);
-
     @Override
     protected void configureBindings() throws UnknownHostException {
-        // TODO Ordering as below.. hard to do currently, because of interdeps. due to CSS
         // Bindings for services from this project
         // Bindings for external services to "real" implementations
         // Bindings to test infra (fakes & mocks)
@@ -70,24 +62,18 @@ public class InterfaceManagerTestModule extends AbstractGuiceJsr250Module {
         DataBroker dataBroker = DataBrokerTestModule.dataBroker();
         bind(DataBroker.class).toInstance(dataBroker);
 
-        LockManagerService lockManager = new LockManager(dataBroker);
-        bind(LockManagerService.class).toInstance(lockManager);
+        bind(DataImportBootReady.class).toInstance(new DataImportBootReady() {});
 
-        IdUtils idUtils = new IdUtils();
-        IdManagerService idManager;
-        try {
-            idManager = new IdManager(dataBroker, lockManager, idUtils);
-        } catch (ReadFailedException e) {
-            // TODO Support AbstractGuiceJsr250Module
-            throw new ModuleSetupRuntimeException(e);
-        }
-        bind(IdManagerService.class).toInstance(idManager);
+        bind(LockManagerService.class).to(LockManagerServiceImpl.class);
+        bind(LockListener.class);
+        bind(IdManagerService.class).to(IdManager.class);
+        bind(IInterfaceManager.class).to(InterfacemgrProvider.class);
 
         TestIMdsalApiManager mdsalManager = TestIMdsalApiManager.newInstance();
         bind(IMdsalApiManager.class).toInstance(mdsalManager);
         bind(TestIMdsalApiManager.class).toInstance(mdsalManager);
 
-        EntityOwnershipService entityOwnershipService = TestEntityOwnershipService.newInstance();
+        EntityOwnershipService entityOwnershipService = mock(EntityOwnershipService.class);
         bind(EntityOwnershipService.class).toInstance(entityOwnershipService);
 
         bind(AlivenessMonitorService.class).toInstance(mock(AlivenessMonitorService.class));
@@ -104,5 +90,6 @@ public class InterfaceManagerTestModule extends AbstractGuiceJsr250Module {
         bind(TerminationPointStateListener.class);
         bind(VlanMemberConfigListener.class);
         bind(InterfaceStateListener.class);
+        bind(JobCoordinatorEventsWaiter.class).to(TestableJobCoordinatorEventsWaiter.class);
     }
 }