use of org.onosproject.net.device.PortDescription in project onos by opennetworkinglab.
the class OpticalPortOperatorTest method testEmptyConfig.
@Test
public void testEmptyConfig() {
opc.portType(Port.Type.ODUCLT).portNumberName(PORT_NUMBER);
PortDescription res;
res = oper.combine(CP, N_DESC);
assertEquals("Configured port name expected", DESC_PORT_NAME, res.portNumber().name());
assertEquals(DESC_STATIC_PORT, res.annotations().value(AnnotationKeys.STATIC_PORT));
}
use of org.onosproject.net.device.PortDescription in project onos by opennetworkinglab.
the class OpticalPortOperatorTest method testConfigPortName.
@Test
public void testConfigPortName() {
opc.portType(Port.Type.ODUCLT).portNumberName(PORT_NUMBER).portName(CFG_PORT_NAME);
PortDescription res;
// full desc + opc with name
res = oper.combine(CP, N_DESC);
assertEquals("Configured port name expected", CFG_PORT_NAME, res.portNumber().name());
assertEquals(DESC_STATIC_PORT, res.annotations().value(AnnotationKeys.STATIC_PORT));
res = oper.combine(CP, U_DESC);
assertEquals("Configured port name expected", CFG_PORT_NAME, res.portNumber().name());
assertEquals(DESC_STATIC_PORT, res.annotations().value(AnnotationKeys.STATIC_PORT));
}
use of org.onosproject.net.device.PortDescription in project onos by opennetworkinglab.
the class OmsPortHelperTest method testOmsPortDescriptionCanBeConvertedToOmsPort.
@Test
public void testOmsPortDescriptionCanBeConvertedToOmsPort() {
PortNumber pn = PortNumber.portNumber(4900);
boolean isEnabled = true;
String anKey = "Base";
String anValue = "value";
SparseAnnotations an = DefaultAnnotations.builder().set(anKey, anValue).build();
Frequency minF = Frequency.ofGHz(3);
Frequency maxF = Frequency.ofGHz(33);
Frequency grid = Frequency.ofGHz(2);
PortDescription portDescription = OmsPortHelper.omsPortDescription(pn, isEnabled, minF, maxF, grid, an);
Port port = new DefaultPort(DEV, portDescription.portNumber(), portDescription.isEnabled(), portDescription.type(), portDescription.portSpeed(), portDescription.annotations());
Optional<OmsPort> maybeOms = OmsPortHelper.asOmsPort(port);
assertTrue(maybeOms.isPresent());
OmsPort oms = maybeOms.get();
assertThat(oms.isEnabled(), is(isEnabled));
assertThat(oms.number(), is(pn));
assertThat(oms.annotations().value(anKey), is(anValue));
assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
assertThat(oms.maxFrequency(), is(maxF));
assertThat(oms.minFrequency(), is(minF));
assertThat(oms.grid(), is(grid));
assertThat("((33-3)/2)+1 = 16", oms.totalChannels(), is((short) 16));
}
use of org.onosproject.net.device.PortDescription in project onos by opennetworkinglab.
the class SimpleDeviceStoreTest method testGetPort.
@Test
public final void testGetPort() {
putDevice(DID1, SW1);
putDevice(DID2, SW1);
List<PortDescription> pds = Arrays.asList(DefaultPortDescription.builder().withPortNumber(P1).isEnabled(true).build(), DefaultPortDescription.builder().withPortNumber(P2).isEnabled(false).build());
deviceStore.updatePorts(PID, DID1, pds);
Port port1 = deviceStore.getPort(DID1, P1);
assertEquals(P1, port1.number());
assertTrue("Port is enabled", port1.isEnabled());
Port port2 = deviceStore.getPort(DID1, P2);
assertEquals(P2, port2.number());
assertFalse("Port is disabled", port2.isEnabled());
Port port3 = deviceStore.getPort(DID1, P3);
assertNull("P3 not expected", port3);
}
use of org.onosproject.net.device.PortDescription in project onos by opennetworkinglab.
the class SimpleDeviceStoreTest method testUpdatePortStatus.
@Test
public final void testUpdatePortStatus() {
putDevice(DID1, SW1);
List<PortDescription> pds = Arrays.asList(DefaultPortDescription.builder().withPortNumber(P1).isEnabled(true).build());
deviceStore.updatePorts(PID, DID1, pds);
DeviceEvent event = deviceStore.updatePortStatus(PID, DID1, DefaultPortDescription.builder().withPortNumber(P1).isEnabled(false).build());
assertEquals(PORT_UPDATED, event.type());
assertDevice(DID1, SW1, event.subject());
assertEquals(P1, event.port().number());
assertFalse("Port is disabled", event.port().isEnabled());
}
Aggregations