use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.auto.bandwidth.rev181109.bandwidth.usage.object.BandwidthUsage in project bgpcep by opendaylight.
the class PCEPBandwidthUsageObjectCodecTest method testCodec.
@Test
public void testCodec() throws PCEPDeserializerException {
final BandwidthUsageObjectCodec codec = new BandwidthUsageObjectCodec(5);
assertEquals(5, codec.getObjectType());
final BandwidthUsageBuilder builder = new BandwidthUsageBuilder().setBwSample(Lists.newArrayList(new Bandwidth(new byte[] { 0x00, 0x00, 0x10, 0x00 }), new Bandwidth(new byte[] { 0x00, 0x00, 0x40, 0x00 }))).setIgnore(false).setProcessingRule(false);
final BandwidthUsage parsedObject = codec.parseObject(new ObjectHeaderImpl(false, false), Unpooled.wrappedBuffer(BW_BYTES, 4, BW_BYTES.length - 4));
assertEquals(builder.build(), parsedObject);
final ByteBuf buffer = Unpooled.buffer(BW_BYTES.length);
codec.serializeObject(builder.build(), buffer);
assertArrayEquals(BW_BYTES, ByteArray.getAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.auto.bandwidth.rev181109.bandwidth.usage.object.BandwidthUsage in project bgpcep by opendaylight.
the class PcRptMessageCodecTest method testGetValidReportsPositive.
@Test
public void testGetValidReportsPositive() {
final PcRptMessageCodec codec = new PcRptMessageCodec(this.ctx.getObjectHandlerRegistry());
final BandwidthUsage bw = new BandwidthUsageBuilder().setBwSample(BW).build();
final Ipv4Builder builder = new Ipv4Builder();
builder.setIpv4TunnelSenderAddress(new Ipv4AddressNoZone("127.0.1.1"));
builder.setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(new Ipv4AddressNoZone("127.0.1.2")));
builder.setIpv4TunnelEndpointAddress(new Ipv4AddressNoZone("127.0.1.3"));
final AddressFamily afiLsp = new Ipv4CaseBuilder().setIpv4(builder.build()).build();
final LspId lspId = new LspId(Uint32.ONE);
final TunnelId tunnelId = new TunnelId(Uint16.ONE);
final LspIdentifiers identifier = new LspIdentifiersBuilder().setAddressFamily(afiLsp).setLspId(lspId).setTunnelId(tunnelId).build();
final Lsp lsp = new LspBuilder().setPlspId(new PlspId(Uint32.ONE)).setTlvs(new TlvsBuilder().setLspIdentifiers(identifier).build()).build();
final Ero ero = new EroBuilder().build();
final Queue<Object> objects = new ArrayDeque<>(List.of(lsp, ero, bw));
final Reports validReports = codec.getValidReports(objects, List.of());
assertNotNull(validReports.getPath().getBandwidth().augmentation(Bandwidth1.class));
assertTrue(objects.isEmpty());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.auto.bandwidth.rev181109.bandwidth.usage.object.BandwidthUsage in project bgpcep by opendaylight.
the class PcRptMessageCodecTest method testGetValidReportsNegative.
@Test
public void testGetValidReportsNegative() {
final PcRptMessageCodec codec = new PcRptMessageCodec(this.ctx.getObjectHandlerRegistry());
final BandwidthUsage bw = new BandwidthUsageBuilder().setBwSample(BW).build();
final Ipv4Builder builder = new Ipv4Builder();
builder.setIpv4TunnelSenderAddress(new Ipv4AddressNoZone("127.0.1.1"));
builder.setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(new Ipv4AddressNoZone("127.0.1.2")));
builder.setIpv4TunnelEndpointAddress(new Ipv4AddressNoZone("127.0.1.3"));
final Lsp lsp = new LspBuilder().setPlspId(new PlspId(Uint32.ONE)).build();
final Ero ero = new EroBuilder().build();
final Queue<Object> objects = new ArrayDeque<>(List.of(lsp, ero, bw));
final Reports validReports = codec.getValidReports(objects, new ArrayList<>());
assertNull(validReports);
}
Aggregations