Refactor SupportedIfCapability usage
[transportpce.git] / renderer / src / test / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadMInterface221Test.java
index bedee6307b9a63b3ca59bc0b4ffb6a414dcaf56b..4d6a21b3e878bde87cd0c32bdf150ee92089589b 100644 (file)
@@ -7,42 +7,39 @@
  */
 package org.opendaylight.transportpce.renderer.openroadminterface;
 
+import java.math.BigDecimal;
 import java.util.Arrays;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.opendaylight.transportpce.common.fixedflex.FixedFlexImpl;
-import org.opendaylight.transportpce.common.fixedflex.FixedFlexInterface;
-import org.opendaylight.transportpce.common.fixedflex.FlexGridImpl;
+import org.opendaylight.transportpce.common.fixedflex.SpectrumInformation;
 import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
 import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.MappingBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.MappingBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
-@Ignore
 public class OpenRoadMInterface221Test extends AbstractTest {
 
     private final PortMapping portMapping = Mockito.mock(PortMapping.class);
-    private final FixedFlexInterface fixedFlex = Mockito.spy(FixedFlexInterface.class);
-    private final FlexGridImpl flexGrid = Mockito.spy(FlexGridImpl.class);
     private OpenRoadmInterface221 openRoadMInterface221;
     private final String nodeId = "node1";
 
     @Before
     public void setup() {
-
         OpenRoadmInterfaces openRoadmInterfaces = Mockito.spy(OpenRoadmInterfaces.class);
-        this.openRoadMInterface221 = new OpenRoadmInterface221(portMapping, openRoadmInterfaces, fixedFlex, flexGrid);
+        this.openRoadMInterface221 = new OpenRoadmInterface221(portMapping, openRoadmInterfaces);
     }
 
     @Test
     public void testCreateOpenRoadmEthInterface() throws OpenRoadmInterfaceException {
 
         String logicalConnPoint = "logicalConnPoint";
-        Mockito.when(portMapping.getMapping(nodeId, logicalConnPoint)).thenReturn(new MappingBuilder().build());
+        Mockito.when(portMapping.getMapping(nodeId, logicalConnPoint))
+            .thenReturn(new MappingBuilder().setSupportingCircuitPackName("circit-pack").setSupportingPort("port")
+                .setLogicalConnectionPoint(logicalConnPoint).build());
         Assert.assertEquals(openRoadMInterface221.createOpenRoadmEthInterface(nodeId, logicalConnPoint),
                 logicalConnPoint + "-ETHERNET");
     }
@@ -59,14 +56,16 @@ public class OpenRoadMInterface221Test extends AbstractTest {
     public void testCreateFlexOCH() throws OpenRoadmInterfaceException {
 
         String logicalConnPoint = "logicalConnPoint";
-        Mockito.when(portMapping.getMapping(nodeId, logicalConnPoint)).thenReturn(new MappingBuilder().build());
-        Mockito.when(fixedFlex.getFixedFlexWaveMapping(Mockito.anyLong())).thenReturn(new FixedFlexImpl());
-        Mockito.when(fixedFlex.getStart()).thenReturn(12d);
-        Mockito.when(fixedFlex.getStop()).thenReturn(12d);
-        Mockito.when(fixedFlex.getCenterFrequency()).thenReturn(12d);
-        Long waveNumber = 1L;
-        Assert.assertNotNull(openRoadMInterface221.createFlexOCH(nodeId, logicalConnPoint, waveNumber, 761, 768));
-        Assert.assertEquals(openRoadMInterface221.createFlexOCH(nodeId, logicalConnPoint, waveNumber, 761, 768),
+        Mockito.when(portMapping.getMapping(nodeId, logicalConnPoint))
+            .thenReturn(new MappingBuilder().setSupportingCircuitPackName("circit-pack").setSupportingPort("port")
+                .setLogicalConnectionPoint(logicalConnPoint).build());
+        SpectrumInformation spectrumInformation = new SpectrumInformation();
+        spectrumInformation.setWaveLength(Uint32.valueOf(1));
+        spectrumInformation.setLowerSpectralSlotNumber(761);
+        spectrumInformation.setHigherSpectralSlotNumber(768);
+        spectrumInformation.setCenterFrequency(BigDecimal.valueOf(195.8));
+        Assert.assertNotNull(openRoadMInterface221.createFlexOCH(nodeId, logicalConnPoint, spectrumInformation));
+        Assert.assertEquals(openRoadMInterface221.createFlexOCH(nodeId, logicalConnPoint, spectrumInformation),
                 Arrays.asList(logicalConnPoint + "-nmc-761:768"));
     }
 
@@ -74,15 +73,19 @@ public class OpenRoadMInterface221Test extends AbstractTest {
     public void testCreateFlexOCHReturnsMoreThanOneElement() throws OpenRoadmInterfaceException {
 
         String logicalConnPoint = "logicalConnPointDEG";
-        Mockito.when(portMapping.getMapping(nodeId, logicalConnPoint)).thenReturn(new MappingBuilder().build());
-        Mockito.when(fixedFlex.getFixedFlexWaveMapping(Mockito.anyLong())).thenReturn(new FixedFlexImpl());
-        Mockito.when(fixedFlex.getStart()).thenReturn(12d);
-        Mockito.when(fixedFlex.getStop()).thenReturn(12d);
-        Mockito.when(fixedFlex.getCenterFrequency()).thenReturn(12d);
-        Long waveNumber = 1L;
-        Assert.assertNotNull(openRoadMInterface221.createFlexOCH(nodeId, logicalConnPoint, waveNumber, 761, 768));
-        Assert.assertEquals(openRoadMInterface221.createFlexOCH(nodeId, logicalConnPoint, waveNumber, 761, 768),
-                Arrays.asList(logicalConnPoint + "-mc-" + waveNumber, logicalConnPoint + "-nmc-761:768"));
+        Mockito.when(portMapping.getMapping(nodeId, logicalConnPoint))
+            .thenReturn(new MappingBuilder().setSupportingCircuitPackName("circit-pack").setSupportingPort("port")
+                .setLogicalConnectionPoint(logicalConnPoint).build());
+        SpectrumInformation spectrumInformation = new SpectrumInformation();
+        spectrumInformation.setWaveLength(Uint32.valueOf(1));
+        spectrumInformation.setLowerSpectralSlotNumber(761);
+        spectrumInformation.setHigherSpectralSlotNumber(768);
+        spectrumInformation.setCenterFrequency(BigDecimal.valueOf(195.8));
+        spectrumInformation.setMinFrequency(BigDecimal.valueOf(195.775));
+        spectrumInformation.setMaxFrequency(BigDecimal.valueOf(195.825));
+        Assert.assertNotNull(openRoadMInterface221.createFlexOCH(nodeId, logicalConnPoint,spectrumInformation));
+        Assert.assertEquals(openRoadMInterface221.createFlexOCH(nodeId, logicalConnPoint, spectrumInformation),
+                Arrays.asList(logicalConnPoint + "-mc-761:768", logicalConnPoint + "-nmc-761:768"));
     }
 
     @Test
@@ -90,12 +93,15 @@ public class OpenRoadMInterface221Test extends AbstractTest {
 
         String logicalConnPoint = "logicalConnPoint";
         Mockito.when(portMapping.getMapping(nodeId, logicalConnPoint))
-                .thenReturn(new MappingBuilder().setLogicalConnectionPoint(logicalConnPoint).build());
-        Mockito.when(fixedFlex.getCenterFrequency()).thenReturn(12d);
-        Mockito.when(fixedFlex.getFixedFlexWaveMapping(Mockito.anyLong())).thenReturn(new FixedFlexImpl());
-        Long waveNumber = 1L;
-        Assert.assertEquals(openRoadMInterface221.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber,
-                761, 768), logicalConnPoint + "-761:768");
+                .thenReturn(new MappingBuilder().setSupportingCircuitPackName("circit-pack").setSupportingPort("port")
+                    .setLogicalConnectionPoint(logicalConnPoint).build());
+        SpectrumInformation spectrumInformation = new SpectrumInformation();
+        spectrumInformation.setWaveLength(Uint32.valueOf(1));
+        spectrumInformation.setLowerSpectralSlotNumber(761);
+        spectrumInformation.setHigherSpectralSlotNumber(768);
+        spectrumInformation.setCenterFrequency(BigDecimal.valueOf(195.8));
+        Assert.assertEquals(openRoadMInterface221.createOpenRoadmOchInterface(nodeId, logicalConnPoint,
+                spectrumInformation), logicalConnPoint + "-761:768");
     }
 
     @Test
@@ -104,10 +110,11 @@ public class OpenRoadMInterface221Test extends AbstractTest {
         String logicalConnPoint = "logicalConnPoint";
         String supportOchInterface = "supportOchInterface";
         Mockito.when(portMapping.getMapping(nodeId, logicalConnPoint))
-                .thenReturn(new MappingBuilder().setLogicalConnectionPoint(logicalConnPoint).build());
-        Assert.assertEquals(
-                openRoadMInterface221.createOpenRoadmOtu4Interface(nodeId, logicalConnPoint, supportOchInterface),
-                logicalConnPoint + "-OTU");
+            .thenReturn(new MappingBuilder().setSupportingCircuitPackName("circit-pack").setSupportingPort("port")
+                .setLogicalConnectionPoint(logicalConnPoint).build());
+        Assert.assertEquals(openRoadMInterface221
+            .createOpenRoadmOtu4Interface(nodeId, logicalConnPoint, supportOchInterface, null, null),
+            logicalConnPoint + "-OTU");
 
     }
 
@@ -121,17 +128,20 @@ public class OpenRoadMInterface221Test extends AbstractTest {
     }
 
     @Test
-    public void testCreateOpenRoadmOmsInterfaceSupportingOmsNotNull() throws OpenRoadmInterfaceException {
-
-        String supportingOms = "supportingOms";
+    public void testCreateOpenRoadmOmsInterfaceSupportingOtsNotNull() throws OpenRoadmInterfaceException {
+        String logicalConnPoint = "logicalConnPoint";
+        String supportingOts = "supportingOts";
         Assert.assertEquals(openRoadMInterface221.createOpenRoadmOmsInterface(nodeId,
-                new MappingBuilder().setSupportingOms(supportingOms).build()), supportingOms);
+                new MappingBuilder().setSupportingCircuitPackName("circit-pack").setSupportingPort("port")
+                    .setLogicalConnectionPoint(logicalConnPoint).setSupportingOts(supportingOts).build()),
+                "OMS-" + logicalConnPoint);
     }
 
     @Test
     public void testCreateOpenRoadmOmsInterfaceSupportingOmsNotNullException() throws OpenRoadmInterfaceException {
 
-        Assert.assertNull(openRoadMInterface221.createOpenRoadmOmsInterface(nodeId, new MappingBuilder().build()));
+        Assert.assertNull(openRoadMInterface221.createOpenRoadmOmsInterface(nodeId, new MappingBuilder()
+                .setLogicalConnectionPoint("logicalConnPoint").build()));
     }
 
     @Test