use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrAlgorithmBuilder in project bgpcep by opendaylight.
the class SrNodeAttributesParser method parseSrAlgorithms.
public static SrAlgorithm parseSrAlgorithms(final ByteBuf buffer) {
final SrAlgorithmBuilder builder = new SrAlgorithmBuilder();
final List<Algorithm> algs = new ArrayList<>();
while (buffer.isReadable()) {
algs.add(Algorithm.forValue(buffer.readUnsignedByte()));
}
builder.setAlgorithms(algs);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrAlgorithmBuilder in project bgpcep by opendaylight.
the class SrAttributeParserTest method testSrAlgorithm.
@Test
public void testSrAlgorithm() {
final byte[] bytes = { 0 };
final SrAlgorithm alg = new SrAlgorithmBuilder().setAlgorithms(Lists.newArrayList(Algorithm.ShortestPathFirst)).build();
final SrAlgorithm empty = new SrAlgorithmBuilder().setAlgorithms(Collections.emptyList()).build();
assertEquals(alg, SrNodeAttributesParser.parseSrAlgorithms(Unpooled.wrappedBuffer(bytes)));
final ByteBuf b = Unpooled.buffer();
assertEquals(empty, SrNodeAttributesParser.parseSrAlgorithms(b));
SrNodeAttributesParser.serializeSrAlgorithms(alg, b);
assertArrayEquals(bytes, ByteArray.readAllBytes(b));
SrNodeAttributesParser.serializeSrAlgorithms(empty, b);
assertEquals(0, b.readableBytes());
}
Aggregations