use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.PathKeyBuilder in project bgpcep by opendaylight.
the class PcepRROSubobjectParserTest method testRROPathKey32Subobject.
@Test
public void testRROPathKey32Subobject() throws PCEPDeserializerException {
final RROPathKey32SubobjectParser parser = new RROPathKey32SubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder();
final PathKeyBuilder pBuilder = new PathKeyBuilder().setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 })).setPathKey(new PathKey(Uint16.valueOf(4660)));
subs.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(PATH_KEY32_BYTES, 2))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(PATH_KEY32_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.PathKeyBuilder in project bgpcep by opendaylight.
the class PcepXROSubobjectParserTest method testXROPathKey128Subobject.
@Test
public void testXROPathKey128Subobject() throws PCEPDeserializerException {
final XROPathKey128SubobjectParser parser = new XROPathKey128SubobjectParser();
final PathKeyBuilder pBuilder = new PathKeyBuilder().setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 })).setPathKey(new PathKey(Uint16.valueOf(4660)));
final SubobjectBuilder subs = new SubobjectBuilder().setMandatory(true).setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(PATH_KEY128_BYTES, 2)), true));
final ByteBuf buff = Unpooled.buffer();
XROPathKey128SubobjectParser.serializeSubobject(subs.build(), buff);
assertArrayEquals(PATH_KEY128_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.PathKeyBuilder in project bgpcep by opendaylight.
the class AbstractEROPathKeySubobjectParser method parseSubobject.
@Override
public final Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
checkContentLength(buffer.readableBytes());
return new SubobjectBuilder().setLoose(loose).setSubobjectType(new PathKeyCaseBuilder().setPathKey(new PathKeyBuilder().setPathKey(new PathKey(ByteBufUtils.readUint16(buffer))).setPceId(new PceId(readPceId(buffer))).build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.PathKeyBuilder in project bgpcep by opendaylight.
the class PCEPPathKeyObjectParser method parseObject.
@Override
public PathKey parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final List<PathKeys> pk = new ArrayList<>();
final List<Subobject> subs = parseSubobjects(bytes);
for (final Subobject sub : subs) {
final PathKeyCase pkc = (PathKeyCase) sub.getSubobjectType();
pk.add(new PathKeysBuilder().setLoose(sub.getLoose()).setPceId(pkc.getPathKey().getPceId()).setPathKey(pkc.getPathKey().getPathKey()).build());
}
return new PathKeyBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setPathKeys(pk).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.PathKeyBuilder in project bgpcep by opendaylight.
the class PathKeyUtilsTest method setUp.
@Before
public void setUp() {
this.key1 = new PathKeyBuilder().build();
this.key2 = new PathKeyBuilder().setPathKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey(Uint16.ONE)).build();
this.key3 = new PathKeyBuilder().setPathKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey(Uint16.ONE)).setPceId(new PceId(new byte[] { 2, 3, 4, 5 })).build();
}
Aggregations