use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCaseBuilder in project bgpcep by opendaylight.
the class WavebandSwitchingLabelParser method parseLabel.
@Override
public final LabelType parseLabel(final ByteBuf buffer) throws RSVPParsingException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + CONTENT_LENGTH + ".");
}
final WavebandSwitchingLabelBuilder builder = new WavebandSwitchingLabelBuilder();
builder.setWavebandId(buffer.readUnsignedInt());
builder.setStartLabel(buffer.readUnsignedInt());
builder.setEndLabel(buffer.readUnsignedInt());
return new WavebandSwitchingLabelCaseBuilder().setWavebandSwitchingLabel(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCaseBuilder in project bgpcep by opendaylight.
the class LabelSubobjectParserTest method testWavebandLabel.
@Test
public void testWavebandLabel() throws RSVPParsingException {
final WavebandSwitchingLabelParser parser = new WavebandSwitchingLabelParser();
final WavebandSwitchingLabelBuilder iBuilder = new WavebandSwitchingLabelBuilder();
iBuilder.setWavebandId(0x1234L);
iBuilder.setStartLabel(0x9999L);
iBuilder.setEndLabel(0x1111L);
final WavebandSwitchingLabelCaseBuilder builder = new WavebandSwitchingLabelCaseBuilder().setWavebandSwitchingLabel(iBuilder.build());
assertEquals(builder.build(), parser.parseLabel(Unpooled.wrappedBuffer(ByteArray.cutBytes(WAVEBAND_LABEL_BYTES, 2))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeLabel(false, true, builder.build(), buff);
assertArrayEquals(WAVEBAND_LABEL_BYTES, ByteArray.getAllBytes(buff));
try {
parser.parseLabel(null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseLabel(Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCaseBuilder in project bgpcep by opendaylight.
the class LabelSubobjectParserTest method testWavebandLabel.
@Test
public void testWavebandLabel() throws PCEPDeserializerException {
final WavebandSwitchingLabelParser parser = new WavebandSwitchingLabelParser();
final WavebandSwitchingLabelBuilder iBuilder = new WavebandSwitchingLabelBuilder();
iBuilder.setWavebandId(0x1234L);
iBuilder.setStartLabel(0x9999L);
iBuilder.setEndLabel(0x1111L);
final WavebandSwitchingLabelCaseBuilder builder = new WavebandSwitchingLabelCaseBuilder().setWavebandSwitchingLabel(iBuilder.build());
assertEquals(builder.build(), parser.parseLabel(Unpooled.wrappedBuffer(ByteArray.cutBytes(wavebandLabelBytes, 2))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeLabel(false, true, builder.build(), buff);
assertArrayEquals(wavebandLabelBytes, ByteArray.getAllBytes(buff));
try {
parser.parseLabel(null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseLabel(Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCaseBuilder in project bgpcep by opendaylight.
the class WavebandSwitchingLabelParser method parseLabel.
@Override
public LabelType parseLabel(final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + CONTENT_LENGTH + ".");
}
final WavebandSwitchingLabelBuilder builder = new WavebandSwitchingLabelBuilder();
builder.setWavebandId(buffer.readUnsignedInt());
builder.setStartLabel(buffer.readUnsignedInt());
builder.setEndLabel(buffer.readUnsignedInt());
return new WavebandSwitchingLabelCaseBuilder().setWavebandSwitchingLabel(builder.build()).build();
}
Aggregations