use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.esi.AsGeneratedCase in project bgpcep by opendaylight.
the class ASGenParserTest method parserTest.
@Test
public void parserTest() {
final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
final AsGeneratedCase asGen = new AsGeneratedCaseBuilder().setAsGenerated(new AsGeneratedBuilder().setAs(AS_NUMBER).setLocalDiscriminator(LD).build()).build();
this.parser.serializeEsi(asGen, buff);
assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
assertEquals(asGen, acResult);
final ContainerNode cont = createContBuilder(new NodeIdentifier(AsGenerated.QNAME)).addChild(createValueBuilder(AS_MODEL, AS_NID).build()).addChild(createValueBuilder(LD, LD_NID).build()).build();
final Esi acmResult = this.parser.serializeEsi(cont);
assertEquals(asGen, acmResult);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.esi.esi.AsGeneratedCase in project bgpcep by opendaylight.
the class ASGenParser method serializeBody.
@Override
public ByteBuf serializeBody(final Esi esi, final ByteBuf body) {
checkArgument(esi instanceof AsGeneratedCase, "Unknown esi instance. Passed %s. Needed AsGeneratedCase.", esi);
final AsGenerated asGen = ((AsGeneratedCase) esi).getAsGenerated();
ByteBufUtils.write(body, asGen.getAs().getValue());
ByteBufUtils.writeOrZero(body, asGen.getLocalDiscriminator());
return body.writeByte(0);
}
Aggregations