use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testPathSetupTypeTlvParser.
@Test
public void testPathSetupTypeTlvParser() throws PCEPDeserializerException {
final PathSetupTypeTlvParser parser = new PathSetupTypeTlvParser();
final PathSetupType pstTlv = new PathSetupTypeBuilder().setPst(Uint8.ZERO).build();
assertEquals(pstTlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(PST_TLV_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(pstTlv, buff);
assertArrayEquals(PST_TLV_BYTES, ByteArray.getAllBytes(buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testUnsupportedPSTSerializer.
@Test(expected = IllegalArgumentException.class)
public void testUnsupportedPSTSerializer() {
final PathSetupTypeTlvParser parser = new PathSetupTypeTlvParser();
final PathSetupType pstTlv = new PathSetupTypeBuilder().setPst(Uint8.ONE).build();
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(pstTlv, buff);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType in project bgpcep by opendaylight.
the class PathSetupTypeTlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
checkArgument(tlv instanceof PathSetupType, "PathSetupType is mandatory.");
final PathSetupType pstTlv = (PathSetupType) tlv;
checkArgument(checkPST(pstTlv.getPst()), UNSUPPORTED_PST);
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
body.writeZero(OFFSET);
ByteBufUtils.writeOrZero(body, pstTlv.getPst());
TlvUtil.formatTlv(TYPE, body, buffer);
}
Aggregations