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;
@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());
@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
}
});
- 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();
@Test
public void testCreateRequestContext() throws Exception {
roleContext.createRequestContext();
- Mockito.verify(conductor).reserveXidForDeviceMessage(nodeId);
+ Mockito.verify(conductor).reserveXidForDeviceMessage(deviceInfo);
}
@Test(expected = NullPointerException.class)
@Test
public void testGetNodeId() throws Exception {
- Assert.assertTrue(roleContext.getNodeId().equals(nodeId));
+ Assert.assertTrue(roleContext.getDeviceInfo().getNodeId().equals(nodeId));
}
@Test