Merge dev/fluorine work across to master
[unimgr.git] / impl / src / test / java / org / opendaylight / unimgr / mef / nrp / impl / ext / UnimgrExtServiceImplTest.java
index ef8bc2623048e92fee5083c855c1533b38fe9a3c..8b4adfbf5f26a0ee4a2bf9965da128aa1332d9a9 100644 (file)
@@ -12,32 +12,33 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.concurrent.ExecutionException;
 import java.util.function.Consumer;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.unimgr.mef.nrp.common.NrpDao;
 import org.opendaylight.unimgr.mef.nrp.impl.AbstractTestWithTopo;
-import org.opendaylight.yang.gen.v1.urn.mef.yang.mef.common.types.rev171221.NaturalNumber;
-import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev171221.ServiceInterfacePoint1;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.mef.common.types.rev180321.NaturalNumber;
+import org.opendaylight.yang.gen.v1.urn.mef.yang.nrp._interface.rev180321.ServiceInterfacePoint1;
 import org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.AddSipInput;
 import org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.AddSipInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.AddSipOutput;
 import org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.add.sip.input.sip.type.EnniSpecBuilder;
 import org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.add.sip.input.sip.type.InniSpecBuilder;
 import org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.add.sip.input.sip.type.UniSpecBuilder;
-import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.tapi.common.rev171113.context.attrs.ServiceInterfacePoint;
-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.topology.rev171113.node.OwnedNodeEdgePoint;
+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.common.rev180307.tapi.context.ServiceInterfacePoint;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev180307.node.OwnedNodeEdgePoint;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-/**
- * @author bartosz.michalik@amartus.com
- */
+
 public class UnimgrExtServiceImplTest extends AbstractTestWithTopo {
     private UnimgrExtServiceImpl extService;
 
-    private final String nodeId = "node-id";
+    private String nodeId = "node-id";
 
     @Before
     public void setUp() {
@@ -48,49 +49,50 @@ public class UnimgrExtServiceImplTest extends AbstractTestWithTopo {
     @Test
     public void addSipNoNep() throws Exception {
         AddSipInput input = input("non-existing-nep");
-        RpcResult<Void> result = extService.addSip(input).get();
+        RpcResult<AddSipOutput> result = extService.addSip(input).get();
         assertFalse(result.isSuccessful());
     }
 
     @Test
-    public void addSip() throws Exception {
+    public void addSip() throws InterruptedException, ExecutionException, ReadFailedException {
 
         //having
         ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
-        n(tx, false, nodeId, nodeId + ":1", nodeId + ":2", nodeId + ":3");
-        tx.submit().checkedGet();
+        n(tx, false, new Uuid(nodeId), "d:" + nodeId, nodeId + ":1", nodeId + ":2", nodeId + ":3");
+        tx.commit().get();
 
         AddSipInput input = input(nodeId + ":1", SipType.enni);
-        RpcResult<Void> result = extService.addSip(input).get();
+        RpcResult<AddSipOutput> result = extService.addSip(input).get();
         assertTrue(result.isSuccessful());
         verifySipExists(nodeId + ":1", sip -> {
-            ServiceInterfacePoint1 lpAug = sip.getAugmentation(ServiceInterfacePoint1.class);
+            ServiceInterfacePoint1 lpAug = sip.augmentation(ServiceInterfacePoint1.class);
             assertNotNull(lpAug);
             assertNotNull(lpAug.getNrpCarrierEthEnniNResource());
         });
     }
 
-
-
     @Test
-    public void addSipFailBecauseItAlreadyExists() throws Exception {
+    public void addSipFailBecauseItAlreadyExists()
+            throws InterruptedException, ExecutionException, ReadFailedException {
 
         //having
         ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
-        n(tx, true, nodeId, nodeId + ":1", nodeId + ":2", nodeId + ":3");
-        tx.submit().checkedGet();
+        n(tx, true, new Uuid(nodeId), "d:" + nodeId, nodeId + ":1", nodeId + ":2", nodeId + ":3");
+        tx.commit().get();
 
         AddSipInput input = input(nodeId + ":1");
-        RpcResult<Void> result = extService.addSip(input).get();
+        RpcResult<AddSipOutput> result = extService.addSip(input).get();
         assertFalse(result.isSuccessful());
         verifySipExists(nodeId + ":1");
     }
 
-    private void verifySipExists(String nepId, Consumer<ServiceInterfacePoint> verifySip) throws ReadFailedException {
+    private void verifySipExists(String nepId, Consumer<ServiceInterfacePoint> verifySip)
+            throws ReadFailedException {
 
         NrpDao nrpDao = new NrpDao(dataBroker.newReadOnlyTransaction());
         OwnedNodeEdgePoint nep = nrpDao.readNep(nodeId, nepId);
-        boolean hasSip = nep.getMappedServiceInterfacePoint().get(0).getValue().equals("sip:" + nepId);
+        boolean hasSip = nep.getMappedServiceInterfacePoint().get(0).getServiceInterfacePointId().getValue()
+                .equals("sip:" + nepId);
         ServiceInterfacePoint sip = nrpDao.getSip("sip:" + nepId);
         assertTrue(hasSip && sip != null);
         if (verifySip != null) {
@@ -98,7 +100,6 @@ public class UnimgrExtServiceImplTest extends AbstractTestWithTopo {
         }
     }
 
-
     private void verifySipExists(String nepId) throws ReadFailedException {
         verifySipExists(nepId, null);
     }
@@ -123,23 +124,28 @@ public class UnimgrExtServiceImplTest extends AbstractTestWithTopo {
             case uni:
                 sipBuilder.setSipType(
                     new UniSpecBuilder()
-                    .setUniSpec(new org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.add.sip.input.sip.type.uni.spec.UniSpecBuilder().build())
+                    .setUniSpec(
+                            new org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.add
+                            .sip.input.sip.type.uni.spec.UniSpecBuilder().build())
                     .build());
-            break;
+                break;
             case enni:
                 sipBuilder.setSipType(
                     new EnniSpecBuilder()
                         .setEnniSpec(
-                                new org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.add.sip.input.sip.type.enni.spec.EnniSpecBuilder()
+                                new org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.add
+                                .sip.input.sip.type.enni.spec.EnniSpecBuilder()
                                         .setMaxFrameSize(new NaturalNumber(new Long(1000)))
                                         .build())
                     .build());
-            break;
+                break;
             case inni:
             default:
                 sipBuilder.setSipType(
                     new InniSpecBuilder()
-                    .setInniSpec(new org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.add.sip.input.sip.type.inni.spec.InniSpecBuilder().build())
+                    .setInniSpec(
+                            new org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.add
+                            .sip.input.sip.type.inni.spec.InniSpecBuilder().build())
                     .build());
         }