X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Frole%2FRoleContextImplTest.java;h=0f3ec3c5c151934c659a593dd36895de10857062;hb=867da8f64fbc12f407db3d41e96b216f7f62eb5b;hp=a427fbbe0bb3ee90cc72309599f3ad20e74a3b36;hpb=b977adac522d210e9fea06b77a40f8bd87c2d193;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleContextImplTest.java index a427fbbe0b..0f3ec3c5c1 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/role/RoleContextImplTest.java @@ -21,6 +21,7 @@ import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlready import org.opendaylight.controller.md.sal.common.api.clustering.Entity; import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration; import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; +import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor; import org.opendaylight.openflowplugin.api.openflow.role.RoleContext; import org.opendaylight.openflowplugin.api.openflow.role.RoleManager; @@ -42,6 +43,9 @@ public class RoleContextImplTest { @Mock private LifecycleConductor conductor; + @Mock + private DeviceInfo deviceInfo; + private final NodeId nodeId = NodeId.getDefaultInstance("openflow:1"); private final Entity entity = new Entity(RoleManager.ENTITY_TYPE, nodeId.getValue()); private final Entity txEntity = new Entity(RoleManager.TX_ENTITY_TYPE, nodeId.getValue()); @@ -49,9 +53,10 @@ public class RoleContextImplTest { @Before public void setup() throws CandidateAlreadyRegisteredException { - roleContext = new RoleContextImpl(nodeId, entityOwnershipService, entity, txEntity, conductor); + roleContext = new RoleContextImpl(deviceInfo, entityOwnershipService, entity, txEntity, conductor); Mockito.when(entityOwnershipService.registerCandidate(entity)).thenReturn(entityOwnershipCandidateRegistration); Mockito.when(entityOwnershipService.registerCandidate(txEntity)).thenReturn(entityOwnershipCandidateRegistration); + Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId); } //@Test @@ -68,20 +73,14 @@ public class RoleContextImplTest { } }); - Thread t1 = new Thread(new Runnable() { - @Override - public void run() { - LOG.info("Starting thread 1"); - Assert.assertTrue(roleContext.initialization()); - } + Thread t1 = new Thread(() -> { + LOG.info("Starting thread 1"); + Assert.assertTrue(roleContext.initialization()); }); - Thread t2 = new Thread(new Runnable() { - @Override - public void run() { - LOG.info("Starting thread 2"); - Assert.assertFalse(roleContext.initialization()); - } + Thread t2 = new Thread(() -> { + LOG.info("Starting thread 2"); + Assert.assertFalse(roleContext.initialization()); }); t1.start(); @@ -108,7 +107,7 @@ public class RoleContextImplTest { @Test public void testCreateRequestContext() throws Exception { roleContext.createRequestContext(); - Mockito.verify(conductor).reserveXidForDeviceMessage(nodeId); + Mockito.verify(conductor).reserveXidForDeviceMessage(deviceInfo); } @Test(expected = NullPointerException.class) @@ -128,7 +127,7 @@ public class RoleContextImplTest { @Test public void testGetNodeId() throws Exception { - Assert.assertTrue(roleContext.getNodeId().equals(nodeId)); + Assert.assertTrue(roleContext.getDeviceInfo().getNodeId().equals(nodeId)); } @Test