Merge dev/fluorine work across to master
[unimgr.git] / impl / src / test / java / org / opendaylight / unimgr / mef / nrp / impl / connectivityservice / TapiConnectivityServiceInplIntTest.java
index 09b753cfe3c242f3c11720c6c1d5a457fe546b0d..a9dc5b7c3dc03c06d4963365db13420efd94de02 100644 (file)
@@ -8,6 +8,31 @@
 
 package org.opendaylight.unimgr.mef.nrp.impl.connectivityservice;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+import static org.opendaylight.unimgr.utils.PredicateMatcher.fromPredicate;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+import org.hamcrest.CoreMatchers;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
@@ -21,79 +46,91 @@ import org.opendaylight.unimgr.mef.nrp.api.RequestValidator;
 import org.opendaylight.unimgr.mef.nrp.api.TapiConstants;
 import org.opendaylight.unimgr.mef.nrp.common.NrpDao;
 import org.opendaylight.unimgr.mef.nrp.common.ResourceActivatorException;
+import org.opendaylight.unimgr.mef.nrp.common.TapiUtils;
 import org.opendaylight.unimgr.mef.nrp.impl.AbstractTestWithTopo;
 import org.opendaylight.unimgr.mef.nrp.impl.ConnectivityServiceIdResourcePool;
 import org.opendaylight.unimgr.mef.nrp.impl.decomposer.BasicDecomposer;
 import org.opendaylight.unimgr.utils.ActivationDriverMocks;
-import org.opendaylight.yang.gen.v1.urn.mef.yang.mef.common.types.rev171221.PositiveInteger;
-import org.opendaylight.yang.gen.v1.urn.mef.yang.nrm.connectivity.rev171221.carrier.eth.connectivity.end.point.resource.CeVlanIdListAndUntag;
-import org.opendaylight.yang.gen.v1.urn.mef.yang.nrm.connectivity.rev171221.carrier.eth.connectivity.end.point.resource.CeVlanIdListAndUntagBuilder;
-import org.opendaylight.yang.gen.v1.urn.mef.yang.nrm.connectivity.rev171221.vlan.id.list.and.untag.VlanIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev171221.EndPoint2;
-import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev171221.EndPoint2Builder;
-import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev171221.NrpConnectivityServiceEndPointAttrs;
-import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev171221.nrp.connectivity.service.end.point.attrs.NrpCarrierEthConnectivityEndPointResource;
-import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev171221.nrp.connectivity.service.end.point.attrs.NrpCarrierEthConnectivityEndPointResourceBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.common.rev171113.PortDirection;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.common.rev171113.PortRole;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.common.rev171113.Uuid;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.*;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connection.ConnectionEndPoint;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connection.ConnectionEndPointBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connection.RouteBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.context.Connection;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.context.ConnectionBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.context.ConnectionKey;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.context.ConnectivityService;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.context.ConnectivityServiceBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.context.ConnectivityServiceKey;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.create.connectivity.service.input.EndPoint;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.create.connectivity.service.input.EndPointBuilder;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.mef.common.types.rev180321.PositiveInteger;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrm.connectivity.rev180321.carrier.eth.connectivity.end.point.resource.CeVlanIdListAndUntagBuilder;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrm.connectivity.rev180321.vlan.id.list.and.untag.VlanIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.EndPoint1;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.EndPoint2;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.EndPoint2Builder;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.EndPoint3;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.EndPoint4;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.EndPoint5;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.EndPoint6;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.EndPoint8;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.NrpConnectivityServiceEndPointAttrs;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.nrp.connectivity.service.end.point.attrs.NrpCarrierEthConnectivityEndPointResource;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.nrp.connectivity.service.end.point.attrs.NrpCarrierEthConnectivityEndPointResourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.LocalClass;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.OperationalState;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.PortDirection;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.PortRole;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev180307.Uuid;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.Context1;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.CreateConnectivityServiceInput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.CreateConnectivityServiceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.CreateConnectivityServiceOutput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.DeleteConnectivityServiceInput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.DeleteConnectivityServiceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.DeleteConnectivityServiceOutput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.GetConnectionDetailsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.GetConnectionDetailsOutput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.GetConnectivityServiceDetailsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.GetConnectivityServiceDetailsOutput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.GetConnectivityServiceListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.GetConnectivityServiceListOutput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.OwnedNodeEdgePoint1;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.UpdateConnectivityServiceInput;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connection.ConnectionEndPoint;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.context.Connection;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.context.ConnectivityService;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.context.ConnectivityServiceBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.context.ConnectivityServiceKey;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.connectivity.service.end.point.ServiceInterfacePoint;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.create.connectivity.service.input.EndPoint;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307.create.connectivity.service.input.EndPointBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev180307.topology.Node;
+import org.opendaylight.yangtools.yang.binding.AugmentationHolder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.stream.Collectors;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
 
-/**
- * @author bartosz.michalik@amartus.com
- */
 public class TapiConnectivityServiceInplIntTest extends AbstractTestWithTopo {
 
     private ActivationDriver ad1;
     private ActivationDriver ad2;
 
     private String uuid1 = "uuid1";
-    private String uuid2 = "uuid2";
+    private String activationDriverId1 = "d1";
+    private String activationDriverId2 = "d2";
     private TapiConnectivityServiceImpl connectivityService;
     private ConnectivityServiceIdResourcePool mockPool;
 
     @Before
     public void setUp() throws Exception {
-        BasicDecomposer decomposer = new BasicDecomposer(dataBroker);
 
         ad1 = mock(ActivationDriver.class);
         ad2 = mock(ActivationDriver.class);
-        ActivationDriverRepoService repo = ActivationDriverMocks.builder()
-                .add(new Uuid(uuid1), ad1)
-                .add(new Uuid(uuid2), ad2)
-                .build();
 
         RequestValidator validator = mock(RequestValidator.class);
-        when(validator.checkValid(any())).thenReturn(new RequestValidator.ValidationResult());
+        when(validator.checkValid(any(CreateConnectivityServiceInput.class)))
+                .thenReturn(new RequestValidator.ValidationResult());
+        when(validator.checkValid(any(UpdateConnectivityServiceInput.class)))
+                .thenReturn(new RequestValidator.ValidationResult());
 
         mockPool = mock(ConnectivityServiceIdResourcePool.class);
 
         connectivityService = new TapiConnectivityServiceImpl();
+        ActivationDriverRepoService repo = ActivationDriverMocks.builder()
+                .add(activationDriverId1 , ad1)
+                .add(activationDriverId2 , ad2)
+                .build();
         connectivityService.setDriverRepo(repo);
-        connectivityService.setDecomposer(decomposer);
+        connectivityService.setDecomposer(new BasicDecomposer(dataBroker));
         connectivityService.setValidator(validator);
         connectivityService.setBroker(getDataBroker());
         connectivityService.setServiceIdPool(mockPool);
@@ -104,29 +141,133 @@ public class TapiConnectivityServiceInplIntTest extends AbstractTestWithTopo {
     public void testSingleDriverActivation() throws Exception {
         //having
         final String servId = "service-id";
+
+        ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
+        n(tx, new Uuid(uuid1), activationDriverId1, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+
+        tx.commit().get();
+        waitForAbstractNeps(5, TimeUnit.SECONDS, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+
+        when(mockPool.getServiceId()).thenReturn(servId);
+
+        //when
         CreateConnectivityServiceInput input = new CreateConnectivityServiceInputBuilder()
                 .setEndPoint(eps(uuid1 + ":1", uuid1 + ":2"))
                 .build();
 
+        RpcResult<CreateConnectivityServiceOutput> result = this.connectivityService
+                .createConnectivityService(input).get();
+
+        //then
+        assertTrue(result.isSuccessful());
+        verify(ad1, times(1)).activate();
+        verify(ad1, times(1)).commit();
+        verifyZeroInteractions(ad2);
+
+        ReadOnlyTransaction tx2 = dataBroker.newReadOnlyTransaction();
+
+        Context1 connCtx = tx2
+                .read(LogicalDatastoreType.OPERATIONAL, TapiConnectivityServiceImpl.CONNECTIVITY_CTX).get().get();
+        assertEquals(2, connCtx.getConnection().size());
+        connCtx.getConnection().forEach(this::verifyConnection);
+
+        assertEquals(1, connCtx.getConnectivityService().size());
+        assertFalse(connCtx.getConnectivityService().get(0).getEndPoint().isEmpty());
+        assertEquals("cs:" + servId, connCtx.getConnectivityService().get(0).getUuid().getValue());
+
+        verifyMefAttributes(connCtx.getConnectivityService().get(0));
+        verifyMefAttributes(result.getResult().getService());
+
+        final Set<String> expected = input.getEndPoint().stream().map(LocalClass::getLocalId)
+                .collect(Collectors.toSet());
+
+        assertThat(result.getResult().getService().getEndPoint(),
+                CoreMatchers.everyItem(fromPredicate(id -> expected.contains(id.getLocalId())))
+
+        );
+
+    }
+
+    private void verifyMefAttributes(
+            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307
+                .ConnectivityService serviceToVerify) {
+        assertTrue(serviceToVerify.getEndPoint().stream().allMatch(ep -> toAugmentation(ep) != null));
+    }
+
+    @SuppressWarnings("unchecked")
+    private NrpCarrierEthConnectivityEndPointResource toAugmentation(
+            org.opendaylight.yang.gen.v1.urn.onf.otcc.yang
+                    .tapi.connectivity.rev180307.connectivity.service.EndPoint ep) {
+        if (ep instanceof AugmentationHolder) {
+            Optional<NrpConnectivityServiceEndPointAttrs> optional =
+                    ((AugmentationHolder) ep).augmentations().values()
+                    .stream()
+                    .filter(a -> a instanceof NrpConnectivityServiceEndPointAttrs).findFirst();
+            if (optional.isPresent()) {
+                return optional.get().getNrpCarrierEthConnectivityEndPointResource();
+            }
+            return null;
+        }
+
+        if (ep.augmentation(EndPoint1.class) != null) {
+            return ep.augmentation(EndPoint1.class).getNrpCarrierEthConnectivityEndPointResource();
+        }
+        if (ep.augmentation(EndPoint3.class) != null) {
+            return ep.augmentation(EndPoint3.class).getNrpCarrierEthConnectivityEndPointResource();
+        }
+        if (ep.augmentation(EndPoint4.class) != null) {
+            return ep.augmentation(EndPoint4.class).getNrpCarrierEthConnectivityEndPointResource();
+        }
+        if (ep.augmentation(EndPoint5.class) != null) {
+            return ep.augmentation(EndPoint5.class).getNrpCarrierEthConnectivityEndPointResource();
+        }
+        if (ep.augmentation(EndPoint6.class) != null) {
+            return ep.augmentation(EndPoint5.class).getNrpCarrierEthConnectivityEndPointResource();
+        }
+        if (ep.augmentation(EndPoint8.class) != null) {
+            return ep.augmentation(EndPoint8.class).getNrpCarrierEthConnectivityEndPointResource();
+        }
+
+        return null;
+    }
+
+    @Test
+    public void testMultiDriverActivation() throws Exception {
+        //having
+        final String servId = "service-id";
+        final String uuid2 = "uuid2";
+        final String uuid3 = "uuid3";
+
         ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
-        n(tx, uuid1, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+        n(tx, new Uuid(uuid1), activationDriverId1, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+        n(tx, new Uuid(uuid2), activationDriverId2, uuid2 + ":1", uuid2 + ":2", uuid2 + ":3");
+        n(tx, new Uuid(uuid3), activationDriverId2, uuid3 + ":1", uuid3 + ":2", uuid3 + ":3");
+        l(tx, uuid1, uuid1 + ":2", uuid2, uuid2 + ":1", OperationalState.ENABLED);
+        l(tx, uuid2, uuid2 + ":3", uuid3, uuid3 + ":2", OperationalState.ENABLED);
 
         when(mockPool.getServiceId()).thenReturn(servId);
 
-        tx.submit().checkedGet();
+        tx.commit().get();
 
         //when
-        RpcResult<CreateConnectivityServiceOutput> result = this.connectivityService.createConnectivityService(input).get();
+        CreateConnectivityServiceInput input = new CreateConnectivityServiceInputBuilder()
+                .setEndPoint(eps(uuid1 + ":1", uuid3 + ":3"))
+                .build();
+
+        RpcResult<CreateConnectivityServiceOutput> result = this.connectivityService
+                .createConnectivityService(input).get();
         //then
         assertTrue(result.isSuccessful());
-        verify(ad1).activate();
-        verify(ad1).commit();
-        verifyZeroInteractions(ad2);
+        verify(ad1, times(1)).activate();
+        verify(ad1, times(1)).commit();
+        verify(ad2, times(2)).activate();
+        verify(ad2, times(2)).commit();
 
         ReadOnlyTransaction tx2 = dataBroker.newReadOnlyTransaction();
 
-        Context1 connCtx = tx2.read(LogicalDatastoreType.OPERATIONAL, TapiConnectivityServiceImpl.connectivityCtx).checkedGet().get();
-        assertEquals(2, connCtx.getConnection().size());
+        Context1 connCtx = tx2
+                .read(LogicalDatastoreType.OPERATIONAL, TapiConnectivityServiceImpl.CONNECTIVITY_CTX).get().get();
+        assertEquals(4, connCtx.getConnection().size());
         connCtx.getConnection().forEach(this::verifyConnection);
 
         assertEquals(1, connCtx.getConnectivityService().size());
@@ -137,29 +278,50 @@ public class TapiConnectivityServiceInplIntTest extends AbstractTestWithTopo {
 
     @Test
     public void testNoServiceDeactivation() throws ExecutionException, InterruptedException {
-        DeleteConnectivityServiceInput input = new DeleteConnectivityServiceInputBuilder().setServiceIdOrName("some-service").build();
+        DeleteConnectivityServiceInput input = new DeleteConnectivityServiceInputBuilder()
+                .setServiceIdOrName("some-service").build();
         RpcResult<DeleteConnectivityServiceOutput> result = connectivityService.deleteConnectivityService(input).get();
         assertFalse(result.isSuccessful());
     }
 
 
     @Test
-    public void testServiceDeactivationWithSingleDriver() throws ExecutionException, InterruptedException, TransactionCommitFailedException, ReadFailedException, ResourceActivatorException {
+    public void testServiceDeactivationWithSingleDriver() throws ExecutionException, InterruptedException,
+            TransactionCommitFailedException, ReadFailedException, ResourceActivatorException {
         //having
+
+        ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
+        n(tx, uuid1, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+        tx.commit().get();
+
+        waitForAbstractNeps(5, TimeUnit.SECONDS, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+
         createConnectivityService();
 
         //when
-        DeleteConnectivityServiceInput input = new DeleteConnectivityServiceInputBuilder().setServiceIdOrName("some-service").build();
+        DeleteConnectivityServiceInput input = new DeleteConnectivityServiceInputBuilder()
+                .setServiceIdOrName("some-service").build();
         RpcResult<DeleteConnectivityServiceOutput> result = connectivityService.deleteConnectivityService(input).get();
 
         //then
         assertTrue(result.isSuccessful());
         ReadOnlyTransaction tx2 = dataBroker.newReadOnlyTransaction();
-        Context1 connCtx = tx2.read(LogicalDatastoreType.OPERATIONAL, TapiConnectivityServiceImpl.connectivityCtx).checkedGet().get();
+        Context1 connCtx = tx2
+                .read(LogicalDatastoreType.OPERATIONAL, TapiConnectivityServiceImpl.CONNECTIVITY_CTX).get().get();
         verify(ad1).deactivate();
         verify(ad1).commit();
         assertEquals(0, connCtx.getConnection().size());
         assertEquals(0, connCtx.getConnectivityService().size());
+        Node node1 = new NrpDao(tx2).getNode(TapiConstants.PRESTO_EXT_TOPO, TapiConstants.PRESTO_ABSTRACT_NODE);
+        Node node2 = new NrpDao(tx2).getNode(TapiConstants.PRESTO_SYSTEM_TOPO, uuid1);
+        long countEndPoints1 = node1.getOwnedNodeEdgePoint().stream()
+                .map(nep -> nep.augmentation(OwnedNodeEdgePoint1.class)).filter(Objects::nonNull)
+                .mapToLong(aug -> aug.getConnectionEndPoint().size()).sum();
+        long countEndPoints2 = node2.getOwnedNodeEdgePoint().stream()
+                .map(nep -> nep.augmentation(OwnedNodeEdgePoint1.class)).filter(Objects::nonNull)
+                .mapToLong(aug -> aug.getConnectionEndPoint().size()).sum();
+        assertEquals(0, countEndPoints1);
+        assertEquals(0, countEndPoints2);
     }
 
     @Test
@@ -167,21 +329,61 @@ public class TapiConnectivityServiceInplIntTest extends AbstractTestWithTopo {
         //having
         //when
         RpcResult<GetConnectivityServiceListOutput> result =
-                connectivityService.getConnectivityServiceList().get();
+                connectivityService.getConnectivityServiceList(
+                        new GetConnectivityServiceListInputBuilder().build()).get();
         //then
         assertTrue(result.isSuccessful());
         assertEquals(0, result.getResult().getService().size());
     }
 
+    private void waitForAbstractNeps(long time, TimeUnit units,String... uuid) {
+        long timeMs = units.toMillis(time);
+
+        final List<String> required = Arrays.asList(uuid);
+
+        for (int i = 0; i < 5; ++i) {
+            NrpDao nrpDao = new NrpDao(dataBroker.newReadOnlyTransaction());
+            try {
+                Node node = nrpDao.getNode(TapiConstants.PRESTO_EXT_TOPO, TapiConstants.PRESTO_ABSTRACT_NODE);
+                if (node != null && node.getOwnedNodeEdgePoint() != null) {
+                    long neps = node.getOwnedNodeEdgePoint().stream()
+                            .map(nep -> nep.getUuid().getValue()).filter(required::contains).count();
+                    if (neps == required.size()) {
+                        return;
+                    }
+                }
+
+                try {
+                    Thread.sleep(timeMs / 5);
+                } catch (InterruptedException e) {
+                    //
+                }
+
+            } catch (ReadFailedException _e) {
+                //
+            }
+        }
+
+        Assert.fail("NEPs are not added to abstract node " + Arrays.stream(uuid)
+                .collect(Collectors.joining(",", "[", "]")));
+    }
 
     @Test
     public void testGetServiceList() throws TransactionCommitFailedException, InterruptedException, ExecutionException {
         //having
+
+        ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
+        n(tx, uuid1, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+        tx.commit().get();
+
+        waitForAbstractNeps(5, TimeUnit.SECONDS, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+
         createConnectivityService();
 
         //when
         RpcResult<GetConnectivityServiceListOutput> result =
-                connectivityService.getConnectivityServiceList().get();
+                connectivityService.getConnectivityServiceList(
+                        new GetConnectivityServiceListInputBuilder().build()).get();
 
         //then
         assertTrue(result.isSuccessful());
@@ -221,8 +423,15 @@ public class TapiConnectivityServiceInplIntTest extends AbstractTestWithTopo {
     }
 
     @Test
-    public void testGetServiceDetails() throws InterruptedException, ExecutionException, TransactionCommitFailedException {
+    public void testGetServiceDetails()
+            throws InterruptedException, ExecutionException, TransactionCommitFailedException {
         //having
+        ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
+        n(tx, uuid1, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+        tx.commit().get();
+
+        waitForAbstractNeps(5, TimeUnit.SECONDS, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+
         createConnectivityService();
 
         //when
@@ -285,8 +494,15 @@ public class TapiConnectivityServiceInplIntTest extends AbstractTestWithTopo {
     }
 
     @Test
-    public void getGetConnectionDetailsByServiceName() throws InterruptedException, ExecutionException, TransactionCommitFailedException {
+    public void getGetConnectionDetailsByServiceName()
+            throws InterruptedException, ExecutionException, TransactionCommitFailedException {
         //having
+        ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
+        n(tx, uuid1, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+        tx.commit().get();
+
+        waitForAbstractNeps(5, TimeUnit.SECONDS, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+
         createConnectivityService();
 
         //when
@@ -302,30 +518,31 @@ public class TapiConnectivityServiceInplIntTest extends AbstractTestWithTopo {
     }
 
 
-    private void createConnectivityService() throws TransactionCommitFailedException {
+    private void createConnectivityService()
+            throws TransactionCommitFailedException, InterruptedException, ExecutionException {
         ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
-        n(tx, uuid1, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
-        Connection system = c(uuid1, uuid1 + ":1", uuid1 + ":2");
-        Connection global = c(TapiConstants.PRESTO_ABSTRACT_NODE, Collections.singletonList(system.getUuid()), uuid1 + ":1", uuid1 + ":2");
-        ConnectivityService cs = cs("some-service", global);
+        n(tx, new Uuid(uuid1), activationDriverId1, uuid1 + ":1", uuid1 + ":2", uuid1 + ":3");
+        Connection system = c(tx, uuid1, uuid1 + ":1", uuid1 + ":2");
+        Connection global = c(tx, TapiConstants.PRESTO_ABSTRACT_NODE,
+                Collections.singletonList(system.getUuid()), uuid1 + ":1", uuid1 + ":2");
+        cs(tx,"some-service", global);
 
-        InstanceIdentifier<Context1> connectivityCtx = NrpDao.ctx().augmentation(Context1.class);
-
-        tx.put(LogicalDatastoreType.OPERATIONAL, connectivityCtx.child(Connection.class,  new ConnectionKey(system.getUuid())), system);
-        tx.put(LogicalDatastoreType.OPERATIONAL, connectivityCtx.child(Connection.class,  new ConnectionKey(global.getUuid())), global);
-        tx.put(LogicalDatastoreType.OPERATIONAL, connectivityCtx.child(ConnectivityService.class,  new ConnectivityServiceKey(cs.getUuid())), cs);
-        tx.submit().checkedGet();
+        tx.commit().get();
     }
 
 
     private void verifyConnection(Connection connection) {
-        assertFalse(connection.getConnectionEndPoint().isEmpty());
+        assertNotNull("Connection " + connection.getUuid().getValue() + " should have at least 2 end points",
+                connection.getConnectionEndPoint());
+        assertFalse("Connection " + connection.getUuid().getValue() + " should have at least 2 end points",
+                connection.getConnectionEndPoint().isEmpty());
     }
 
     private List<EndPoint> eps(String ... uuids) {
 
         EndPoint2Builder builder = new EndPoint2Builder();
-        EndPoint2 epAugmentation = builder.setNrpCarrierEthConnectivityEndPointResource(new NrpCarrierEthConnectivityEndPointResourceBuilder()
+        EndPoint2 epAugmentation = builder.setNrpCarrierEthConnectivityEndPointResource(
+                new NrpCarrierEthConnectivityEndPointResourceBuilder()
                 .setCeVlanIdListAndUntag(new CeVlanIdListAndUntagBuilder()
                         .setVlanId(Collections.singletonList(
                                 new VlanIdBuilder().setVlanId(new PositiveInteger(100L)).build()))
@@ -334,60 +551,51 @@ public class TapiConnectivityServiceInplIntTest extends AbstractTestWithTopo {
                 ).build()
         ).build();
 
-
         return Arrays.stream(uuids).map(uuid -> new EndPointBuilder()
                 .setLocalId("e:" + uuid)
                 .setRole(PortRole.SYMMETRIC)
                 .setDirection(PortDirection.BIDIRECTIONAL)
-                .setServiceInterfacePoint(new Uuid("sip:" + uuid))
+                .setServiceInterfacePoint(TapiUtils.toSipRef(
+                        new Uuid("sip:" + uuid), ServiceInterfacePoint.class))
                 .addAugmentation(EndPoint2.class, epAugmentation)
                 .build()).collect(Collectors.toList());
     }
 
-    private org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.context.ConnectivityService cs(String csId, Connection connection) {
-        return new ConnectivityServiceBuilder()
+    private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307
+            .connectivity.context.ConnectivityService cs(
+                    ReadWriteTransaction tx, String csId, Connection connection) {
+        ConnectivityService cs = new ConnectivityServiceBuilder()
                 .setUuid(new Uuid(csId))
                 .setConnection(Collections.singletonList(connection.getUuid()))
                 .setEndPoint(toEps(connection.getConnectionEndPoint()))
                 .build();
-    }
+        InstanceIdentifier<Context1> connectivityCtx = NrpDao.ctx().augmentation(Context1.class);
+        tx.put(LogicalDatastoreType.OPERATIONAL,
+                connectivityCtx.child(
+                        ConnectivityService.class,  new ConnectivityServiceKey(cs.getUuid())), cs);
 
-    private List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.service.EndPoint> toEps(List<ConnectionEndPoint> ceps) {
-        org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.service.EndPointBuilder builder
-                = new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.service.EndPointBuilder();
-        return ceps.stream().map(cep -> {
-            return builder.setServiceInterfacePoint(cep.getUuid())
-                    .setLocalId(cep.getUuid().getValue())
-                    .build();
-        }).collect(Collectors.toList());
-    }
+        return cs;
 
-    private org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.context.Connection c(String nodeUuid, List<Uuid> route, String... neps) {
-        ConnectionBuilder builder = new ConnectionBuilder()
-                .setUuid(new Uuid("c:" + nodeUuid))
-                .setContainerNode(new Uuid(nodeUuid))
-                .setConnectionEndPoint(ceps(neps));
-
-        if (!route.isEmpty()) {
-            builder.setRoute(Collections.singletonList(new RouteBuilder()
-                    .setConnectionEndPoint(route)
-                    .setLocalId("route")
-                    .build()
-            ));
-        }
-        return builder.build();
     }
 
-    private org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.connectivity.rev171113.connectivity.context.Connection c(String nodeUuid, String... neps) {
-        return c(nodeUuid, Collections.emptyList(), neps);
-    }
+    private List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307
+                .connectivity.service.EndPoint>
+            toEps(List<ConnectionEndPoint> ceps) {
 
-    private List<ConnectionEndPoint> ceps(String... neps) {
-        return Arrays.stream(neps).map(nep -> new ConnectionEndPointBuilder()
-                .setUuid(new Uuid("cep:" + nep))
-//                .setTerminationDirection(TerminationDirection.Bidirectional)
-                .setServerNodeEdgePoint(new Uuid(nep))
-                .build()).collect(Collectors.toList());
+        org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307
+            .connectivity.service.EndPointBuilder builder
+                = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev180307
+                    .connectivity.service.EndPointBuilder();
+        return ceps.stream().map(cep -> {
+            ServiceInterfacePoint sipRef =
+                    TapiUtils.toSipRef(
+                            new Uuid("sip:" + cep.getOwnedNodeEdgePointId().getValue()),
+                            ServiceInterfacePoint.class);
+
+            return builder.setServiceInterfacePoint(sipRef)
+                    .setLocalId(cep.getConnectionEndPointId().getValue())
+                    .build();
+        }).collect(Collectors.toList());
     }
 
 }