X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fopenflow%2Fmd%2Fcore%2Fsal%2Fconvertor%2FPortConvertorTest.java;h=06e143c648aae36370908ffbaa760ec1054f15c1;hb=31da05eeb07dd00356a47c73a8d282a92e02dd89;hp=7b2b02e21e74b2d5cf7076315c77097b83c80b0c;hpb=611180ac770b6038b526c54994701db16d1a8567;p=openflowplugin.git diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PortConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PortConvertorTest.java index 7b2b02e21e..06e143c648 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PortConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PortConvertorTest.java @@ -4,15 +4,16 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributor: usha.m.s@ericsson.com */ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor; +import java.util.Optional; import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; +import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures; @@ -35,64 +36,73 @@ public class PortConvertorTest { private PortFeatures features = new PortFeatures(true, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); - + private PortConfig config = new PortConfig(false, false, false, false); - - private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures portf31= + + private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures portf31= new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures( null, null, null, null, null, null, null, null, null, null, true, null, null, null, null, null); - - private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig config31 = + + private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig config31 = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig( false, false, false, false); + private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig configMask31 = + new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig( + true, true, true, true); + + private PortConfigV10 portConfMaskV10 = new PortConfigV10(true, true, true, true, true, true, true);; + /** - * test of {@link PortConvertor#toPortModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port, short)} + * test of {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)} } */ @Test public void testtoPortModInputwithAllParameters() { - + PortBuilder portBld = new PortBuilder(); portBld.setAdvertisedFeatures(features); portBld.setConfiguration(config); portBld.setPortNumber(new PortNumberUni(42L)); portBld.setHardwareAddress(new MacAddress(DEFAULT_MAC_ADDRESS)); - - PortModInput portOut = PortConvertor.toPortModInput(portBld.build(), EncodeConstants.OF13_VERSION_ID); - + + VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3); + final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager(); + Optional portOutOptional = convertorManager.convert(portBld.build(), data); + PortModInput portOut = portOutOptional.orElse(PortConvertor.defaultResult(OFConstants.OFP_VERSION_1_3)); + PortConfigV10 portConfV10 = new PortConfigV10(false, false, false, false, true, true, false); - + PortModInputBuilder portModInputBld = new PortModInputBuilder(); - + portModInputBld.setConfig(config31); - portModInputBld.setMask(config31); + portModInputBld.setMask(configMask31); portModInputBld.setPortNo( new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber(42L)); portModInputBld.setHwAddress(new MacAddress(DEFAULT_MAC_ADDRESS)); portModInputBld.setAdvertise(portf31); - + portModInputBld.setConfigV10(portConfV10); - portModInputBld.setMaskV10(portConfV10); + portModInputBld.setMaskV10(portConfMaskV10); portModInputBld.setAdvertiseV10( new PortFeaturesV10(null, null, null, null, null, null, null, true, null, null, null, null)); - + portModInputBld.setVersion((short) EncodeConstants.OF13_VERSION_ID); - + Assert.assertEquals(portModInputBld.build(), portOut); } - + /** * test of {@link PortConvertor#toPortDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.FlowCapablePort , short)} */ @Test public void testtoPortDescwithAllParameters(){ - + State state = new StateBuilder().setBlocked(false).setLinkDown(false).setLive(false).build(); PortState state31= new PortState(false, false, false); - + FlowCapableNodeConnectorBuilder flowCapableNodeConnectorBuilder = new FlowCapableNodeConnectorBuilder(); - + flowCapableNodeConnectorBuilder.setAdvertisedFeatures(features); flowCapableNodeConnectorBuilder.setConfiguration(config); flowCapableNodeConnectorBuilder.setCurrentFeature(features); @@ -104,11 +114,11 @@ public class PortConvertorTest { flowCapableNodeConnectorBuilder.setPortNumber(new PortNumberUni(42L)); flowCapableNodeConnectorBuilder.setState(state); flowCapableNodeConnectorBuilder.setSupported(features); - + Ports portsOut = PortConvertor.toPortDesc(flowCapableNodeConnectorBuilder.build(), EncodeConstants.OF13_VERSION_ID); - + PortsBuilder portsB = new PortsBuilder(); - + portsB.setAdvertisedFeatures(portf31); portsB.setConfig(config31); portsB.setCurrentFeatures(portf31); @@ -120,8 +130,8 @@ public class PortConvertorTest { portsB.setPortNo(42L); portsB.setState(state31); portsB.setSupportedFeatures(portf31); - + Assert.assertEquals(portsB.build(), portsOut); } - + }