Migrate common module to JUnit5
[transportpce.git] / common / src / test / java / org / opendaylight / transportpce / common / mapping / PortMappingImplTest.java
index 5a16454a1c19f56ebf70265ed8750b62232992b6..132b3d45cc77c590f12484ac9b86f6d711d7aab3 100644 (file)
@@ -8,34 +8,34 @@
 
 package org.opendaylight.transportpce.common.mapping;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.opendaylight.transportpce.common.StringConstants.OPENROADM_DEVICE_VERSION_1_2_1;
 import static org.opendaylight.transportpce.common.StringConstants.OPENROADM_DEVICE_VERSION_2_2_1;
 
 import java.util.concurrent.ExecutionException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.test.DataStoreContext;
 import org.opendaylight.transportpce.test.DataStoreContextImpl;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.OpenroadmNodeVersion;
-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.rev220114.mapping.MappingBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.mapping.MappingKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.network.NodesBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.network.NodesKey;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.network.nodes.NodeInfo;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220114.network.nodes.NodeInfoBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.OpenroadmNodeVersion;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.MappingKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.NodesBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.NodesKey;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.nodes.NodeInfo;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.nodes.NodeInfoBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class PortMappingImplTest {
@@ -46,8 +46,8 @@ public class PortMappingImplTest {
     private PortMappingVersion121 portMappingVersion121;
     private PortMapping portMapping;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         DataStoreContext dataStoreContext = new DataStoreContextImpl();
         dataBroker = dataStoreContext.getDataBroker();
         portMappingVersion710 = mock(PortMappingVersion710.class);
@@ -58,7 +58,7 @@ public class PortMappingImplTest {
     }
 
     @Test
-    public void createMappingDataTest() {
+    void createMappingDataTest() {
         //test create mapping version 1
         when(portMappingVersion121.createMappingData("node")).thenReturn(true);
         assertTrue(portMapping.createMappingData("node", OPENROADM_DEVICE_VERSION_1_2_1));
@@ -71,9 +71,8 @@ public class PortMappingImplTest {
         assertFalse(portMapping.createMappingData("node", "test"));
     }
 
-
     @Test
-    public void updateMappingTest() throws ExecutionException, InterruptedException {
+    void updateMappingTest() throws ExecutionException, InterruptedException {
         Mapping mapping = new MappingBuilder().setLogicalConnectionPoint("logicalConnectionPoint")
                 .setPortDirection("1").setConnectionMapLcp("1").setPartnerLcp("1")
                 .setPortQual("1").setSupportingCircuitPackName("1").setSupportingOms("1")
@@ -97,7 +96,7 @@ public class PortMappingImplTest {
         wr.commit().get();
         //test update port mapping version 2
         when(portMappingVersion221.updateMapping("node", mapping)).thenReturn(true);
-        assertTrue("Update sould be ok", portMapping.updateMapping("node", mapping));
+        assertTrue(portMapping.updateMapping("node", mapping), "Update sould be ok");
 
         //replace node nodefino version 1 instead of version 2
         WriteTransaction wr2 = dataBroker.newWriteOnlyTransaction();
@@ -115,15 +114,12 @@ public class PortMappingImplTest {
         assertNull(portMapping.getNode("node2"));
 
         //test get portmapping for existing node
-        assertEquals(portMapping
-                .getMapping("node", "logicalConnectionPoint"), mapping);
+        assertEquals(portMapping.getMapping("node", "logicalConnectionPoint"), mapping);
 
         //test delete portmapping for existing node
         portMapping.deletePortMappingNode("node");
 
         //test get portmapping that was deleted above and doesn't exist anymore
         assertNull(portMapping.getMapping("node", "logicalConnectionPoint"));
-
     }
-
 }