package org.opendaylight.transportpce.common.mapping;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Random;
import java.util.concurrent.ExecutionException;
import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
import org.opendaylight.transportpce.test.DataStoreContext;
import org.opendaylight.transportpce.test.DataStoreContextImpl;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.Network;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.NetworkBuilder;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.network.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.Network;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.NetworkBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.Nodes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.Direction;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.NodeTypes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.OrgOpenroadmDeviceData;
private static PortMappingVersion121 portMappingVersion121;
private Random ran = new Random();
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
// test createMappingData for a xpdr node with 3 network + 1 client + bidirectional & unidirectional ports
DataStoreContext dataStoreContext = new DataStoreContextImpl();
dataBroker = dataStoreContext.getDataBroker();
}
@Test
- public void createMappingDataTestRdm() {
+ void createMappingDataTestRdm() {
// mock node info
final Info info = getInfo2();
.thenReturn(Optional.of(ordmSrgObject6));
// test createMappingData with a node with 3 dgree + 3 srg + bidirectional & unidirectional ports
- assertTrue("creating mappingdata for existed node returns true",
- portMappingVersion121.createMappingData("node"));
+ assertTrue(portMappingVersion121.createMappingData("node"),
+ "creating mappingdata for existed node returns true");
// assert all portmappings have been created for the roadm node
ReadTransaction rr = dataBroker.newReadOnlyTransaction();
try {
Optional<Network> optionalNetwork = rr.read(LogicalDatastoreType.CONFIGURATION, mappingIID).get();
if (optionalNetwork.isPresent()) {
- network = optionalNetwork.get();
+ network = optionalNetwork.orElseThrow();
}
} catch (ExecutionException | InterruptedException e) {
LOG.error("Failed to read mapping.", e);
fail();
-
}
List<String> testMappings = Arrays.asList("SRG2-PP1-RX", "SRG3-PP1-RX", "SRG1-PP1-TXRX", "SRG3-PP1-TX",
"DEG1-TTP-TXRX", "SRG2-PP1-TX", "DEG2-TTP-RX", "DEG2-TTP-TX", "DEG3-TTP-RX", "DEG3-TTP-TX");
}
Collections.sort(testMappings);
Collections.sort(mappings);
- assertEquals("test mapping are equals to mapping", testMappings, mappings);
+ assertEquals(testMappings, mappings, "test mapping are equals to mapping");
// test updateMapping
- assertTrue("update mapping for node returns true",
- portMappingVersion121.updateMapping("node", mappingValues.get(0)));
+ assertTrue(portMappingVersion121.updateMapping("node", mappingValues.get(0)),
+ "update mapping for node returns true");
// test createMapping for non-existent roadm node
- assertFalse("create non existed roadm node returns false", portMappingVersion121.createMappingData("node2"));
+ assertFalse(portMappingVersion121.createMappingData("node2"), "create non existed roadm node returns false");
// test updateMapping for null roadm node
- assertFalse("updating null roadm node returns false",
- portMappingVersion121.updateMapping(null, mappingValues.get(0)));
+ assertFalse(portMappingVersion121.updateMapping(null, mappingValues.get(0)),
+ "updating null roadm node returns false");
}
@Test
- public void createMappingDataTestXpdr() {
+ void createMappingDataTestXpdr() {
// mock node info
final Info info = getInfo();
Timeouts.DEVICE_READ_TIMEOUT, Timeouts.DEVICE_READ_TIMEOUT_UNIT)).thenReturn(Optional.of(deviceObject));
// test createMappingData for xpdr node with 2 network + 1 client + unidirectional & bidirectional ports
- assertTrue("returns true when create mapping ", portMappingVersion121.createMappingData("node"));
+ assertTrue(portMappingVersion121.createMappingData("node"), "returns true when create mapping");
// assert all portmappings have been created for the xpdr node
ReadTransaction rr = dataBroker.newReadOnlyTransaction();
try {
Optional<Network> optionalNetwork = rr.read(LogicalDatastoreType.CONFIGURATION, mappingIID).get();
if (optionalNetwork.isPresent()) {
- network = optionalNetwork.get();
+ network = optionalNetwork.orElseThrow();
}
} catch (ExecutionException | InterruptedException e) {
}
Collections.sort(testMappings);
Collections.sort(mappings);
- assertEquals("test mapping are equals to mapping", testMappings, mappings);
+ assertEquals(testMappings, mappings, "test mapping are equals to mapping");
}
@NonNull
private Interfaces getInterfaces(String i1) {
return new InterfacesBuilder().setInterfaceName(i1).build();
}
-
}