c.add(Calendar.SECOND, 1);
Entity entity3 = new Entity(1L, null, null, 10L, 1, c.getTime());
c.add(Calendar.SECOND, 1);
Entity entity4 = new Entity(1L, null, null, 50L, 1, c.getTime());
IDevice d;
SwitchPort[] aps;
Integer[] ips;
mockListener.deviceAdded(isA(IDevice.class));
mockListener.deviceIPV4AddrChanged((isA(IDevice.class)));
replay(mockListener);
// TODO: we currently do learn entities on suppressed APs
// // cannot learn device on suppressed AP
// d = deviceManager.learnDeviceByEntity(entity1);
// assertNull(d);
deviceManager.learnDeviceByEntity(entity0);
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertEquals(aps.length, 0);
verifyEntityArray(new Entity[] { entity0, entity1} , (Device)d);
ips = d.getIPv4Addresses();
assertArrayEquals(new Integer[] { 1 }, ips);
verify(mockListener);
reset(mockListener);
mockListener.deviceMoved((isA(IDevice.class)));
//mockListener.deviceIPV4AddrChanged((isA(IDevice.class)));
replay(mockListener);
d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(5L, 1) }, aps);
verifyEntityArray(new Entity[] { entity0, entity1, entity2 } , (Device)d);
ips = d.getIPv4Addresses();
assertArrayEquals(new Integer[] { 1 }, ips);
verify(mockListener);
reset(mockListener);
replay(mockListener);
d = deviceManager.learnDeviceByEntity(entity3);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(5L, 1) }, aps);
verifyEntityArray(new Entity[] { entity0, entity1, entity2, entity3 } , (Device)d);
ips = d.getIPv4Addresses();
assertArrayEquals(new Integer[] { 1 }, ips);
verify(mockListener);
reset(mockListener);
mockListener.deviceMoved((isA(IDevice.class)));
replay(mockListener);
d = deviceManager.learnDeviceByEntity(entity4);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(5L, 1),
new SwitchPort(50L, 1) }, aps);
verifyEntityArray(new Entity[] { entity0, entity1, entity2, entity3, entity4} , (Device)d);
ips = d.getIPv4Addresses();
assertArrayEquals(new Integer[] { 1 }, ips);
verify(mockListener);
}