From: Gilles Thouenon Date: Sun, 26 Feb 2023 13:37:44 +0000 (+0100) Subject: Migrate networkmodel module to JUnit5 X-Git-Tag: 7.0.0~18 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=commitdiff_plain;h=6bc844fe96e1bd2ae991f5a1b2ad3f7446f87f10 Migrate networkmodel module to JUnit5 JIRA: TRNSPRTPCE-730 Signed-off-by: Gilles Thouenon Change-Id: I68a6718804e6013fe46a4cb41f4a8a98b4fc9ba1 --- diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetwork.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetwork.java index 0a62dd2a4..83759113a 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetwork.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetwork.java @@ -76,11 +76,11 @@ public final class OpenRoadmNetwork { // Sets the value of Network-ref and Node-ref as a part of the supporting node // attribute SupportingNode supportingNode = new SupportingNodeBuilder() - .setNetworkRef(new NetworkId(NetworkUtils.CLLI_NETWORK_ID)) - .setNodeRef(new NodeId(nodeInfo.getNodeClli())) - .withKey(new SupportingNodeKey(new NetworkId(NetworkUtils.CLLI_NETWORK_ID), - new NodeId(nodeInfo.getNodeClli()))) - .build(); + .setNetworkRef(new NetworkId(NetworkUtils.CLLI_NETWORK_ID)) + .setNodeRef(new NodeId(nodeInfo.getNodeClli())) + .withKey(new SupportingNodeKey(new NetworkId(NetworkUtils.CLLI_NETWORK_ID), + new NodeId(nodeInfo.getNodeClli()))) + .build(); return new NodeBuilder() .setNodeId(new NodeId(nodeId)) diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/NetConfTopologyListenerTest.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/NetConfTopologyListenerTest.java index 7fc2b4c5f..7dbc8601d 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/NetConfTopologyListenerTest.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/NetConfTopologyListenerTest.java @@ -21,10 +21,10 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Map; -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.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.DataObjectModification; import org.opendaylight.mdsal.binding.api.DataTreeModification; @@ -51,7 +51,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; -@RunWith(MockitoJUnitRunner.StrictStubs.class) +@ExtendWith(MockitoExtension.class) public class NetConfTopologyListenerTest { @Mock @@ -66,7 +66,7 @@ public class NetConfTopologyListenerTest { private Map registrations; @Test - public void testOnDataTreeChangedWhenDeleteNode() { + void testOnDataTreeChangedWhenDeleteNode() { @SuppressWarnings("unchecked") final DataObjectModification node = mock(DataObjectModification.class); final Collection> changes = new HashSet<>(); @SuppressWarnings("unchecked") final DataTreeModification ch = mock(DataTreeModification.class); @@ -90,7 +90,7 @@ public class NetConfTopologyListenerTest { } @Test - public void testOnDataTreeChangedWhenAddNode() { + void testOnDataTreeChangedWhenAddNode() { @SuppressWarnings("unchecked") final DataObjectModification node = mock(DataObjectModification.class); final Collection> changes = new HashSet<>(); @SuppressWarnings("unchecked") final DataTreeModification ch = mock(DataTreeModification.class); @@ -116,7 +116,7 @@ public class NetConfTopologyListenerTest { } @Test - public void testOnDataTreeChangedWhenDisconnectingNode() { + void testOnDataTreeChangedWhenDisconnectingNode() { @SuppressWarnings("unchecked") final DataObjectModification node = mock(DataObjectModification.class); final Collection> changes = new HashSet<>(); @SuppressWarnings("unchecked") final DataTreeModification ch = mock(DataTreeModification.class); @@ -143,7 +143,7 @@ public class NetConfTopologyListenerTest { } @Test - public void testOnDataTreeChangedWhenShouldNeverHappen() { + void testOnDataTreeChangedWhenShouldNeverHappen() { @SuppressWarnings("unchecked") final DataObjectModification node = mock(DataObjectModification.class); final Collection> changes = new HashSet<>(); @SuppressWarnings("unchecked") final DataTreeModification ch = mock(DataTreeModification.class); diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/NetworkModelProviderTest.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/NetworkModelProviderTest.java index 04dec312d..5f31c3bdc 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/NetworkModelProviderTest.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/NetworkModelProviderTest.java @@ -13,11 +13,11 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.util.concurrent.FluentFuture; -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.invocation.InvocationOnMock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.stubbing.Answer; import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.mdsal.binding.api.RpcProviderService; @@ -28,7 +28,7 @@ import org.opendaylight.transportpce.networkmodel.service.FrequenciesService; import org.opendaylight.transportpce.test.AbstractTest; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.TransportpceNetworkutilsService; -@RunWith(MockitoJUnitRunner.StrictStubs.class) +@ExtendWith(MockitoExtension.class) public class NetworkModelProviderTest extends AbstractTest { @Mock NetworkTransactionService networkTransactionService; @@ -47,7 +47,7 @@ public class NetworkModelProviderTest extends AbstractTest { @Test - public void networkmodelProviderInitTest() { + void networkmodelProviderInitTest() { NetworkModelProvider provider = new NetworkModelProvider(networkTransactionService, getDataBroker(), rpcProviderService, networkutilsService, topologyListener, notificationService, frequenciesService, portMappingListener); @@ -66,5 +66,4 @@ public class NetworkModelProviderTest extends AbstractTest { verify(rpcProviderService, times(1)) .registerRpcImplementation(any(), any(TransportpceNetworkutilsService.class)); } - } diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener121Test.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener121Test.java index d2d38ae64..efe1d2894 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener121Test.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener121Test.java @@ -17,10 +17,10 @@ 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.rev220316.mapping.Mapping; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.ChangeNotification; @@ -35,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 editList = createEditList(); @@ -56,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); @@ -66,7 +66,7 @@ public class DeviceListener121Test { } @Test - public void testOnChangeNotificationWhenOtherthingUpdated() { + void testOnChangeNotificationWhenOtherthingUpdated() { ChangeNotification notification = mock(ChangeNotification.class); ImmutableList editList = createBadEditList(); when(notification.getEdit()).thenReturn(editList); diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener221Test.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener221Test.java index d27cf42bd..1779399df 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener221Test.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener221Test.java @@ -17,10 +17,10 @@ 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.rev220316.mapping.Mapping; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.ChangeNotification; @@ -35,13 +35,13 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.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 DeviceListener221Test { @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 editList = createEditList(); @@ -56,7 +56,7 @@ public class DeviceListener221Test { } @Test - public void testOnChangeNotificationWhenNoEditList() { + void testOnChangeNotificationWhenNoEditList() { ChangeNotification notification = mock(ChangeNotification.class); when(notification.getEdit()).thenReturn(null); DeviceListener221 listener = new DeviceListener221("node1", portMapping); @@ -66,7 +66,7 @@ public class DeviceListener221Test { } @Test - public void testOnChangeNotificationWhenOtherthingUpdated() { + void testOnChangeNotificationWhenOtherthingUpdated() { ChangeNotification notification = mock(ChangeNotification.class); ImmutableList editList = createBadEditList(); when(notification.getEdit()).thenReturn(editList); diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener710Test.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener710Test.java index 56a5a4694..0dfe7405c 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener710Test.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/DeviceListener710Test.java @@ -17,10 +17,10 @@ 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.rev220316.mapping.Mapping; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.ChangeNotification; @@ -35,13 +35,13 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.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 DeviceListener710Test { @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 editList = createEditList(); @@ -56,7 +56,7 @@ public class DeviceListener710Test { } @Test - public void testOnChangeNotificationWhenNoEditList() { + void testOnChangeNotificationWhenNoEditList() { ChangeNotification notification = mock(ChangeNotification.class); when(notification.getEdit()).thenReturn(null); DeviceListener710 listener = new DeviceListener710("node1", portMapping); @@ -66,7 +66,7 @@ public class DeviceListener710Test { } @Test - public void testOnChangeNotificationWhenOtherthingUpdated() { + void testOnChangeNotificationWhenOtherthingUpdated() { ChangeNotification notification = mock(ChangeNotification.class); ImmutableList editList = createBadEditList(); when(notification.getEdit()).thenReturn(editList); diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/PortMappingListenerTest.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/PortMappingListenerTest.java index 32ec06a66..50afef19a 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/PortMappingListenerTest.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/listeners/PortMappingListenerTest.java @@ -9,7 +9,7 @@ package org.opendaylight.transportpce.networkmodel.listeners; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.anyString; -import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; @@ -18,33 +18,33 @@ import static org.mockito.Mockito.when; import java.util.Collection; import java.util.HashSet; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.opendaylight.mdsal.binding.api.DataObjectModification; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.transportpce.networkmodel.service.NetworkModelService; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class PortMappingListenerTest { @Mock private NetworkModelService networkModelService; private PortMappingListener portMappingListenerSpy; - @Before - public void setUp() { + @BeforeEach + void setUp() { portMappingListenerSpy = Mockito.spy(new PortMappingListener(networkModelService)); - doReturn("NodeID").when(portMappingListenerSpy).getNodeIdFromMappingDataTreeIdentifier(any()); + lenient().doReturn("NodeID").when(portMappingListenerSpy).getNodeIdFromMappingDataTreeIdentifier(any()); } @Test - public void testOnDataTreeChangedWhenMappingOperAndAdminDidntChange() { + void testOnDataTreeChangedWhenMappingOperAndAdminDidntChange() { final Collection> changes = new HashSet<>(); @SuppressWarnings("unchecked") final DataTreeModification ch = mock(DataTreeModification.class); changes.add(ch); @@ -66,7 +66,7 @@ public class PortMappingListenerTest { } @Test - public void testOnDataTreeChangedWhenMappingAdminChanged() { + void testOnDataTreeChangedWhenMappingAdminChanged() { final Collection> changes = new HashSet<>(); @SuppressWarnings("unchecked") final DataTreeModification ch = mock(DataTreeModification.class); changes.add(ch); @@ -86,7 +86,7 @@ public class PortMappingListenerTest { } @Test - public void testOnDataTreeChangedWhenMappingOperChanged() { + void testOnDataTreeChangedWhenMappingOperChanged() { final Collection> changes = new HashSet<>(); @SuppressWarnings("unchecked") final DataTreeModification ch = mock(DataTreeModification.class); changes.add(ch); diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/service/FrequenciesServiceTest.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/service/FrequenciesServiceTest.java index cf3eb8433..7df86407c 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/service/FrequenciesServiceTest.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/service/FrequenciesServiceTest.java @@ -8,9 +8,10 @@ package org.opendaylight.transportpce.networkmodel.service; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.fail; import java.io.FileNotFoundException; import java.io.FileReader; @@ -22,9 +23,9 @@ import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.opendaylight.mdsal.binding.api.ReadTransaction; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.common.InstanceIdentifiers; @@ -46,7 +47,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@Ignore +@Disabled public class FrequenciesServiceTest extends AbstractTest { private static final Logger LOG = LoggerFactory.getLogger(FrequenciesServiceTest.class); private static final String OPENROADM_TOPOLOGY_FILE = "src/test/resources/openroadm-topology.xml"; @@ -56,8 +57,8 @@ public class FrequenciesServiceTest extends AbstractTest { private final BitSet usedBits = new BitSet(8); private static BitSet availableBits = new BitSet(8); - @BeforeClass - public static void setUp() throws InterruptedException, ExecutionException, FileNotFoundException { + @BeforeAll + static void setUp() throws InterruptedException, ExecutionException, FileNotFoundException { availableBits.set(0, 8, true); TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(), OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II); @@ -76,41 +77,53 @@ public class FrequenciesServiceTest extends AbstractTest { } @Test - public void allocateFrequenciesTest() throws IOException { + void allocateFrequenciesTest() throws IOException { FrequenciesService service = new FrequenciesServiceImpl(getDataBroker()); service.allocateFrequencies(pathDescription.getAToZDirection(), pathDescription.getZToADirection()); TerminationPoint1 terminationPoint = getNetworkTerminationPointFromDatastore("ROADM-A1-DEG2", "DEG2-CTP-TXRX"); - assertEquals("Lambda 1 should not be available for ctp-attributes", - BitSet.valueOf(terminationPoint.getCtpAttributes().getAvailFreqMaps().get(availFreqMapKey) - .getFreqMap()).get(760, 768),usedBits); - assertNull("cp-attributes should be null", terminationPoint.getCpAttributes()); + assertEquals( + BitSet.valueOf(terminationPoint.getCtpAttributes().getAvailFreqMaps().get(availFreqMapKey).getFreqMap()) + .get(760, 768), + usedBits, + "Lambda 1 should not be available for ctp-attributes"); + assertNull(terminationPoint.getCpAttributes(), "cp-attributes should be null"); terminationPoint = getNetworkTerminationPointFromDatastore("ROADM-A1-SRG1", "SRG1-PP1-TXRX"); - assertEquals("Lambda 1 should not be available for pp-attributes", - BitSet.valueOf(terminationPoint.getPpAttributes().getAvailFreqMaps().get(availFreqMapKey) - .getFreqMap()).get(760, 768),usedBits); + assertEquals( + BitSet.valueOf(terminationPoint.getPpAttributes().getAvailFreqMaps().get(availFreqMapKey).getFreqMap()) + .get(760, 768), + usedBits, + "Lambda 1 should not be available for pp-attributes"); Node1 node = getNetworkNodeFromDatastore("ROADM-A1-SRG1"); - assertEquals("Lambda 1 should not be available for srg-attributes", - BitSet.valueOf(node.getSrgAttributes().getAvailFreqMaps().get(availFreqMapKey) - .getFreqMap()).get(760, 768),usedBits); + assertEquals( + BitSet.valueOf(node.getSrgAttributes().getAvailFreqMaps().get(availFreqMapKey).getFreqMap()) + .get(760, 768), + usedBits, + "Lambda 1 should not be available for srg-attributes"); } @Test - public void releaseFrequenciesTest() throws IOException { + void releaseFrequenciesTest() throws IOException { FrequenciesService service = new FrequenciesServiceImpl(getDataBroker()); service.allocateFrequencies(pathDescription.getAToZDirection(), pathDescription.getZToADirection()); service.releaseFrequencies(pathDescription.getAToZDirection(), pathDescription.getZToADirection()); TerminationPoint1 terminationPoint = getNetworkTerminationPointFromDatastore("ROADM-A1-DEG2", "DEG2-CTP-TXRX"); - assertEquals("Lambda 1 should be available for ctp-attributes", - BitSet.valueOf(terminationPoint.getCtpAttributes().getAvailFreqMaps().get(availFreqMapKey) - .getFreqMap()).get(760, 768),availableBits); + assertEquals( + BitSet.valueOf(terminationPoint.getCtpAttributes().getAvailFreqMaps().get(availFreqMapKey) + .getFreqMap()).get(760, 768), + availableBits, + "Lambda 1 should be available for ctp-attributes"); terminationPoint = getNetworkTerminationPointFromDatastore("ROADM-A1-SRG1", "SRG1-PP1-TXRX"); - assertEquals("Lambda 1 should be available for pp-attributes", - BitSet.valueOf(terminationPoint.getPpAttributes().getAvailFreqMaps().get(availFreqMapKey) - .getFreqMap()).get(760, 768),availableBits); + assertEquals( + BitSet.valueOf(terminationPoint.getPpAttributes().getAvailFreqMaps().get(availFreqMapKey) + .getFreqMap()).get(760, 768), + availableBits, + "Lambda 1 should be available for pp-attributes"); Node1 node = getNetworkNodeFromDatastore("ROADM-A1-SRG1"); - assertEquals("Lambda 1 should be available for srg-attributes", - BitSet.valueOf(node.getSrgAttributes().getAvailFreqMaps().get(availFreqMapKey) - .getFreqMap()).get(760, 768),availableBits); + assertEquals( + BitSet.valueOf(node.getSrgAttributes().getAvailFreqMaps().get(availFreqMapKey) + .getFreqMap()).get(760, 768), + availableBits, + "Lambda 1 should be available for srg-attributes"); } private TerminationPoint1 getNetworkTerminationPointFromDatastore(String nodeId, String tpId) { @@ -160,5 +173,4 @@ public class FrequenciesServiceTest extends AbstractTest { return null; } } - } diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/ClliNetworkTest.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/ClliNetworkTest.java index df1c8d7c1..8d6fc3d7c 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/ClliNetworkTest.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/ClliNetworkTest.java @@ -7,10 +7,11 @@ */ package org.opendaylight.transportpce.networkmodel.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.junit.jupiter.api.Test; 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.network.nodes.NodeInfo; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.nodes.NodeInfoBuilder; @@ -26,7 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev public class ClliNetworkTest { @Test - public void createNodeTest() { + void createNodeTest() { //prepare data test NodeInfo nodeInfo = computeNodeInfoBuilder().build(); Node1 clliAugmentation = new Node1Builder() @@ -35,18 +36,18 @@ public class ClliNetworkTest { //run test Node createdNode = ClliNetwork.createNode("XPDRA01", nodeInfo); - assertNull("SupportingNode should be null", createdNode.getSupportingNode()); - assertEquals("Node key should be equals to NodeClliId ", new NodeKey(new NodeId("NodeClliId")), - createdNode.key()); - assertEquals("Expect org.opendaylight.yang.gen.v1.http.org.openroadm.clli.network.rev191129.Node1 augmentation", - clliAugmentation, createdNode.augmentation(Node1.class)); + assertNull(createdNode.getSupportingNode(), "SupportingNode should be null"); + assertEquals(new NodeKey(new NodeId("NodeClliId")), createdNode.key(), + "Node key should be equals to NodeClliId"); + assertEquals(clliAugmentation, createdNode.augmentation(Node1.class), + "Expect org.opendaylight.yang.gen.v1.http.org.openroadm.clli.network.rev191129.Node1 augmentation"); } @Test - public void createNodeWithNullDeviceIdTest() { + void createNodeWithNullDeviceIdTest() { Node createdNode = ClliNetwork.createNode(null, computeNodeInfoBuilder().build()); - assertNull("SupportingNode should be null", createdNode.getSupportingNode()); - assertEquals("Node id should be equals to NodeClliId ", new NodeId("NodeClliId"), createdNode.getNodeId()); + assertNull(createdNode.getSupportingNode(), "SupportingNode should be null"); + assertEquals(new NodeId("NodeClliId"), createdNode.getNodeId(), "Node id should be equals to NodeClliId"); } private NodeInfoBuilder computeNodeInfoBuilder() { diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetworkTest.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetworkTest.java index 06492ccd3..20a20e89d 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetworkTest.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetworkTest.java @@ -8,13 +8,15 @@ package org.opendaylight.transportpce.networkmodel.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.opendaylight.transportpce.common.NetworkUtils; 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.network.nodes.NodeInfo; @@ -32,7 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev public class OpenRoadmNetworkTest { @Test - public void createXpdrNodeTest() { + void createXpdrNodeTest() { NodeInfo nodeInfo = computeNodeInfo(NodeTypes.Xpdr, "nodeA"); Node createdNode = OpenRoadmNetwork.createNode("XPDRA01", nodeInfo); assertEquals("XPDRA01", createdNode.getNodeId().getValue()); @@ -42,7 +44,7 @@ public class OpenRoadmNetworkTest { } @Test - public void createRdmNodeTest() { + void createRdmNodeTest() { NodeInfo nodeInfo = computeNodeInfo(NodeTypes.Rdm, "nodeA"); Node createdNode = OpenRoadmNetwork.createNode("XPDRA01", nodeInfo); assertEquals("XPDRA01", createdNode.getNodeId().getValue()); @@ -52,23 +54,22 @@ public class OpenRoadmNetworkTest { } @Test - public void createNodeWithBadNodeTypeTest() { + void createNodeWithBadNodeTypeTest() { NodeInfo nodeInfo = computeNodeInfo(NodeTypes.Ila, "nodeA"); Node createdNode = OpenRoadmNetwork.createNode("XPDRA01", nodeInfo); assertEquals("XPDRA01", createdNode.getNodeId().getValue()); - assertNull("NodeType should be ROADM or XPONDER", createdNode.augmentation(Node1.class).getNodeType()); + assertNull(createdNode.augmentation(Node1.class).getNodeType(), "NodeType should be ROADM or XPONDER"); supportingNodeTest(nodeInfo.getNodeClli(), createdNode); } - @Ignore @Test - public void createNodeWithoutClliTest() { + void createNodeWithoutClliTest() { NodeInfo nodeInfo = computeNodeInfo(NodeTypes.Xpdr, null); - Node createdNode = OpenRoadmNetwork.createNode("XPDRA01", nodeInfo); - assertEquals("XPDRA01", createdNode.getNodeId().getValue()); - assertEquals("XPONDER", createdNode.augmentation(Node1.class).getNodeType().getName()); - assertEquals(0, createdNode.getSupportingNode().size()); + Exception exception = assertThrows(NullPointerException.class, () -> { + OpenRoadmNetwork.createNode("XPDRA01", nodeInfo); + }); + assertTrue("Supplied value may not be null".contains(exception.getMessage())); } private NodeInfo computeNodeInfo(NodeTypes nodeType, String clli) { diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopologyTest.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopologyTest.java index 144aef0d4..3718002d2 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopologyTest.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmOtnTopologyTest.java @@ -15,11 +15,11 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsCollectionWithSize.hasSize; import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +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.junit.jupiter.api.Assertions.fail; import com.google.gson.stream.JsonReader; import java.io.FileReader; @@ -31,7 +31,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.opendaylight.transportpce.networkmodel.dto.TopologyShard; import org.opendaylight.transportpce.networkmodel.util.test.JsonUtil; import org.opendaylight.transportpce.networkmodel.util.test.NetworkmodelTestUtil; @@ -113,116 +113,87 @@ public class OpenRoadmOtnTopologyTest { } @Test - public void createTopologyShardForTpdrTest() { + void createTopologyShardForTpdrTest() { TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingTpdr); - assertNotNull("TopologyShard should never be null", topologyShard); - assertEquals("Should contain a single node", 1, topologyShard.getNodes().size()); - assertEquals("Should contain no link", 0, topologyShard.getLinks().size()); + assertNotNull(topologyShard, "TopologyShard should never be null"); + assertEquals(1, topologyShard.getNodes().size(), "Should contain a single node"); + assertEquals(0, topologyShard.getLinks().size(), "Should contain no link"); Node node = topologyShard.getNodes().get(0); assertEquals("XPDR-A1-XPDR1", node.getNodeId().getValue()); // tests supporting nodes List supportingNodes = node.nonnullSupportingNode().values().stream() .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue())) .collect(Collectors.toList()); - assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size()); - assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue()); - assertEquals("NodeA", supportingNodes.get(0).getNodeRef().getValue()); - assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue()); - assertEquals("XPDR-A1", supportingNodes.get(1).getNodeRef().getValue()); - assertEquals("openroadm-topology", supportingNodes.get(2).getNetworkRef().getValue()); - assertEquals("XPDR-A1-XPDR1", supportingNodes.get(2).getNodeRef().getValue()); + assertEquals(3, supportingNodes.size(),"Should contain 3 supporting nodes"); + assertEquals(supportingNodes.get(0).getNetworkRef().getValue(), "clli-network"); + assertEquals(supportingNodes.get(0).getNodeRef().getValue(), "NodeA"); + assertEquals(supportingNodes.get(1).getNetworkRef().getValue(), "openroadm-network"); + assertEquals(supportingNodes.get(1).getNodeRef().getValue(), "XPDR-A1"); + assertEquals(supportingNodes.get(2).getNetworkRef().getValue(), "openroadm-topology"); + assertEquals(supportingNodes.get(2).getNodeRef().getValue(), "XPDR-A1-XPDR1"); assertEquals(OpenroadmNodeType.TPDR, node.augmentation(Node1.class).getNodeType()); assertEquals( Uint16.valueOf(1), node.augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210.Node1.class) - .getXpdrAttributes() - .getXpdrNumber()); + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210.Node1.class) + .getXpdrAttributes().getXpdrNumber()); //tests list of TPs List tps = node.augmentation( org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) .nonnullTerminationPoint().values().stream() - .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue())) - .collect(Collectors.toList()); - assertEquals("node should contain 4 TPs", 4, tps.size()); + .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue())) + .collect(Collectors.toList()); + assertEquals(4, tps.size(), "node should contain 4 TPs"); //tests client tp assertEquals("XPDR1-CLIENT1", tps.get(0).getTpId().getValue()); assertEquals( "XPDR1-NETWORK1", - tps.get(0) - .augmentation(TerminationPoint1.class) - .getAssociatedConnectionMapTp() - .iterator() - .next() - .getValue()); + tps.get(0).augmentation( + TerminationPoint1.class).getAssociatedConnectionMapTp().iterator().next().getValue()); assertEquals( - "only If100GE interface capabitily expected", 1, - tps.get(0).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 + tps.get(0).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability() - .size()); + .getTpSupportedInterfaces().getSupportedInterfaceCapability().size(), + "only If100GE interface capabitily expected"); assertEquals( If100GE.VALUE, - tps.get(0).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 + tps.get(0).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getTpSupportedInterfaces().nonnullSupportedInterfaceCapability() - .values().stream().findFirst() - .get().getIfCapType()); - assertEquals( - "first TP must be of type client", - OpenroadmTpType.XPONDERCLIENT, - tps.get(0).augmentation(TerminationPoint1.class).getTpType()); + .getTpSupportedInterfaces().nonnullSupportedInterfaceCapability().values().stream().findFirst() + .get().getIfCapType()); + assertEquals(OpenroadmTpType.XPONDERCLIENT,tps.get(0).augmentation(TerminationPoint1.class).getTpType(), + "first TP must be of type client"); //tests network tp assertEquals("XPDR1-NETWORK1", tps.get(2).getTpId().getValue()); + assertEquals("XPDR1-CLIENT1", tps.get(2).augmentation(TerminationPoint1.class) + .getAssociatedConnectionMapTp().iterator().next().getValue()); assertEquals( - "XPDR1-CLIENT1", - tps.get(2).augmentation(TerminationPoint1.class) - .getAssociatedConnectionMapTp() - .iterator() - .next() - .getValue()); - assertEquals( - "only IfOCH interface capabitily expected", 1, - tps.get(2).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 + tps.get(2).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability() - .size()); + .getTpSupportedInterfaces().getSupportedInterfaceCapability().size()); assertEquals( IfOCH.VALUE, - tps.get(2).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 + tps.get(2).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability() - .values().stream().findFirst() - .get() - .getIfCapType()); + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst().get() + .getIfCapType()); assertNull( - "the rate should be null", - tps.get(2).augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 - .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getRate()); - assertEquals( - "third TP must be of type network", - OpenroadmTpType.XPONDERNETWORK, - tps.get(2).augmentation(TerminationPoint1.class).getTpType()); + tps.get(2).augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 + .TerminationPoint1.class) + .getXpdrTpPortConnectionAttributes().getRate(), + "the rate should be null"); + assertEquals(OpenroadmTpType.XPONDERNETWORK,tps.get(2).augmentation(TerminationPoint1.class).getTpType(), + "third TP must be of type network"); } @Test - public void createTopologyShardForSpdrTest() { + void createTopologyShardForSpdrTest() { TopologyShard topologyShard = OpenRoadmOtnTopology.createTopologyShard(this.portMappingSpdr); - assertNotNull("TopologyShard should never be null", topologyShard); - assertEquals("Should contain two nodes", 2, topologyShard.getNodes().size()); - assertEquals("Should contain no link", 0, topologyShard.getLinks().size()); + assertNotNull(topologyShard, "TopologyShard should never be null"); + assertEquals(2, topologyShard.getNodes().size(), "Should contain two nodes"); + assertEquals(0, topologyShard.getLinks().size(), "Should contain no link"); List nodes = topologyShard.getNodes().stream() .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue())) .collect(Collectors.toList()); @@ -232,90 +203,88 @@ public class OpenRoadmOtnTopologyTest { } @Test - public void createOtnLinksForOTU4NormalTest() { + void createOtnLinksForOTU4NormalTest() { String nodeA = "SPDRA"; String tpA = "XPDR1-NETWORK1"; String nodeZ = "SPDRZ"; String tpZ = "XPDR1-NETWORK1"; List links = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.OTU4).getLinks(); - assertEquals("2 OTU4 links should have been created", 2, links.size()); + assertEquals(2, links.size(), "2 OTU4 links should have been created"); List sortedLinks = links.stream() .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue())) .collect(Collectors.toList()); assertEquals( - "name of OTU4 linkid AZ", "OTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1", - sortedLinks.get(0).getLinkId().getValue()); + sortedLinks.get(0).getLinkId().getValue(), + "name of OTU4 linkid AZ"); assertEquals( - "name of OTU4 linkid ZA", "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1", - sortedLinks.get(1).getLinkId().getValue()); + sortedLinks.get(1).getLinkId().getValue(), + "name of OTU4 linkid ZA"); assertEquals("SPDRA-XPDR1", sortedLinks.get(0).getSource().getSourceNode().getValue()); assertEquals("SPDRZ-XPDR1", sortedLinks.get(0).getDestination().getDestNode().getValue()); assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue()); assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue()); assertEquals( - "available BW at OTU4 creation should be 100G (100000)", Uint32.valueOf(100000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "available BW at OTU4 creation should be 100G (100000)"); assertEquals( - "used BW at OTU4 creation should be 0", Uint32.valueOf(0), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "used BW at OTU4 creation should be 0"); assertEquals( OpenroadmLinkType.OTNLINK, sortedLinks.get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1.class) .getLinkType()); assertEquals( - "opposite link must be present", "OTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1", sortedLinks.get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1.class) - .getOppositeLink() - .getValue()); + .getOppositeLink().getValue(), + "opposite link must be present"); assertEquals( - "otn link type should be OTU4", OtnLinkType.OTU4, sortedLinks.get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.Link1.class) - .getOtnLinkType()); + .getOtnLinkType(), + "otn link type should be OTU4"); } @Test - public void createOtnLinksForNotManagedOtnlinktypeTest() { + void createOtnLinksForNotManagedOtnlinktypeTest() { String nodeA = "SPDRA"; String tpA = "XPDR1-NETWORK1"; String nodeZ = "SPDRZ"; String tpZ = "XPDR1-NETWORK1"; TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks(nodeA, tpA, nodeZ, tpZ, OtnLinkType.ODU0); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("TopologyShard should not contain any node", topoShard.getNodes()); - assertNull("TopologyShard should not contain any link", topoShard.getLinks()); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "TopologyShard should not contain any node"); + assertNull(topoShard.getLinks(), "TopologyShard should not contain any link"); } @Test - public void createOtnLinksForODU4NormalTest() { + void createOtnLinksForODU4NormalTest() { TopologyShard topoShard = OpenRoadmOtnTopology .createOtnLinks( NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(100000)), NetworkmodelTestUtil.createTpList(false), OtnLinkType.ODTU4); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("list of nodes should be null", topoShard.getNodes()); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); List sortedLinks = topoShard.getLinks().stream() .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue())) .collect(Collectors.toList()); - assertEquals("list of links should contain 4 links", 4, sortedLinks.size()); - assertTrue("link 3 should be of type OTU4", sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-")); + assertEquals(4, sortedLinks.size(), "list of links should contain 4 links"); + assertTrue(sortedLinks.get(2).getLinkId().getValue().startsWith("OTU4-"), "link 3 should be of type OTU4"); assertEquals( - "after odu4 creation, available BW of supported OTU4 should be 0", Uint32.valueOf(0), - sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(2).augmentation(Link1.class).getAvailableBandwidth(), + "after odu4 creation, available BW of supported OTU4 should be 0"); assertEquals( - "after odu4 creation, used BW of supported OTU4 should be 100 000", Uint32.valueOf(100000), - sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth()); - + sortedLinks.get(2).augmentation(Link1.class).getUsedBandwidth(), + "after odu4 creation, used BW of supported OTU4 should be 100 000"); assertEquals( "ODTU4-SPDRA-XPDR1-XPDR1-NETWORK1toSPDRZ-XPDR1-XPDR1-NETWORK1", sortedLinks.get(0).getLinkId().getValue()); @@ -327,435 +296,358 @@ public class OpenRoadmOtnTopologyTest { assertEquals("SPDRZ-XPDR1", sortedLinks.get(1).getSource().getSourceNode().getValue()); assertEquals("SPDRA-XPDR1", sortedLinks.get(1).getDestination().getDestNode().getValue()); assertEquals( - "after odu4 creation, its available BW should be 100 000", Uint32.valueOf(100000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after odu4 creation, its available BW should be 100 000"); assertEquals( - "after odu4 creation, its used BW should be 0", Uint32.valueOf(0), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "after odu4 creation, its used BW should be 0"); assertEquals( OpenroadmLinkType.OTNLINK, - sortedLinks.get(0) - .augmentation( + sortedLinks.get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1.class) .getLinkType()); assertEquals( - "opposite link must be present", "ODTU4-SPDRZ-XPDR1-XPDR1-NETWORK1toSPDRA-XPDR1-XPDR1-NETWORK1", - sortedLinks.get(0) - .augmentation( + sortedLinks.get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.Link1.class) - .getOppositeLink() - .getValue()); + .getOppositeLink().getValue(), + "opposite link must be present"); assertEquals( - "otn link type should be ODTU4", OtnLinkType.ODTU4, - sortedLinks.get(0) - .augmentation(org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630 - .Link1.class) - .getOtnLinkType()); + sortedLinks.get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.Link1.class) + .getOtnLinkType(), + "otn link type should be ODTU4"); - assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size()); + assertEquals(2, topoShard.getTps().size(), "list of TPs should contain 2 updated TPs"); assertNotNull( - "after ODU4 creation, its termination point should contain a TsPool list", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool()); + .getXpdrTpPortConnectionAttributes().getTsPool(), + "after ODU4 creation, its termination point should contain a TsPool list"); assertEquals( - "Ts pool list should be full, with 80 trib slots", 80, - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool() - .size()); + .getXpdrTpPortConnectionAttributes().getTsPool().size(), + "Ts pool list should be full, with 80 trib slots"); assertNotNull( - "after ODU4 creation, its termination point should contain a TpnPool list", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().values().stream().findFirst() - .get() - .getTpnPool()); + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(), + "after ODU4 creation, its termination point should contain a TpnPool list"); assertEquals( - "Tpn pool list should be full, with 80 trib ports", 80, - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().values().stream().findFirst() - .get() - .getTpnPool() - .size()); + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool() + .size(), + "Tpn pool list should be full, with 80 trib ports"); } @Test - public void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() { + void createOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() { List otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(100000)); List otu4LinksWithBadBWParam = new ArrayList<>(); for (Link link : otu4Links) { otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build()); } - TopologyShard topoShard = - OpenRoadmOtnTopology.createOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(false), + TopologyShard topoShard = OpenRoadmOtnTopology.createOtnLinks( + otu4LinksWithBadBWParam, + NetworkmodelTestUtil.createTpList(false), OtnLinkType.OTU4); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("list of nodes should be null", topoShard.getNodes()); - assertNull("list of links should be null", topoShard.getLinks()); - assertNull("list of tps should be null", topoShard.getTps()); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); + assertNull(topoShard.getLinks(), "list of links should be null"); + assertNull(topoShard.getTps(), "list of tps should be null"); otu4LinksWithBadBWParam.clear(); - topoShard = - OpenRoadmOtnTopology.createOtnLinks( - NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(99000)), - NetworkmodelTestUtil.createTpList(false), OtnLinkType.OTU4); - assertNull("list of nodes should be null", topoShard.getNodes()); - assertNull("list of links should be null", topoShard.getLinks()); - assertNull("list of tps should be null", topoShard.getTps()); + topoShard = OpenRoadmOtnTopology.createOtnLinks( + NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(99000)), + NetworkmodelTestUtil.createTpList(false), + OtnLinkType.OTU4); + assertNull(topoShard.getNodes(), "list of nodes should be null"); + assertNull(topoShard.getLinks(), "list of links should be null"); + assertNull(topoShard.getTps(), "list of tps should be null"); } @Test - public void deleteOtnLinksForODU4NormalTest() { - TopologyShard topoShard = - OpenRoadmOtnTopology.deleteOtnLinks( + void deleteOtnLinksForODU4NormalTest() { + TopologyShard topoShard = OpenRoadmOtnTopology.deleteOtnLinks( NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(0)), - NetworkmodelTestUtil.createTpList(true), OtnLinkType.OTU4); - assertNotNull("TopologyShard should never be null", topoShard); - assertEquals("list of links should contain 2 links", 2, topoShard.getLinks().size()); + NetworkmodelTestUtil.createTpList(true), + OtnLinkType.OTU4); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertEquals(2, topoShard.getLinks().size(), "list of links should contain 2 links"); assertEquals( - "after ODU4 deletion, available BW of supported OTU4 should be 100 000", Uint32.valueOf(100000), - topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth()); + topoShard.getLinks().get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after ODU4 deletion, available BW of supported OTU4 should be 100 000"); assertEquals( - "after ODU4 deletion, used BW of supported OTU4 should be 0", Uint32.valueOf(0), - topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth()); + topoShard.getLinks().get(0).augmentation(Link1.class).getUsedBandwidth(), + "after ODU4 deletion, used BW of supported OTU4 should be 0"); - assertEquals("list of TPs should contain 2 updated TPs", 2, topoShard.getTps().size()); + assertEquals(2, topoShard.getTps().size(), "list of TPs should contain 2 updated TPs"); assertNull( - "after ODU4 deletion, its termination points should not contain any TsPool list", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool()); + .getXpdrTpPortConnectionAttributes().getTsPool(), + "after ODU4 deletion, its termination points should not contain any TsPool list"); assertNull( - "after ODU4 deletion, its termination points should not contain any TpnPool list", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool()); + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool(), + "after ODU4 deletion, its termination points should not contain any TpnPool list"); } @Test - public void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() { + void deleteOtnLinksForODU4WhenOTU4HaveBadBWParamsTest() { List otu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.OTU4, Uint32.valueOf(0)); List otu4LinksWithBadBWParam = new ArrayList<>(); for (Link link : otu4Links) { otu4LinksWithBadBWParam.add(new LinkBuilder(link).removeAugmentation(Link1.class).build()); } - TopologyShard topoShard = - OpenRoadmOtnTopology.deleteOtnLinks(otu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true), + TopologyShard topoShard = OpenRoadmOtnTopology.deleteOtnLinks( + otu4LinksWithBadBWParam, + NetworkmodelTestUtil.createTpList(true), OtnLinkType.OTU4); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("list of nodes should be null", topoShard.getNodes()); - assertNull("list of links should be null", topoShard.getLinks()); - assertNull("list of tps should be null", topoShard.getTps()); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); + assertNull(topoShard.getLinks(), "list of links should be null"); + assertNull(topoShard.getTps(), "list of tps should be null"); } @Test - public void updateOtnLinksFor10GTest() { + void updateOtnLinksFor10GTest() { // tests update for 10G creation - TopologyShard topoShard = - OpenRoadmOtnTopology.updateOtnLinks( + TopologyShard topoShard = OpenRoadmOtnTopology.updateOtnLinks( NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000)), NetworkmodelTestUtil.createTpList(true), Uint32.valueOf(10), (short)1, (short)1, (short)8, false); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("list of nodes should be null", topoShard.getNodes()); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); List sortedLinks = topoShard.getLinks().stream() .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue())) .collect(Collectors.toList()); - assertEquals("list of links should contain 2 links", 2, sortedLinks.size()); + assertEquals(2, sortedLinks.size(), "list of links should contain 2 links"); assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-")); assertEquals( - "after 10G creation, available BW of supported ODU4 should be 90000", Uint32.valueOf(90000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after 10G creation, available BW of supported ODU4 should be 90000"); assertEquals( - "after 10G creation, used BW of supported ODU4 should be 10000", Uint32.valueOf(10000), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "after 10G creation, used BW of supported ODU4 should be 10000"); assertEquals( - "after 10G creation, 8 (over 80) trib slot should be occupied", 72, - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool() - .size()); + .getXpdrTpPortConnectionAttributes().getTsPool().size(), + "after 10G creation, 8 (over 80) trib slot should be occupied"); assertThat( "trib slot 1-8 should no longer be present in Trib slot list", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool(), + .getXpdrTpPortConnectionAttributes().getTsPool(), not(hasItems(Uint16.valueOf(1), Uint16.valueOf(8)))); assertThat( "trib slot 9 should always be present in trib slot list", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool(), + .getXpdrTpPortConnectionAttributes().getTsPool(), hasItem(Uint16.valueOf(9))); assertEquals( - "after 10G creation, 1 (over 80) trib port should be occupied", 79, - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().values().stream().findFirst() - .get() - .getTpnPool() - .size()); + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool() + .size(), + "after 10G creation, 1 (over 80) trib port should be occupied"); assertThat( "trib port 1 should no longer be present", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().values().stream().findFirst() - .get() - .getTpnPool(), + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(), not(hasItem(Uint16.valueOf(1)))); // tests update for 10G deletion sortedLinks.clear(); topoShard = OpenRoadmOtnTopology.updateOtnLinks(topoShard.getLinks(), topoShard.getTps(), Uint32.valueOf(10), - (short)1, (short)1, (short)8, true); + (short)1, (short)1, (short)8, true); sortedLinks = topoShard.getLinks().stream() .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue())) .collect(Collectors.toList()); - assertEquals("list of links should contain 2 links", 2, sortedLinks.size()); + assertEquals(2, sortedLinks.size(), "list of links should contain 2 links"); assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-")); assertEquals( - "after 10G deletion, available BW of supported ODU4 should be 100 000", Uint32.valueOf(100000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after 10G deletion, available BW of supported ODU4 should be 100 000"); assertEquals( - "after 10G deletion, used BW of supported ODU4 should be 0", Uint32.valueOf(0), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "after 10G deletion, used BW of supported ODU4 should be 0"); assertEquals( - "after 10G deletion, trib slot list should be full", 80, - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool() - .size()); + .getXpdrTpPortConnectionAttributes().getTsPool().size(), + "after 10G deletion, trib slot list should be full"); assertThat( "after 10G deletion, trib slot list should contain items 1-8", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool(), + .getXpdrTpPortConnectionAttributes().getTsPool(), hasItems(Uint16.valueOf(1), Uint16.valueOf(8), Uint16.valueOf(9))); assertEquals( - "after 10G deletion, trib port list should be full", 80, - topoShard.getTps().get(0) - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 - .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().values().stream().findFirst() - .get() - .getTpnPool() - .size()); + topoShard.getTps().get(0).augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 + .TerminationPoint1.class) + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get() + .getTpnPool().size(), + "after 10G deletion, trib port list should be full"); assertThat( "after 10G deletion, trib port list should contain items 1", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().values().stream().findFirst() - .get() - .getTpnPool(), + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(), hasItem(Uint16.valueOf(1))); } @Test - public void updateOtnLinksFor1GCreationTest() { + void updateOtnLinksFor1GCreationTest() { // tests update for 1G creation - TopologyShard topoShard = - OpenRoadmOtnTopology.updateOtnLinks( + TopologyShard topoShard = OpenRoadmOtnTopology.updateOtnLinks( NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000)), NetworkmodelTestUtil.createTpList(true), Uint32.valueOf(1), (short)1, (short)1, (short)1, false); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("list of nodes should be null", topoShard.getNodes()); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); List sortedLinks = topoShard.getLinks().stream() .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue())) .collect(Collectors.toList()); - assertEquals("list of links should contain 2 links", 2, sortedLinks.size()); + assertEquals(2, sortedLinks.size(), "list of links should contain 2 links"); assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-")); assertEquals( - "after 1G creation, available BW of supported ODU4 should be 99000", Uint32.valueOf(99000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after 1G creation, available BW of supported ODU4 should be 99000"); assertEquals( - "after 1G creation, used BW of supported ODU4 should be 1000", Uint32.valueOf(1000), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "after 1G creation, used BW of supported ODU4 should be 1000"); assertEquals( - "after 1G creation, 1 (over 80) trib slot should be occupied", 79, - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool() - .size()); + .getXpdrTpPortConnectionAttributes().getTsPool().size(), + "after 1G creation, 1 (over 80) trib slot should be occupied"); assertThat( "trib slot 1 should no longer be present in Trib slot list", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool(), + .getXpdrTpPortConnectionAttributes().getTsPool(), not(hasItem(Uint16.valueOf(1)))); assertThat( "trib slot 2 should always be present in Trib slot list", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) .getXpdrTpPortConnectionAttributes().getTsPool(), hasItem(Uint16.valueOf(2))); assertEquals( - "after 1G creation, 1 (over 80) trib port should be occupied", 79, - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().values().stream().findFirst() - .get() - .getTpnPool() - .size()); + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool() + .size(), + "after 1G creation, 1 (over 80) trib port should be occupied"); assertThat( "trib port 1 should no longer be present in Trib port list", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().values().stream().findFirst() - .get() - .getTpnPool(), + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(), not(hasItem(Uint16.valueOf(1)))); // tests update for 1G deletion sortedLinks.clear(); - topoShard = - OpenRoadmOtnTopology.updateOtnLinks( + topoShard = OpenRoadmOtnTopology.updateOtnLinks( topoShard.getLinks(), topoShard.getTps(), Uint32.valueOf(1), (short)1, (short)1, (short)1, true); sortedLinks = topoShard.getLinks().stream() .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue())) .collect(Collectors.toList()); - assertEquals("list of links should contain 2 links", 2, sortedLinks.size()); + assertEquals(2, sortedLinks.size(), "list of links should contain 2 links"); assertTrue(sortedLinks.get(0).getLinkId().getValue().startsWith("ODTU4-")); assertEquals( - "after 1G deletion, available BW of supported ODU4 should be 100 000", Uint32.valueOf(100000), - sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getAvailableBandwidth(), + "after 1G deletion, available BW of supported ODU4 should be 100 000"); assertEquals( - "after 1G deletion, used BW of supported ODU4 should be 0", Uint32.valueOf(0), - sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth()); + sortedLinks.get(0).augmentation(Link1.class).getUsedBandwidth(), + "after 1G deletion, used BW of supported ODU4 should be 0"); assertEquals( - "after 1G deletion, trib slot list should be full", 80, - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool() - .size()); + .getXpdrTpPortConnectionAttributes().getTsPool().size(), + "after 1G deletion, trib slot list should be full"); assertThat( "after 1G deletion, trib slot list should contain items 1 and 2", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 - .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getTsPool(), + .TerminationPoint1.class) + .getXpdrTpPortConnectionAttributes().getTsPool(), hasItems(Uint16.valueOf(1), Uint16.valueOf(2))); assertEquals( - "after 1G deletion, trib port list should be full", 80, - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().values().stream().findFirst() - .get() - .getTpnPool() - .size()); + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool() + .size(), + "after 1G deletion, trib port list should be full"); assertThat( "after 1G deletion, trib port list should contain items 1", - topoShard.getTps().get(0) - .augmentation( + topoShard.getTps().get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getOdtuTpnPool().values().stream().findFirst() - .get() - .getTpnPool(), + .getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values().stream().findFirst().get().getTpnPool(), hasItem(Uint16.valueOf(1))); } @Test - public void updateOtnLinksForODU4WhenBWParamsNotPresentTest() { + void updateOtnLinksForODU4WhenBWParamsNotPresentTest() { List odu4Links = NetworkmodelTestUtil.createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(100000)); List odu4LinksWithBadBWParam = new ArrayList<>(); for (Link link : odu4Links) { @@ -766,30 +658,30 @@ public class OpenRoadmOtnTopologyTest { odu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true), Uint32.valueOf(1), (short)1, (short)1, (short)10, false); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("list of nodes should be null", topoShard.getNodes()); - assertNull("list of links should be null", topoShard.getLinks()); - assertNull("list of tps should be null", topoShard.getTps()); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); + assertNull(topoShard.getLinks(), "list of links should be null"); + assertNull(topoShard.getTps(), "list of tps should be null"); } @Test - public void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() { - List odu4LinksWithBadBWParam = NetworkmodelTestUtil - .createSuppOTNLinks(OtnLinkType.ODTU4, Uint32.valueOf(8000)); - TopologyShard topoShard = - OpenRoadmOtnTopology.updateOtnLinks( + void updateOtnLinksForODU4WhenAvailBWNotSufficientTest() { + List odu4LinksWithBadBWParam = NetworkmodelTestUtil.createSuppOTNLinks( + OtnLinkType.ODTU4, + Uint32.valueOf(8000)); + TopologyShard topoShard = OpenRoadmOtnTopology.updateOtnLinks( odu4LinksWithBadBWParam, NetworkmodelTestUtil.createTpList(true), Uint32.valueOf(10), (short)1, (short)1, (short)10, false); - assertNotNull("TopologyShard should never be null", topoShard); - assertNull("list of nodes should be null", topoShard.getNodes()); - assertNull("list of links should be null", topoShard.getLinks()); - assertNull("list of tps should be null", topoShard.getTps()); + assertNotNull(topoShard, "TopologyShard should never be null"); + assertNull(topoShard.getNodes(), "list of nodes should be null"); + assertNull(topoShard.getLinks(), "list of links should be null"); + assertNull(topoShard.getTps(), "list of tps should be null"); } private void checkSpdrNode(Node node) { - Uint16 xpdrNb = node - .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210.Node1.class) + Uint16 xpdrNb = node.augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210.Node1.class) .getXpdrAttributes().getXpdrNumber(); assertEquals("SPDR-SA1-XPDR" + xpdrNb, node.getNodeId().getValue()); if (xpdrNb.equals(Uint16.valueOf(1))) { @@ -801,7 +693,7 @@ public class OpenRoadmOtnTopologyTest { List supportingNodes = node.nonnullSupportingNode().values().stream() .sorted((sn1, sn2) -> sn1.getNetworkRef().getValue().compareTo(sn2.getNetworkRef().getValue())) .collect(Collectors.toList()); - assertEquals("Should contain 3 supporting nodes", 3, supportingNodes.size()); + assertEquals(3, supportingNodes.size(), "Should contain 3 supporting nodes"); assertEquals("clli-network", supportingNodes.get(0).getNetworkRef().getValue()); assertEquals("NodeSA", supportingNodes.get(0).getNodeRef().getValue()); assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue()); @@ -824,36 +716,31 @@ public class OpenRoadmOtnTopologyTest { private void checkSpdrSwitchingPools(Uint16 xpdrNb, SwitchingPools sp) { List oduSwitchingPools = new ArrayList<>(sp.nonnullOduSwitchingPools().values()); assertEquals( - "switching-pools augmentation should contain a single odu-switching-pools", 1, - oduSwitchingPools.size()); + oduSwitchingPools.size(), + "switching-pools augmentation should contain a single odu-switching-pools"); assertEquals( - "switching-pool-number should be 1", Uint16.valueOf(1), - oduSwitchingPools.get(0).getSwitchingPoolNumber()); + oduSwitchingPools.get(0).getSwitchingPoolNumber(), + "switching-pool-number should be 1"); assertEquals( - "switching-pool-type should be non-blocking", "non-blocking", - oduSwitchingPools.get(0).getSwitchingPoolType().getName()); + oduSwitchingPools.get(0).getSwitchingPoolType().getName(), + "switching-pool-type should be non-blocking"); List nonBlockingList = new ArrayList<>(oduSwitchingPools.get(0).nonnullNonBlockingList().values()); if (xpdrNb.equals(Uint16.valueOf(1))) { - assertEquals( - "Mux should contain 4 non blocking list", - 4, - nonBlockingList.size()); - assertEquals( - Uint16.valueOf(1), - nonBlockingList.get(0).getNblNumber()); + assertEquals(4, nonBlockingList.size(), "Mux should contain 4 non blocking list"); + assertEquals(Uint16.valueOf(1), nonBlockingList.get(0).getNblNumber()); List nblList = oduSwitchingPools.get(0).nonnullNonBlockingList().values().stream() .sorted((nbl1, nbl2) -> nbl1.getNblNumber().compareTo(nbl2.getNblNumber())) .collect(Collectors.toList()); for (NonBlockingList nbl : nblList) { assertEquals( - "for a 10G mux, interconnect BW should be 10G", Uint32.valueOf(10), - nbl.getAvailableInterconnectBandwidth()); + nbl.getAvailableInterconnectBandwidth(), + "for a 10G mux, interconnect BW should be 10G"); assertEquals(Uint32.valueOf(1000000000), nbl.getInterconnectBandwidthUnit()); assertThat( "for a 10G mux, non blocking list should contain 2 entries (client + network ports)", @@ -862,17 +749,11 @@ public class OpenRoadmOtnTopologyTest { String nb = nbl.getNblNumber().toString(); assertThat( nbl.getTpList(), - containsInAnyOrder(new TpId("XPDR1-NETWORK1"), - new TpId("XPDR1-CLIENT" + nb))); + containsInAnyOrder(new TpId("XPDR1-NETWORK1"), new TpId("XPDR1-CLIENT" + nb))); } } else if (xpdrNb.equals(Uint16.valueOf(2))) { - assertEquals( - "Switch should contain a single non blocking list", - 1, - nonBlockingList.size()); - assertEquals( - Uint16.valueOf(1), - nonBlockingList.get(0).getNblNumber()); + assertEquals(1, nonBlockingList.size(), "Switch should contain a single non blocking list"); + assertEquals(Uint16.valueOf(1), nonBlockingList.get(0).getNblNumber()); assertThat( "for a 100G Switch, non blocking list should contain 8 entries (4 clients + 4 network ports)", nonBlockingList.get(0).getTpList(), @@ -889,146 +770,128 @@ public class OpenRoadmOtnTopologyTest { private void checkSpdrTpList(Uint16 xpdrNb, List tpList) { LOG.info("tpList = {}", tpList); assertEquals( - "only IfOCHOTU4ODU4 interface capabitily expected", IfOCHOTU4ODU4.VALUE, - tpList.get(4) - .augmentation( + tpList.get(4).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability().values().stream().findFirst() - .get() - .getIfCapType()); + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst().get() + .getIfCapType(), + "only IfOCHOTU4ODU4 interface capabitily expected"); assertEquals( - "the rate should be ODU4", ODU4.VALUE, - tpList.get(4) - .augmentation( + tpList.get(4).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getRate()); + .getXpdrTpPortConnectionAttributes().getRate(), + "the rate should be ODU4"); assertEquals( "openroadm-topology", - tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst() - .get().getNetworkRef().getValue()); + tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().get().getNetworkRef() + .getValue()); assertEquals( "SPDR-SA1-XPDR" + xpdrNb, - tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst() - .get().getNodeRef().getValue()); + tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().get().getNodeRef().getValue()); assertEquals( "XPDR" + xpdrNb + "-NETWORK1", - tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst() - .get().getTpRef().getValue()); + tpList.get(4).getSupportingTerminationPoint().values().stream().findFirst().get().getTpRef().getValue()); if (xpdrNb.equals(Uint16.valueOf(1))) { - assertEquals("should contain 5 TPs", 5, tpList.size()); + assertEquals(5, tpList.size(), "should contain 5 TPs"); assertEquals("XPDR1-CLIENT1", tpList.get(0).getTpId().getValue()); assertEquals("XPDR1-CLIENT2", tpList.get(1).getTpId().getValue()); assertEquals("XPDR1-NETWORK1", tpList.get(4).getTpId().getValue()); assertEquals( - "supported interface capability of tp-id XPDR1-CLIENT2 should contain 2 if-cap-type", 2, - tpList.get(1) - .augmentation( + tpList.get(1).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability().values().size()); + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().size(), + "supported interface capability of tp-id XPDR1-CLIENT2 should contain 2 if-cap-type"); assertEquals( - "supported interface capability of tp-id XPDR1-CLIENT3 should contain 3 if-cap-type", 3, - tpList.get(2) - .augmentation( + tpList.get(2).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability().values().size()); - List sicListClient1 = tpList.get(0) - .augmentation( + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().size(), + "supported interface capability of tp-id XPDR1-CLIENT3 should contain 3 if-cap-type"); + List sicListClient1 = tpList.get(0).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 - .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList()); + .TerminationPoint1.class) + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream() + .collect(Collectors.toList()); for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient1) { assertThat("tp should have 2 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2", String.valueOf(supportedInterfaceCapability.getIfCapType()), either(containsString(String.valueOf(If10GEODU2e.VALUE))) - .or(containsString(String.valueOf(If10GEODU2.VALUE)))); + .or(containsString(String.valueOf(If10GEODU2.VALUE)))); } - List sicListClient3 = tpList.get(3) - .augmentation( + List sicListClient3 = tpList.get(3).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 - .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList()); + .TerminationPoint1.class) + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream() + .collect(Collectors.toList()); for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) { assertThat("tp should have 3 if-cap-type: if-10GE-ODU2e, if-10GE-ODU2, if-10GE", String.valueOf(supportedInterfaceCapability.getIfCapType()), either(containsString(String.valueOf(If10GEODU2e.VALUE))) - .or(containsString(String.valueOf(If10GEODU2.VALUE))) - .or(containsString(String.valueOf(If10GE.VALUE)))); + .or(containsString(String.valueOf(If10GEODU2.VALUE))) + .or(containsString(String.valueOf(If10GE.VALUE)))); } assertThat("the rate should be ODU2 or ODU2e", - String.valueOf(tpList.get(2) - .augmentation( + String.valueOf(tpList.get(2).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getXpdrTpPortConnectionAttributes() - .getRate()), + .getXpdrTpPortConnectionAttributes().getRate()), either(containsString(String.valueOf(ODU2e.VALUE))) - .or(containsString(String.valueOf(ODU2.VALUE)))); + .or(containsString(String.valueOf(ODU2.VALUE)))); assertEquals( - "TP should be of type client", OpenroadmTpType.XPONDERCLIENT, - tpList.get(2).augmentation(TerminationPoint1.class).getTpType()); + tpList.get(2).augmentation(TerminationPoint1.class).getTpType(), + "TP should be of type client"); assertEquals( - "TP should be of type network", OpenroadmTpType.XPONDERNETWORK, - tpList.get(4).augmentation(TerminationPoint1.class).getTpType()); + tpList.get(4).augmentation(TerminationPoint1.class).getTpType(), + "TP should be of type network"); } else if (xpdrNb.equals(Uint16.valueOf(2))) { - assertEquals("should contain 8 TPs", 8, tpList.size()); + assertEquals(8, tpList.size(), "should contain 8 TPs"); assertEquals("XPDR2-CLIENT1", tpList.get(0).getTpId().getValue()); assertEquals("XPDR2-CLIENT2", tpList.get(1).getTpId().getValue()); assertEquals("XPDR2-NETWORK1", tpList.get(4).getTpId().getValue()); assertEquals("XPDR2-NETWORK2", tpList.get(5).getTpId().getValue()); assertEquals( - "only IfOCHOTU4ODU4 interface capabitily expected", IfOCHOTU4ODU4.VALUE, - tpList.get(5) - .augmentation( + tpList.get(5).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 - .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability().values().stream().findFirst() - .get() - .getIfCapType()); + .TerminationPoint1.class) + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream().findFirst().get() + .getIfCapType(), + "only IfOCHOTU4ODU4 interface capabitily expected"); assertEquals( - "supported interface capability of tp should contain 2 IfCapType", 2, - tpList.get(2) - .augmentation( + tpList.get(2).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability().values().size()); - List sicListClient3 = tpList.get(2) - .augmentation( + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().size(), + "supported interface capability of tp should contain 2 IfCapType"); + List sicListClient3 = tpList.get(2).augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev211210 - .TerminationPoint1.class) - .getTpSupportedInterfaces() - .getSupportedInterfaceCapability().values().stream().collect(Collectors.toList()); + .TerminationPoint1.class) + .getTpSupportedInterfaces().getSupportedInterfaceCapability().values().stream() + .collect(Collectors.toList()); for (SupportedInterfaceCapability supportedInterfaceCapability : sicListClient3) { - assertThat("tp should have 2 if-cap-type: if-100GE-ODU4, if-100GE", + assertThat( + "tp should have 2 if-cap-type: if-100GE-ODU4, if-100GE", String.valueOf(supportedInterfaceCapability.getIfCapType()), either(containsString(String.valueOf(If100GEODU4.VALUE))) - .or(containsString(String.valueOf(If100GE.VALUE)))); + .or(containsString(String.valueOf(If100GE.VALUE)))); } assertEquals( - "TP should be of type client", OpenroadmTpType.XPONDERCLIENT, - tpList.get(2).augmentation(TerminationPoint1.class).getTpType()); + OpenroadmTpType.XPONDERCLIENT, + tpList.get(2).augmentation(TerminationPoint1.class).getTpType(), + "TP should be of type client"); assertEquals( - "TP should be of type network", OpenroadmTpType.XPONDERNETWORK, - tpList.get(6).augmentation(TerminationPoint1.class).getTpType()); + OpenroadmTpType.XPONDERNETWORK, + tpList.get(6).augmentation(TerminationPoint1.class).getTpType(), + "TP should be of type network"); } } } diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopologyTest.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopologyTest.java index 4acee5cbd..10b1fd34b 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopologyTest.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmTopologyTest.java @@ -7,11 +7,11 @@ */ package org.opendaylight.transportpce.networkmodel.util; -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.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -28,12 +28,11 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; -import org.junit.Ignore; -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.invocation.InvocationOnMock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.stubbing.Answer; import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; @@ -72,18 +71,18 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.Uint16; -@RunWith(MockitoJUnitRunner.StrictStubs.class) +@ExtendWith(MockitoExtension.class) public class OpenRoadmTopologyTest { @Mock private NetworkTransactionService networkTransactionService; @Test - public void createTopologyShardForDegreeTest() { + void createTopologyShardForDegreeTest() { Nodes mappingNode = NetworkmodelTestUtil.createMappingForRdm("ROADMA01", "nodeA", 2, List.of()); TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(mappingNode); assertNotNull(topologyShard); - assertEquals("Should contain 2 Degree nodes only", 2, topologyShard.getNodes().size()); - assertEquals("Should contain 2 links", 2, topologyShard.getLinks().size()); + assertEquals(2, topologyShard.getNodes().size(), "Should contain 2 Degree nodes only"); + assertEquals(2, topologyShard.getLinks().size(), "Should contain 2 links"); List nodes = topologyShard.getNodes().stream() .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue())) .collect(Collectors.toList()); @@ -95,7 +94,7 @@ public class OpenRoadmTopologyTest { List links = topologyShard.getLinks().stream() .sorted((l1, l2) -> l1.getLinkId().getValue().compareTo(l2.getLinkId().getValue())) .collect(Collectors.toList()); - assertEquals("Should contain 2 express links", 2, links.size()); + assertEquals(2, links.size(), "Should contain 2 express links"); assertEquals("ROADMA01-DEG1-DEG1-CTP-TXRXtoROADMA01-DEG2-DEG2-CTP-TXRX", links.get(0).getLinkId().getValue()); assertEquals("ROADMA01-DEG1", links.get(0).getSource().getSourceNode().getValue()); assertEquals("DEG1-CTP-TXRX", links.get(0).getSource().getSourceTp().getValue()); @@ -109,29 +108,29 @@ public class OpenRoadmTopologyTest { } @Test - public void createTopologyShardForSrgTest() { - Nodes mappingNode = NetworkmodelTestUtil.createMappingForRdm("ROADMA01", "nodeA", 0, - List.of(Integer.valueOf(1))); + void createTopologyShardForSrgTest() { + Nodes mappingNode = NetworkmodelTestUtil.createMappingForRdm( + "ROADMA01", "nodeA", 0, List.of(Integer.valueOf(1))); TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(mappingNode); assertNotNull(topologyShard); List nodes = topologyShard.getNodes(); - assertEquals("Should contain 1 SRG node only", 1, nodes.size()); - assertEquals("Should contain 0 link", 0, topologyShard.getLinks().size()); + assertEquals(1, nodes.size(), "Should contain 1 SRG node only"); + assertEquals(0, topologyShard.getLinks().size(), "Should contain 0 link"); checkSrgNode("1", nodes.get(0)); } @Test - public void createTopologyShardForMultipleSrgTest() { + void createTopologyShardForMultipleSrgTest() { List srgNbs = List.of(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(10), - Integer.valueOf(11)); + Integer.valueOf(11)); Nodes mappingNode = NetworkmodelTestUtil.createMappingForRdm("ROADMA01", "nodeA", 0, srgNbs); TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(mappingNode); assertNotNull(topologyShard); List nodes = topologyShard.getNodes().stream() .sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue())) .collect(Collectors.toList()); - assertEquals("Should contain 4 SRG nodes", 4, nodes.size()); - assertEquals("Should contain 0 link", 0, topologyShard.getLinks().size()); + assertEquals(4, nodes.size(), "Should contain 4 SRG nodes"); + assertEquals(0, topologyShard.getLinks().size(), "Should contain 0 link"); checkSrgNode("1", nodes.get(0)); checkSrgNode("10", nodes.get(1)); checkSrgNode("11", nodes.get(2)); @@ -139,76 +138,77 @@ public class OpenRoadmTopologyTest { } @Test - public void createTopologyShardForCompleteRdmNodeTest() { + void createTopologyShardForCompleteRdmNodeTest() { Nodes mappingNode = NetworkmodelTestUtil.createMappingForRdm("ROADMA01", "nodeA", 2, List.of(Integer.valueOf(1), Integer.valueOf(2))); TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(mappingNode); assertNotNull(topologyShard); - assertEquals("Should contain 2 Deg and 2 SRG nodes", 4, topologyShard.getNodes().size()); + assertEquals(4, topologyShard.getNodes().size(), "Should contain 2 Deg and 2 SRG nodes"); List addLinks = topologyShard.getLinks().stream() .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.ADDLINK)) .collect(Collectors.toList()); - assertEquals("Should contain 4 add links", 4, addLinks.size()); + assertEquals(4, addLinks.size(), "Should contain 4 add links"); List dropLinks = topologyShard.getLinks().stream() .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.DROPLINK)) .collect(Collectors.toList()); - assertEquals("Should contain 4 drop links", 4, dropLinks.size()); + assertEquals(4, dropLinks.size(), "Should contain 4 drop links"); List expressLinks = topologyShard.getLinks().stream() .filter(lk -> lk.augmentation(Link1.class).getLinkType().equals(OpenroadmLinkType.EXPRESSLINK)) .collect(Collectors.toList()); - assertEquals("Should contain 2 express links", 2, expressLinks.size()); + assertEquals(2, expressLinks.size(), "Should contain 2 express links"); } @Test - public void createTopologyShardForTpdrNodeTest() { + void createTopologyShardForTpdrNodeTest() { Nodes mappingNode = NetworkmodelTestUtil.createMappingForXpdr("XPDRA01", "nodeA", 2, 2, null); TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(mappingNode); assertNotNull(topologyShard); - assertEquals("Should contain a single node", 1, topologyShard.getNodes().size()); - assertEquals("Should contain 0 link", 0, topologyShard.getLinks().size()); + assertEquals(1, topologyShard.getNodes().size(), "Should contain a single node"); + assertEquals(0, topologyShard.getLinks().size(), "Should contain 0 link"); checkTpdrNode(topologyShard.getNodes().get(0)); } @Test - public void createTopologyShardForTpdrNode2Test() { + void createTopologyShardForTpdrNode2Test() { Nodes mappingNode = NetworkmodelTestUtil.createMappingForXpdr("XPDRA01", "nodeA", 2, 2, XpdrNodeTypes.Tpdr); TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(mappingNode); assertNotNull(topologyShard); - assertEquals("Should contain a single node", 1, topologyShard.getNodes().size()); - assertEquals("Should contain 0 link", 0, topologyShard.getLinks().size()); + assertEquals(1, topologyShard.getNodes().size(), "Should contain a single node"); + assertEquals(0, topologyShard.getLinks().size(), "Should contain 0 link"); checkTpdrNode(topologyShard.getNodes().get(0)); } @Test - public void createTopologyShardForMpdrNodeTest() { + void createTopologyShardForMpdrNodeTest() { Nodes mappingNode = NetworkmodelTestUtil.createMappingForXpdr("XPDRA01", "nodeA", 2, 2, XpdrNodeTypes.Mpdr); TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(mappingNode); assertNotNull(topologyShard); - assertEquals("Should contain a single node", 1, topologyShard.getNodes().size()); - assertEquals("Should contain 0 link", 0, topologyShard.getLinks().size()); + assertEquals(1, topologyShard.getNodes().size(), "Should contain a single node"); + assertEquals(0, topologyShard.getLinks().size(), "Should contain 0 link"); checkOtnXpdrNode(topologyShard.getNodes().get(0)); } @Test - public void createTopologyShardForSwitchNodeTest() { + void createTopologyShardForSwitchNodeTest() { Nodes mappingNode = NetworkmodelTestUtil.createMappingForXpdr("XPDRA01", "nodeA", 2, 2, XpdrNodeTypes.Switch); TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(mappingNode); assertNotNull(topologyShard); - assertEquals("Should contain a single node", 1, topologyShard.getNodes().size()); - assertEquals("Should contain 0 link", 0, topologyShard.getLinks().size()); + assertEquals(1, topologyShard.getNodes().size(), "Should contain a single node"); + assertEquals(0, topologyShard.getLinks().size(), "Should contain 0 link"); checkOtnXpdrNode(topologyShard.getNodes().get(0)); } - @Ignore @Test - public void createTopologyShardForRdmWithoutClliTest() { + void createTopologyShardForRdmWithoutClliTest() { Nodes mappingNode = NetworkmodelTestUtil.createMappingForRdm("ROADMA01", null, 2, List.of()); - TopologyShard topologyShard = OpenRoadmTopology.createTopologyShard(mappingNode); - assertNull("clli must not be null", topologyShard); + Exception exception = assertThrows(NullPointerException.class, () -> { + OpenRoadmTopology.createTopologyShard(mappingNode); + }); + assertTrue("Supplied value may not be null".contains(exception.getMessage())); } @Test - public void deleteLinkOkTest() throws InterruptedException, ExecutionException { + void deleteLinkOkTest() throws InterruptedException, ExecutionException { String srcNode = "ROADM-A1-DEG1"; String dstNode = "ROADM-A1-SRG1"; String srcTp = "DEG1-CTP-TXRX"; @@ -223,9 +223,11 @@ public class OpenRoadmTopologyTest { .build()) .addAugmentation(link1) .build(); - InstanceIdentifier linkIID = InstanceIdentifier.builder(Networks.class).child(Network.class, - new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).augmentation(Network1.class) - .child(Link.class, new LinkKey(linkId)).build(); + InstanceIdentifier linkIID = InstanceIdentifier.builder(Networks.class) + .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) + .augmentation(Network1.class) + .child(Link.class, new LinkKey(linkId)) + .build(); when(networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, linkIID)) .thenReturn(new LinkFuture(link)); @@ -241,29 +243,31 @@ public class OpenRoadmTopologyTest { boolean result = OpenRoadmTopology.deleteLink("ROADM-A1-DEG1", "ROADM-A1-SRG1", "DEG1-CTP-TXRX", "SRG1-CP-TXRX", networkTransactionService); - assertTrue("link deletion should be ok", result); + assertTrue(result, "link deletion should be ok"); } @Test - public void deleteLinkNotOkTest() throws InterruptedException, ExecutionException { + void deleteLinkNotOkTest() throws InterruptedException, ExecutionException { String srcNode = "ROADM-A1-DEG1"; String dstNode = "ROADM-A1-SRG1"; String srcTp = "DEG1-CTP-TXRX"; String destTp = "SRG1-CP-TXRX"; LinkId linkId = LinkIdUtil.buildLinkId(srcNode, srcTp, dstNode, destTp); - InstanceIdentifier linkIID = InstanceIdentifier.builder(Networks.class).child(Network.class, - new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).augmentation(Network1.class) - .child(Link.class, new LinkKey(linkId)).build(); + InstanceIdentifier linkIID = InstanceIdentifier.builder(Networks.class) + .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) + .augmentation(Network1.class) + .child(Link.class, new LinkKey(linkId)) + .build(); when(networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, linkIID)).thenReturn(new LinkFuture()); - boolean result = OpenRoadmTopology.deleteLink("ROADM-A1-DEG1", "ROADM-A1-SRG1", "DEG1-CTP-TXRX", "SRG1-CP-TXRX", - networkTransactionService); - assertFalse("link deletion should not be ok", result); + boolean result = OpenRoadmTopology.deleteLink( + "ROADM-A1-DEG1", "ROADM-A1-SRG1", "DEG1-CTP-TXRX", "SRG1-CP-TXRX", networkTransactionService); + assertFalse(result, "link deletion should not be ok"); } @Test - public void deleteLinkExceptionTest() throws InterruptedException, ExecutionException { + void deleteLinkExceptionTest() throws InterruptedException, ExecutionException { String srcNode = "ROADM-A1-DEG1"; String dstNode = "ROADM-A1-SRG1"; String srcTp = "DEG1-CTP-TXRX"; @@ -271,14 +275,16 @@ public class OpenRoadmTopologyTest { LinkId linkId = LinkIdUtil.buildLinkId(srcNode, srcTp, dstNode, destTp); InstanceIdentifier linkIID = InstanceIdentifier.builder(Networks.class) - .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) - .augmentation(Network1.class).child(Link.class, new LinkKey(linkId)).build(); + .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) + .augmentation(Network1.class) + .child(Link.class, new LinkKey(linkId)) + .build(); when(networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, linkIID)) - .thenReturn(new InterruptedLinkFuture()); - boolean result = OpenRoadmTopology.deleteLink("ROADM-A1-DEG1", "ROADM-A1-SRG1", "DEG1-CTP-TXRX", "SRG1-CP-TXRX", - networkTransactionService); + .thenReturn(new InterruptedLinkFuture()); + boolean result = OpenRoadmTopology.deleteLink( + "ROADM-A1-DEG1", "ROADM-A1-SRG1", "DEG1-CTP-TXRX", "SRG1-CP-TXRX", networkTransactionService); verify(networkTransactionService, never()).merge(any(), any(), any()); - assertFalse("Result should be false du to InterruptedException", result); + assertFalse(result, "Result should be false du to InterruptedException"); } private void checkDegreeNode(String nodeNb, Node node) { @@ -292,18 +298,19 @@ public class OpenRoadmTopologyTest { assertEquals("openroadm-network", supportingNodes.get(1).getNetworkRef().getValue()); assertEquals("ROADMA01", supportingNodes.get(1).getNodeRef().getValue()); assertEquals(OpenroadmNodeType.DEGREE, node.augmentation(Node1.class).getNodeType()); - assertEquals(Uint16.valueOf(nodeNb), node.augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.Node1.class) - .getDegreeAttributes().getDegreeNumber()); + assertEquals( + Uint16.valueOf(nodeNb), + node.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.Node1.class) + .getDegreeAttributes().getDegreeNumber()); List availFreqMapsValues = new ArrayList<>(node.augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.Node1.class) + org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.Node1.class) .getDegreeAttributes().getAvailFreqMaps().values()); assertEquals(GridConstant.NB_OCTECTS, availFreqMapsValues.get(0).getFreqMap().length); byte[] byteArray = new byte[GridConstant.NB_OCTECTS]; Arrays.fill(byteArray, (byte) GridConstant.AVAILABLE_SLOT_VALUE); assertEquals(Arrays.toString(byteArray), Arrays.toString(availFreqMapsValues.get(0).getFreqMap())); List tps = node.augmentation( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) .nonnullTerminationPoint().values().stream() .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue())) .collect(Collectors.toList()); @@ -327,13 +334,13 @@ public class OpenRoadmTopologyTest { assertEquals(OpenroadmNodeType.SRG, node.augmentation(Node1.class).getNodeType()); List availFreqMapsValues = new ArrayList<>(node.augmentation( org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev211210.Node1.class) - .getSrgAttributes().getAvailFreqMaps().values()); + .getSrgAttributes().getAvailFreqMaps().values()); assertEquals(GridConstant.NB_OCTECTS, availFreqMapsValues.get(0).getFreqMap().length); byte[] byteArray = new byte[GridConstant.NB_OCTECTS]; Arrays.fill(byteArray, (byte) GridConstant.AVAILABLE_SLOT_VALUE); assertEquals(Arrays.toString(byteArray), Arrays.toString(availFreqMapsValues.get(0).getFreqMap())); List tps = node.augmentation( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) .nonnullTerminationPoint().values().stream() .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue())) .collect(Collectors.toList()); @@ -356,25 +363,22 @@ public class OpenRoadmTopologyTest { assertEquals("XPDRA01", supportingNodes.get(1).getNodeRef().getValue()); assertEquals(OpenroadmNodeType.XPONDER, node.augmentation(Node1.class).getNodeType()); List tps = node.augmentation( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) .nonnullTerminationPoint().values().stream() .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue())) .collect(Collectors.toList()); assertEquals(4, tps.size()); assertEquals("XPDR1-CLIENT1", tps.get(0).getTpId().getValue()); assertEquals(OpenroadmTpType.XPONDERCLIENT, tps.get(0).augmentation(TerminationPoint1.class).getTpType()); - assertEquals("XPDR1-NETWORK1", tps.get(0).augmentation(TerminationPoint1.class) - .getAssociatedConnectionMapTp() - .iterator() - .next() + assertEquals( + "XPDR1-NETWORK1", + tps.get(0).augmentation(TerminationPoint1.class).getAssociatedConnectionMapTp().iterator().next() .getValue()); assertEquals("XPDR1-NETWORK1", tps.get(2).getTpId().getValue()); assertEquals(OpenroadmTpType.XPONDERNETWORK, tps.get(2).augmentation(TerminationPoint1.class).getTpType()); - assertEquals("XPDR1-CLIENT1", tps.get(2).augmentation( - TerminationPoint1.class) - .getAssociatedConnectionMapTp() - .iterator() - .next() + assertEquals( + "XPDR1-CLIENT1", + tps.get(2).augmentation(TerminationPoint1.class).getAssociatedConnectionMapTp().iterator().next() .getValue()); } @@ -390,7 +394,7 @@ public class OpenRoadmTopologyTest { assertEquals("XPDRA01", supportingNodes.get(1).getNodeRef().getValue()); assertEquals(OpenroadmNodeType.XPONDER, node.augmentation(Node1.class).getNodeType()); List tps = node.augmentation( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class) .nonnullTerminationPoint().values().stream() .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue())) .collect(Collectors.toList()); diff --git a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/TpceNetworkTest.java b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/TpceNetworkTest.java index 667997583..a8d7aabca 100644 --- a/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/TpceNetworkTest.java +++ b/networkmodel/src/test/java/org/opendaylight/transportpce/networkmodel/util/TpceNetworkTest.java @@ -7,12 +7,13 @@ */ package org.opendaylight.transportpce.networkmodel.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.concurrent.ExecutionException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.common.network.NetworkTransactionImpl; import org.opendaylight.transportpce.test.AbstractTest; @@ -32,81 +33,84 @@ public class TpceNetworkTest extends AbstractTest { TpceNetwork tpceNetwork = new TpceNetwork(new NetworkTransactionImpl(getDataBroker())); @Test - public void createLayerClliTest() throws InterruptedException, ExecutionException { + void createLayerClliTest() throws InterruptedException, ExecutionException { tpceNetwork.createLayer("clli-network"); InstanceIdentifier nwIID = InstanceIdentifier.create(Networks.class) .child(Network.class, new NetworkKey(new NetworkId("clli-network"))); Network createdClli = getDataBroker().newReadOnlyTransaction() .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().get(); - assertNotNull("Clli layer should be created and not null", createdClli); + assertNotNull(createdClli, "Clli layer should be created and not null"); Augmentation ordClli = new NetworkTypes1Builder() .setClliNetwork(new ClliNetworkBuilder().build()) .build(); - assertNotNull("clli augmentation should not be null", createdClli.getNetworkTypes() - .augmentation(NetworkTypes1.class)); - assertEquals("bad clli augmentation for network-types", ordClli, - createdClli.getNetworkTypes().augmentation(NetworkTypes1.class)); + assertNotNull(createdClli.getNetworkTypes().augmentation(NetworkTypes1.class), + "clli augmentation should not be null"); + assertEquals(ordClli, createdClli.getNetworkTypes().augmentation(NetworkTypes1.class), + "bad clli augmentation for network-types"); } @Test - public void createLayerNetworkTest() throws InterruptedException, ExecutionException { + void createLayerNetworkTest() throws InterruptedException, ExecutionException { tpceNetwork.createLayer("openroadm-network"); InstanceIdentifier nwIID = InstanceIdentifier.create(Networks.class) .child(Network.class, new NetworkKey(new NetworkId("openroadm-network"))); Network createdOrdNetwork = getDataBroker().newReadOnlyTransaction() .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().get(); - assertNotNull("openroadm-network layer should be created and not null", createdOrdNetwork); + assertNotNull(createdOrdNetwork, "openroadm-network layer should be created and not null"); commonNetworkAugmentationTest(createdOrdNetwork); } @Test - public void createLayerTopologyTest() throws InterruptedException, ExecutionException { + void createLayerTopologyTest() throws InterruptedException, ExecutionException { tpceNetwork.createLayer("openroadm-topology"); InstanceIdentifier nwIID = InstanceIdentifier.create(Networks.class) .child(Network.class, new NetworkKey(new NetworkId("openroadm-topology"))); Network createdOrdNetwork = getDataBroker().newReadOnlyTransaction() .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().get(); - assertNotNull("openroadm-logpology layer should be created and not null", createdOrdNetwork); + assertNotNull(createdOrdNetwork, "openroadm-logpology layer should be created and not null"); commonNetworkAugmentationTest(createdOrdNetwork); } @Test - public void createLayerOtnTest() throws InterruptedException, ExecutionException { + void createLayerOtnTest() throws InterruptedException, ExecutionException { tpceNetwork.createLayer("otn-topology"); InstanceIdentifier nwIID = InstanceIdentifier.create(Networks.class) .child(Network.class, new NetworkKey(new NetworkId("otn-topology"))); Network createdOrdNetwork = getDataBroker().newReadOnlyTransaction() .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().get(); - assertNotNull("otn-logpology layer should be created and not null", createdOrdNetwork); + assertNotNull(createdOrdNetwork, "otn-logpology layer should be created and not null"); commonNetworkAugmentationTest(createdOrdNetwork); } @Test - public void createBadLayerTest() throws InterruptedException, ExecutionException { + void createBadLayerTest() throws InterruptedException, ExecutionException { tpceNetwork.createLayer("toto"); InstanceIdentifier nwIID = InstanceIdentifier.create(Networks.class) .child(Network.class, new NetworkKey(new NetworkId("toto"))); Network createdOrdNetwork = getDataBroker().newReadOnlyTransaction() .read(LogicalDatastoreType.CONFIGURATION, nwIID).get().get(); - assertNotNull("toto layer should be created and not null", createdOrdNetwork); - assertNull("toto layer should not have any network-type augmentation", createdOrdNetwork.getNetworkTypes() - .augmentation(NetworkTypes1.class)); - assertNull("toto layer should not have any network-type augmentation", createdOrdNetwork.getNetworkTypes() - .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210 - .NetworkTypes1.class)); + assertNotNull(createdOrdNetwork, "toto layer should be created and not null"); + assertNull(createdOrdNetwork.getNetworkTypes().augmentation(NetworkTypes1.class), + "toto layer should not have any network-type augmentation"); + assertNull( + createdOrdNetwork.getNetworkTypes().augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.NetworkTypes1.class), + "toto layer should not have any network-type augmentation"); } private void commonNetworkAugmentationTest(Network createdOrdNetwork) { Augmentation ordComNet = new org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.NetworkTypes1Builder() - .setOpenroadmCommonNetwork(new OpenroadmCommonNetworkBuilder().build()) - .build(); - assertNotNull("common-network augmentation should not be null", createdOrdNetwork.getNetworkTypes() - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.NetworkTypes1.class)); - assertEquals("bad common-network augmentation for network-types", ordComNet, createdOrdNetwork.getNetworkTypes() - .augmentation( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.NetworkTypes1.class)); + .setOpenroadmCommonNetwork(new OpenroadmCommonNetworkBuilder().build()) + .build(); + assertNotNull( + createdOrdNetwork.getNetworkTypes().augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.NetworkTypes1.class), + "common-network augmentation should not be null"); + assertEquals( + ordComNet, createdOrdNetwork.getNetworkTypes().augmentation( + org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev211210.NetworkTypes1.class), + "bad common-network augmentation for network-types"); } }