use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDuration in project bgpcep by opendaylight.
the class OverloadedDurationTlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
checkArgument(tlv instanceof OverloadDuration, "OverloadedTlv is mandatory.");
final ByteBuf body = Unpooled.buffer();
ByteBufUtils.writeOrZero(body, ((OverloadDuration) tlv).getDuration());
TlvUtil.formatTlv(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDuration in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testOverloadedDurationTlv.
@Test
public void testOverloadedDurationTlv() throws PCEPDeserializerException {
final OverloadedDurationTlvParser parser = new OverloadedDurationTlvParser();
final OverloadDuration tlv = new OverloadDurationBuilder().setDuration(Uint32.valueOf(0x7FFFFFFFL)).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(OVERLOADED_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(OVERLOADED_BYTES, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
Aggregations