@Test public final void testGetPorts() { putDevice(DID1, SW1); putDevice(DID2, SW1); List<PortDescription> pds = Arrays.<PortDescription>asList( new DefaultPortDescription(P1, true), new DefaultPortDescription(P2, true) ); deviceStore.updatePorts(PID, DID1, pds); Set<PortNumber> expectedPorts = Sets.newHashSet(P1, P2); List<Port> ports = deviceStore.getPorts(DID1); for (Port port : ports) { assertTrue("Port is enabled", port.isEnabled()); assertTrue("PortNumber is one of expected", expectedPorts.remove(port.number())); } assertTrue("Event for all expectedport appeared", expectedPorts.isEmpty()); assertTrue("DID2 has no ports", deviceStore.getPorts(DID2).isEmpty()); }
@Override public List<Port> getPorts(DeviceId deviceId) { Map<PortNumber, Port> ports = devicePorts.get(deviceId); if (ports == null) { return Collections.emptyList(); } return ImmutableList.copyOf(ports.values()); }
GossipDeviceStore extends AbstractStore<DeviceEvent, DeviceStoreDelegate> implements DeviceStore { @Override public List<Port> getPorts(DeviceId deviceId) { Map<PortNumber, Port> ports = devicePorts.get(deviceId); if (ports == null) { return Collections.emptyList(); } return ImmutableList.copyOf(ports.values()); } }
GossipDeviceStore extends AbstractStore<DeviceEvent, DeviceStoreDelegate> implements DeviceStore { @Override public List<Port> getPorts(DeviceId deviceId) { Map<PortNumber, Port> ports = devicePorts.get(deviceId); if (ports == null) { return Collections.emptyList(); } return ImmutableList.copyOf(ports.values()); }  }
GossipDeviceStore extends AbstractStore<DeviceEvent, DeviceStoreDelegate> implements DeviceStore { @Override public List<Port> getPorts(DeviceId deviceId) { Map<PortNumber, Port> ports = devicePorts.get(deviceId); if (ports == null) { return Collections.emptyList(); } return ImmutableList.copyOf(ports.values()); }  @Activate void activate(); @Deactivate void deactivate(); @Override int getDeviceCount(); @Override Iterable<Device> getDevices(); @Override Iterable<Device> getAvailableDevices(); @Override Device getDevice(DeviceId deviceId); @Override synchronized DeviceEvent createOrUpdateDevice(ProviderId providerId,
                                                         DeviceId deviceId,
                                                         DeviceDescription deviceDescription); @Override DeviceEvent markOffline(DeviceId deviceId); @Override synchronized List<DeviceEvent> updatePorts(ProviderId providerId,
                                                      DeviceId deviceId,
                                                      List<PortDescription> portDescriptions); @Override synchronized DeviceEvent updatePortStatus(ProviderId providerId,
                                                     DeviceId deviceId,
                                                     PortDescription portDescription); @Override List<Port> getPorts(DeviceId deviceId); @Override DeviceEvent updatePortStatistics(ProviderId providerId, DeviceId deviceId,
                                            Collection<PortStatistics> newStatsCollection); PortStatistics calcDeltaStats(DeviceId deviceId, PortStatistics prvStats, PortStatistics newStats); @Override List<PortStatistics> getPortStatistics(DeviceId deviceId); @Override List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId); @Override Port getPort(DeviceId deviceId, PortNumber portNumber); @Override boolean isAvailable(DeviceId deviceId); @Override synchronized DeviceEvent removeDevice(DeviceId deviceId); }
GossipDeviceStore extends AbstractStore<DeviceEvent, DeviceStoreDelegate> implements DeviceStore { @Override public List<Port> getPorts(DeviceId deviceId) { Map<PortNumber, Port> ports = devicePorts.get(deviceId); if (ports == null) { return Collections.emptyList(); } return ImmutableList.copyOf(ports.values()); }  @Activate void activate(); @Deactivate void deactivate(); @Override int getDeviceCount(); @Override Iterable<Device> getDevices(); @Override Iterable<Device> getAvailableDevices(); @Override Device getDevice(DeviceId deviceId); @Override synchronized DeviceEvent createOrUpdateDevice(ProviderId providerId,
                                                         DeviceId deviceId,
                                                         DeviceDescription deviceDescription); @Override DeviceEvent markOffline(DeviceId deviceId); @Override synchronized List<DeviceEvent> updatePorts(ProviderId providerId,
                                                      DeviceId deviceId,
                                                      List<PortDescription> portDescriptions); @Override synchronized DeviceEvent updatePortStatus(ProviderId providerId,
                                                     DeviceId deviceId,
                                                     PortDescription portDescription); @Override List<Port> getPorts(DeviceId deviceId); @Override DeviceEvent updatePortStatistics(ProviderId providerId, DeviceId deviceId,
                                            Collection<PortStatistics> newStatsCollection); PortStatistics calcDeltaStats(DeviceId deviceId, PortStatistics prvStats, PortStatistics newStats); @Override List<PortStatistics> getPortStatistics(DeviceId deviceId); @Override List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId); @Override Port getPort(DeviceId deviceId, PortNumber portNumber); @Override boolean isAvailable(DeviceId deviceId); @Override synchronized DeviceEvent removeDevice(DeviceId deviceId);  }