import org.eclipse.jdt.annotation.Nullable;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.transportpce.common.InstanceIdentifiers;
import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
import org.opendaylight.transportpce.tapi.TapiStringConstants;
import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetLinkDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeEdgePointDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointListImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyDetailsImpl;
import org.opendaylight.transportpce.tapi.utils.TapiContext;
import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
import org.opendaylight.transportpce.tapi.utils.TapiLink;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@ExtendWith(MockitoExtension.class)
public class TapiTopologyImplTest extends AbstractTest {
private static final Logger LOG = LoggerFactory.getLogger(TapiTopologyImplTest.class);
+ @Mock
+ private RpcService rpcService;
private static ListeningExecutorService executorService;
private static CountDownLatch endSignal;
private static final int NUM_THREADS = 3;
}
@Test
- void getTopologyDetailsForTransponder100GTopologyWhenSuccessful()
- throws ExecutionException, InterruptedException {
+ void getTopologyDetailsForTransponder100GTopologyWhenSuccessful() throws ExecutionException, InterruptedException {
Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.TPDR_100G.getBytes(
Charset.forName("UTF-8"))).toString());
LOG.info("TPDR100GUuid = {}", topologyUuid);
GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
- TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
- ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
+// TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(networkTransactionService, tapiContext, topologyUtils,
+// tapiLink);
+ ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = new GetTopologyDetailsImpl(tapiContext,
+ topologyUtils, tapiLink, networkTransactionService)
+ .invoke(input);
LOG.info("RESULT of getTopoDetailsTopo/name = {}", result.get().getResult().getTopology().getName().toString());
- result.addListener(new Runnable() {
- @Override
- public void run() {
- endSignal.countDown();
- }
- }, executorService);
- endSignal.await();
RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
@Nullable
Topology topology = rpcResult.getResult().getTopology();
}
@Test
- void getTopologyDetailsForOtnTopologyWithOtnLinksWhenSuccessful()
- throws ExecutionException, InterruptedException {
+ void getTopologyDetailsForOtnTopologyWithOtnLinksWhenSuccessful() throws ExecutionException, InterruptedException {
Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_MULTILAYER.getBytes(
Charset.forName("UTF-8"))).toString());
LOG.info("T0MultilayerUuid = {}", topologyUuid);
GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
- TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
- ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
- result.addListener(new Runnable() {
- @Override
- public void run() {
- endSignal.countDown();
- }
- }, executorService);
- endSignal.await();
+ ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = new GetTopologyDetailsImpl(tapiContext,
+ topologyUtils, tapiLink, networkTransactionService)
+ .invoke(input);
RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
@Nullable
Topology topology = rpcResult.getResult().getTopology();
Charset.forName("UTF-8"))).toString());
LOG.info("T0FullMultilayerUuid = {}", topologyUuid);
GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
- TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
- ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
- result.addListener(new Runnable() {
- @Override
- public void run() {
- endSignal.countDown();
- }
- }, executorService);
- endSignal.await();
+ ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = new GetTopologyDetailsImpl(tapiContext,
+ topologyUtils, tapiLink, networkTransactionService)
+ .invoke(input);
RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
@Nullable
Topology topology = rpcResult.getResult().getTopology();
.filter(nep -> nep.getName().containsKey(new NameKey("eNodeEdgePoint"))))
.count();
assertEquals(4, inb5, "SPDR-SA1-XPDR2+XPONDER (switch) should have 4 external network neps");
- Node nodeRoadm = topology.getNode().values().stream()
- .filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
- && !node.getLayerProtocolName().contains(LayerProtocolName.DSR))
- .filter(node -> node.getName().get(new NameKey("roadm node name")).getValue()
- .equals("ROADM-A1+PHOTONIC_MEDIA"))
- .findAny().orElseThrow();
long inb6 = topology.getNode().values().stream()
.filter(node -> node.getLayerProtocolName().contains(LayerProtocolName.PHOTONICMEDIA)
&& !node.getLayerProtocolName().contains(LayerProtocolName.DSR))
}
@Test
- void getNodeAndNepsDetailsWhenSuccessful()
- throws ExecutionException, InterruptedException {
+ void getNodeAndNepsDetailsWhenSuccessful() throws ExecutionException, InterruptedException {
Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
Charset.forName("UTF-8"))).toString());
GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
- TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
- ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
- result.addListener(new Runnable() {
- @Override
- public void run() {
- endSignal.countDown();
- }
- }, executorService);
- endSignal.await();
+ ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = new GetTopologyDetailsImpl(tapiContext,
+ topologyUtils, tapiLink, networkTransactionService)
+ .invoke(input);
RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
@Nullable
Topology topology = rpcResult.getResult().getTopology();
for (Node node:topology.getNode().values()) {
- //String nodeName = node.getName().values().stream().findFirst().orElseThrow().getValue();
Uuid nodeUuid = node.getUuid();
GetNodeDetailsInput input1 = TapiTopologyDataUtils.buildGetNodeDetailsInput(topologyUuid, nodeUuid);
- ListenableFuture<RpcResult<GetNodeDetailsOutput>> result1 = tapiTopoImpl.getNodeDetails(input1);
- result.addListener(new Runnable() {
- @Override
- public void run() {
- endSignal.countDown();
- }
- }, executorService);
- endSignal.await();
+ ListenableFuture<RpcResult<GetNodeDetailsOutput>> result1 = new GetNodeDetailsImpl(tapiContext)
+ .invoke(input1);
RpcResult<GetNodeDetailsOutput> rpcResult1 = result1.get();
@Nullable
Node node1 = rpcResult1.getResult().getNode();
assertNotNull(node1, "Node should not be null");
for (OwnedNodeEdgePoint onep:node1.getOwnedNodeEdgePoint().values()) {
- //String onepName = onep.getName().values().stream().findFirst().orElseThrow().getValue();
Uuid onepUuid = onep.getUuid();
GetNodeEdgePointDetailsInput input2 = TapiTopologyDataUtils.buildGetNodeEdgePointDetailsInput(
topologyUuid, nodeUuid, onepUuid);
- ListenableFuture<RpcResult<GetNodeEdgePointDetailsOutput>> result2
- = tapiTopoImpl.getNodeEdgePointDetails(input2);
- result.addListener(new Runnable() {
- @Override
- public void run() {
- endSignal.countDown();
- }
- }, executorService);
- endSignal.await();
+ ListenableFuture<RpcResult<GetNodeEdgePointDetailsOutput>> result2 =
+ new GetNodeEdgePointDetailsImpl(tapiContext).invoke(input2);
RpcResult<GetNodeEdgePointDetailsOutput> rpcResult2 = result2.get();
org.opendaylight.yang.gen.v1
.urn.onf.otcc.yang.tapi.topology.rev221121.get.node.edge.point.details.output.NodeEdgePoint
}
@Test
- void getLinkDetailsWhenSuccessful()
- throws ExecutionException, InterruptedException {
+ void getLinkDetailsWhenSuccessful() throws ExecutionException, InterruptedException {
Uuid topologyUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER.getBytes(
Charset.forName("UTF-8"))).toString());
GetTopologyDetailsInput input = TapiTopologyDataUtils.buildGetTopologyDetailsInput(topologyUuid);
- TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
- ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = tapiTopoImpl.getTopologyDetails(input);
- result.addListener(new Runnable() {
- @Override
- public void run() {
- endSignal.countDown();
- }
- }, executorService);
- endSignal.await();
+ ListenableFuture<RpcResult<GetTopologyDetailsOutput>> result = new GetTopologyDetailsImpl(tapiContext,
+ topologyUtils, tapiLink, networkTransactionService)
+ .invoke(input);
RpcResult<GetTopologyDetailsOutput> rpcResult = result.get();
@Nullable
Topology topology = rpcResult.getResult().getTopology();
for (Link link:topology.getLink().values()) {
- //String linkName = link.getName().values().stream().findFirst().orElseThrow().getValue();
Uuid linkUuid = link.getUuid();
GetLinkDetailsInput input1 = TapiTopologyDataUtils.buildGetLinkDetailsInput(
topologyUuid, linkUuid);
- ListenableFuture<RpcResult<GetLinkDetailsOutput>> result1 = tapiTopoImpl.getLinkDetails(input1);
- result.addListener(new Runnable() {
- @Override
- public void run() {
- endSignal.countDown();
- }
- }, executorService);
- endSignal.await();
+ ListenableFuture<RpcResult<GetLinkDetailsOutput>> result1 = new GetLinkDetailsImpl(tapiContext)
+ .invoke(input1);
RpcResult<GetLinkDetailsOutput> rpcResult1 = result1.get();
org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.get.link.details.output.Link link1
= rpcResult1.getResult().getLink();
}
@Test
- void getSipDetailsWhenSuccessful()
- throws ExecutionException, InterruptedException {
+ void getSipDetailsWhenSuccessful() throws ExecutionException, InterruptedException {
GetServiceInterfacePointListInput input = TapiTopologyDataUtils.buildServiceInterfacePointListInput();
- TapiTopologyImpl tapiTopoImpl = new TapiTopologyImpl(getDataBroker(), tapiContext, topologyUtils, tapiLink);
- ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>> result = tapiTopoImpl
- .getServiceInterfacePointList(input);
- result.addListener(new Runnable() {
- @Override
- public void run() {
- endSignal.countDown();
- }
- }, executorService);
- endSignal.await();
+ ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>> result =
+ new GetServiceInterfacePointListImpl(tapiContext).invoke(input);
RpcResult<GetServiceInterfacePointListOutput> rpcResult = result.get();
Map<SipKey, Sip> sipMap = rpcResult.getResult().getSip();
for (Sip sip:sipMap.values()) {
Uuid sipUuid = sip.getUuid();
GetServiceInterfacePointDetailsInput input1 = TapiTopologyDataUtils
.buildGetServiceInterfacePointDetailsInput(sipUuid);
- ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>> result1
- = tapiTopoImpl.getServiceInterfacePointDetails(input1);
- result.addListener(new Runnable() {
- @Override
- public void run() {
- endSignal.countDown();
- }
- }, executorService);
- endSignal.await();
+ ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>> result1 =
+ new GetServiceInterfacePointDetailsImpl(tapiContext).invoke(input1);
RpcResult<GetServiceInterfacePointDetailsOutput> rpcResult1 = result1.get();
org.opendaylight.yang.gen.v1
.urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.details.output.Sip sip1