use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPStatefulPeerProposalTest method setUp.
@SuppressWarnings("unchecked")
@Before
public void setUp() throws InterruptedException, ExecutionException {
MockitoAnnotations.initMocks(this);
this.tlvsBuilder = new TlvsBuilder().addAugmentation(Tlvs1.class, new Tlvs1Builder().setStateful(new StatefulBuilder().addAugmentation(Stateful1.class, new Stateful1Builder().build()).build()).build());
doReturn(this.rt).when(this.dataBroker).newReadOnlyTransaction();
doNothing().when(this.rt).close();
doReturn(this.listenableFutureMock).when(this.rt).read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
doReturn(true).when(this.listenableFutureMock).isDone();
doAnswer(invocation -> {
final Runnable runnable = (Runnable) invocation.getArguments()[0];
runnable.run();
return null;
}).when(this.listenableFutureMock).addListener(any(Runnable.class), any(Executor.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class NodeChangedListenerTest method createNode.
private void createNode(final NodeId nodeId, final String ipv4Address, final String lspName, final long lspId, final String dstIpv4Address) throws TransactionCommitFailedException {
final NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setKey(new NodeKey(nodeId));
nodeBuilder.setNodeId(nodeId);
final PathBuilder pathBuilder = new PathBuilder();
pathBuilder.setKey(new PathKey(new LspId(lspId)));
pathBuilder.setBandwidth(new BandwidthBuilder().setBandwidth(new Bandwidth(new byte[] { 0x00, 0x00, (byte) 0xff, (byte) 0xff })).build());
pathBuilder.addAugmentation(Path1.class, new Path1Builder().setLsp(new LspBuilder().setTlvs(new TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setAddressFamily(new Ipv4CaseBuilder().setIpv4(new Ipv4Builder().setIpv4TunnelSenderAddress(new Ipv4Address(ipv4Address)).setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(ipv4Address)).setIpv4TunnelEndpointAddress(new Ipv4Address(dstIpv4Address)).build()).build()).build()).build()).setAdministrative(true).setDelegate(true).build()).build());
final ReportedLsp reportedLps = new ReportedLspBuilder().setKey(new ReportedLspKey(lspName)).setPath(Collections.singletonList(pathBuilder.build())).build();
final Node1Builder node1Builder = new Node1Builder();
node1Builder.setPathComputationClient(new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).setReportedLsp(Lists.newArrayList(reportedLps)).setIpAddress(new IpAddress(new Ipv4Address(ipv4Address))).build());
nodeBuilder.addAugmentation(Node1.class, node1Builder.build());
final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID.builder().child(Node.class, new NodeKey(nodeId)).build(), nodeBuilder.build());
wTx.submit().checkedGet();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class AbstractObjectWithTlvsTest method testParseVendorInformationTlv.
@Test
public void testParseVendorInformationTlv() throws PCEPDeserializerException {
final Abs parser = new Abs(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf buffer = Unpooled.buffer();
parser.serializeVendorInformationTlvs(Lists.newArrayList(this.viTlv), buffer);
Mockito.verify(this.viTlvRegistry, Mockito.only()).serializeVendorInformationTlv(Mockito.any(VendorInformationTlv.class), Mockito.any(ByteBuf.class));
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
parser.parseTlvs(tlvsBuilder, Unpooled.wrappedBuffer(new byte[] { 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 }));
assertEquals(this.viTlv, tlvsBuilder.getVendorInformationTlv().get(0));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class AbstractObjectWithTlvsTest method testParseTlvs.
@Test
public void testParseTlvs() throws PCEPDeserializerException {
Abs a = new Abs(this.tlvRegistry, this.viTlvRegistry);
ByteBuf buffer = Unpooled.buffer();
a.serializeTlv(this.tlv, buffer);
Mockito.verify(this.tlvRegistry, Mockito.only()).serializeTlv(Mockito.any(Tlv.class), Mockito.any(ByteBuf.class));
TlvsBuilder b = new TlvsBuilder();
a.parseTlvs(b, Unpooled.wrappedBuffer(new byte[] { 0, 4, 0, 2, 5, 6, 0, 0 }));
assertEquals(this.tlv, b.getOfList());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder in project bgpcep by opendaylight.
the class SyncOptimizationsLspObjectParser method addTlv.
@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
super.addTlv(tbuilder, tlv);
final Tlvs1Builder syncOptTlvsBuilder = new Tlvs1Builder();
if (tbuilder.getAugmentation(Tlvs1.class) != null) {
final Tlvs1 t = tbuilder.getAugmentation(Tlvs1.class);
if (t.getLspDbVersion() != null) {
syncOptTlvsBuilder.setLspDbVersion(t.getLspDbVersion());
}
}
if (tlv instanceof LspDbVersion) {
syncOptTlvsBuilder.setLspDbVersion((LspDbVersion) tlv);
}
tbuilder.addAugmentation(Tlvs1.class, syncOptTlvsBuilder.build());
}
Aggregations