use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder in project bgpcep by opendaylight.
the class PCCSessionListenerTest method createInitMsg.
private static PcinitiateMessage createInitMsg(final boolean remove, final boolean endpoint) {
// lsp with "unknown" plsp-id
final LspBuilder lspBuilder = new LspBuilder().setAdministrative(true).setDelegate(true).setIgnore(false).setOperational(OperationalStatus.Up).setPlspId(new PlspId(999L)).setProcessingRule(false).setRemove(remove).setSync(true);
final List<Requests> requests = Lists.newArrayList();
final RequestsBuilder reqBuilder = new RequestsBuilder().setLsp(lspBuilder.build()).setSrp(new SrpBuilder(MsgBuilderUtil.createSrp(123)).addAugmentation(Srp1.class, new Srp1Builder().setRemove(remove).build()).build());
if (endpoint) {
reqBuilder.setEndpointsObj(new EndpointsObjBuilder().build());
}
requests.add(reqBuilder.build());
final PcinitiateMessageBuilder initBuilder = new PcinitiateMessageBuilder().setRequests(requests);
return new PcinitiateBuilder().setPcinitiateMessage(initBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method testPcinitMsg.
@Test
public void testPcinitMsg() throws IOException, PCEPDeserializerException {
new InitiatedActivator().start(ctx);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/Pcinit.bin"));
final InitiatedPCInitiateMessageParser parser = new InitiatedPCInitiateMessageParser(this.ctx.getObjectHandlerRegistry());
final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder().setRequests(List.of(new RequestsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setEro(this.ero).setLspa(this.lspa).setMetrics(List.of(this.metrics)).setIro(this.iro).build()));
assertEquals(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.PcinitiateBuilder in project bgpcep by opendaylight.
the class InitiatedPCInitiateMessageParser method validate.
@Override
protected Message validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
checkArgument(objects != null, "Passed list can't be null.");
final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder();
final List<Requests> reqs = new ArrayList<>();
while (!objects.isEmpty()) {
reqs.add(this.getValidRequest(objects));
}
builder.setRequests(reqs);
return new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build();
}
Aggregations