Migrate networkmodel module to JUnit5
[transportpce.git] / networkmodel / src / test / java / org / opendaylight / transportpce / networkmodel / listeners / DeviceListener121Test.java
index a862a02d764cff8a21b36e0dd501e38f5db1fbe8..efe1d28943f5750a1f5e6e481d6108a5db3a307c 100644 (file)
@@ -17,13 +17,14 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import com.google.common.collect.ImmutableList;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.mapping.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.ChangeNotification;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceData;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.change.notification.Edit;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.change.notification.EditBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.circuit.pack.Ports;
@@ -34,13 +35,13 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.org.open
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
+@ExtendWith(MockitoExtension.class)
 public class DeviceListener121Test {
     @Mock
     private PortMapping portMapping;
 
     @Test
-    public void testOnChangeNotificationWhenPortUpdated() throws InterruptedException {
+    void testOnChangeNotificationWhenPortUpdated() throws InterruptedException {
         ChangeNotification notification = mock(ChangeNotification.class);
         Mapping oldMapping = mock(Mapping.class);
         ImmutableList<Edit> editList = createEditList();
@@ -55,7 +56,7 @@ public class DeviceListener121Test {
     }
 
     @Test
-    public void testOnChangeNotificationWhenNoEditList() {
+    void testOnChangeNotificationWhenNoEditList() {
         ChangeNotification notification = mock(ChangeNotification.class);
         when(notification.getEdit()).thenReturn(null);
         DeviceListener121 listener = new DeviceListener121("node1", portMapping);
@@ -65,7 +66,7 @@ public class DeviceListener121Test {
     }
 
     @Test
-    public void testOnChangeNotificationWhenOtherthingUpdated() {
+    void testOnChangeNotificationWhenOtherthingUpdated() {
         ChangeNotification notification = mock(ChangeNotification.class);
         ImmutableList<Edit> editList = createBadEditList();
         when(notification.getEdit()).thenReturn(editList);
@@ -76,9 +77,11 @@ public class DeviceListener121Test {
     }
 
     private ImmutableList<Edit> createEditList() {
-        InstanceIdentifier<Ports> portId = InstanceIdentifier.create(OrgOpenroadmDevice.class)
+        InstanceIdentifier<Ports> portId = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
             .child(CircuitPacks.class, new CircuitPacksKey("circuit-pack1"))
-            .child(Ports.class, new PortsKey("port1"));
+            .child(Ports.class, new PortsKey("port1"))
+            .build();
         Edit edit = new EditBuilder()
             .setOperation(EditOperationType.Merge)
             .setTarget(portId)
@@ -88,8 +91,10 @@ public class DeviceListener121Test {
     }
 
     private ImmutableList<Edit> createBadEditList() {
-        InstanceIdentifier<CircuitPacks> cpId = InstanceIdentifier.create(OrgOpenroadmDevice.class)
-            .child(CircuitPacks.class, new CircuitPacksKey("circuit-pack1"));
+        InstanceIdentifier<CircuitPacks> cpId = InstanceIdentifier
+            .builderOfInherited(OrgOpenroadmDeviceData.class, OrgOpenroadmDevice.class)
+            .child(CircuitPacks.class, new CircuitPacksKey("circuit-pack1"))
+            .build();
         Edit edit = new EditBuilder()
             .setOperation(EditOperationType.Merge)
             .setTarget(cpId)