use of org.onosproject.net.device.DeviceEvent in project onos by opennetworkinglab.
the class MQEventHandlerTest method switchAdd.
@Test
public void switchAdd() {
DeviceEvent de = deviceEvent(DEVICE_ADDED, DID1);
deviceListener.event(de);
}
use of org.onosproject.net.device.DeviceEvent in project fabric-tna by stratum.
the class IntManagerTest method testAddDevice.
/**
* Test sending new device event to trigger device config update.
*/
@Test
public void testAddDevice() {
testActivateWithConfig();
DeviceListener listener = deviceListener.getValue();
CompletableFuture<Void> completableFuture = new CompletableFuture<>();
Device newDevice = createMock(Device.class);
IntProgrammable newIntProgrammable = createMock(IntProgrammable.class);
expect(newDevice.id()).andReturn(DEVICE_ID_2).anyTimes();
expect(newDevice.is(IntProgrammable.class)).andReturn(true).anyTimes();
expect(newDevice.as(IntProgrammable.class)).andReturn(newIntProgrammable).anyTimes();
expect(newIntProgrammable.init()).andReturn(true).once();
expect(newIntProgrammable.setUpIntConfig(INT_CONFIG_1)).andAnswer(() -> {
completableFuture.complete(null);
return true;
}).once();
replay(newDevice, newIntProgrammable);
DeviceEvent deviceEvent = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, newDevice);
listener.event(deviceEvent);
try {
completableFuture.get(1, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
fail("Didn't get expected call within 1 second.");
}
verifyAll();
}
Aggregations