use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.TerminationMessage in project bgpcep by opendaylight.
the class TerminationHandler method serializeMessageBody.
@Override
public void serializeMessageBody(final Notification message, final ByteBuf buffer) {
Preconditions.checkArgument(message instanceof TerminationMessage, "An instance of Termination message is required");
final TerminationMessage terminationMsg = (TerminationMessage) message;
serializeTlvs(terminationMsg.getTlvs(), buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.TerminationMessage in project bgpcep by opendaylight.
the class TerminationHandlerTest method testParseTerminationMessage.
@Test
public void testParseTerminationMessage() throws BmpDeserializationException {
final TerminationMessage parsedInitMsg = (TerminationMessage) getBmpMessageRegistry().parseMessage(Unpooled.copiedBuffer(TERMINATION_MESSAGE));
assertEquals(createTerminationMsg(), parsedInitMsg);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.TerminationMessage in project bgpcep by opendaylight.
the class TestUtil method createTerminationMsg.
public static TerminationMessage createTerminationMsg() {
final TerminationMessageBuilder terminatMsgBuilder = new TerminationMessageBuilder();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.termination.TlvsBuilder tlvsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.termination.TlvsBuilder();
tlvsBuilder.setReasonTlv(new ReasonTlvBuilder().setReason(Reason.AdministrativelyClosed).build());
tlvsBuilder.setStringInformation(Lists.newArrayList(createStringInfo("error1"), createStringInfo("error1")));
return terminatMsgBuilder.setTlvs(tlvsBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.TerminationMessage in project bgpcep by opendaylight.
the class TerminationHandler method parseMessageBody.
@Override
public Notification parseMessageBody(final ByteBuf bytes) throws BmpDeserializationException {
final TerminationMessageBuilder terminationMessage = new TerminationMessageBuilder();
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
tlvsBuilder.setStringInformation(ImmutableList.of());
parseTlvs(tlvsBuilder, bytes);
if (tlvsBuilder.getReasonTlv() == null || tlvsBuilder.getReasonTlv().getReason() == null) {
throw new BmpDeserializationException("Inclusion of Reason TLV is mandatory.");
}
return terminationMessage.setTlvs(tlvsBuilder.build()).build();
}
Aggregations