Bug 5540 - ConvertorManager base 63/40863/24
authorTomas Slusny <tomas.slusny@pantheon.sk>
Mon, 27 Jun 2016 11:36:16 +0000 (13:36 +0200)
committerTomas Slusny <tomas.slusny@pantheon.sk>
Wed, 3 Aug 2016 15:44:55 +0000 (17:44 +0200)
- Added base for ConvertorManager
- Removed datapathId from Convertor interface (as it was not needed anymore)
- Updated usages and tests accordingly
- Moved IPProtocols and IPConversionUtil to package
  org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common

Change-Id: I22940403495be5f0398682cab4e3377ee86ce7be
Signed-off-by: Tomas Slusny <tomas.slusny@pantheon.sk>
36 files changed:
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/FlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/MatchingFlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/FlowDirectStatisticsService.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcTaskFactory.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManager.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstConvertorImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstConvertorV10Impl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactorMappingFactory.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcConvertorImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcConvertorV10Impl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactorMappingFactory.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertReactor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/Convertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorData.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorProcessor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IPProtocols.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IPProtocols.java with 93% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IpConversionUtil.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IpConversionUtil.java with 99% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ParametrizedConvertor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flowflag/FlowFlagConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flowflag/FlowFlagsConvertorImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flowflag/FlowFlagsConvertorV10Impl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10Impl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/FlowRemovedTranslator.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManagerTest.java [new file with mode: 0644]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwDstReactorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionSetNwSrcReactorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IpConversionUtilTest.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IpConversionUtilTest.java with 96% similarity]
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flowflag/FlowFlagReactorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorImpl2Test.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10ImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchReactorTest.java

index 70b458daaa3084d42b8e6c87564aaf6a9f2d8ca5..12641266b037a07f1b69dd65abef784b2d103fe1 100644 (file)
@@ -73,8 +73,7 @@ public final class FlowsInTableService extends AbstractCompatibleStatService<Get
 
         // convert and inject match
         final short version = getVersion();
-        MatchReactor.getInstance().convert(input.getMatch(), version, mprFlowRequestBuilder,
-                getDeviceInfo().getDatapathId());
+        MatchReactor.getInstance().convert(input.getMatch(), version, mprFlowRequestBuilder);
 
         // Set request body to main multipart request
         multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
index 6456c89fad3b0bcc0d6731a984766f1063f9769a..f7050395c8499a4cc8bbd4a28b1e276da9a5021f 100644 (file)
@@ -60,7 +60,7 @@ final class MatchingFlowsInTableService extends AbstractMultipartService<GetAggr
             mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
         }
 
-        MatchReactor.getInstance().convert(input.getMatch(), version, mprAggregateRequestBuilder, getDatapathId());
+        MatchReactor.getInstance().convert(input.getMatch(), version, mprAggregateRequestBuilder);
 
         FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
 
index 66c8a93679c9d90334477205c4e5bb16f2fd60ef..e30988e1aa3d0e6014eaf190e60c66358d9ab639 100644 (file)
@@ -93,7 +93,7 @@ public class FlowDirectStatisticsService extends AbstractDirectStatisticsService
             mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
         }
 
-        MatchReactor.getInstance().convert(input.getMatch(), getVersion(), mprFlowRequestBuilder, getDatapathId());
+        MatchReactor.getInstance().convert(input.getMatch(), getVersion(), mprFlowRequestBuilder);
 
         return new MultipartRequestFlowCaseBuilder()
                 .setMultipartRequestFlow(mprFlowRequestBuilder.build())
index 60df8aabf3be101c6d405f0502a45a9d540f32ca..774dce40b4463ab399f826800271df2d718a0ee7 100644 (file)
@@ -1644,8 +1644,7 @@ public abstract class OFRpcTaskFactory {
 
                 // convert and inject match
                 MatchReactor.getInstance().convert(input.getMatch(), taskContext.getSession()
-                                .getPrimaryConductor().getVersion(), mprFlowRequestBuilder,
-                        taskContext.getSession().getFeatures().getDatapathId());
+                                .getPrimaryConductor().getVersion(), mprFlowRequestBuilder);
 
                 // Set request body to main multipart request
                 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
@@ -1772,8 +1771,7 @@ public abstract class OFRpcTaskFactory {
                 }
 
                 MatchReactor.getInstance().convert(input.getMatch(), taskContext.getSession()
-                                .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder,
-                        taskContext.getSession().getFeatures().getDatapathId());
+                                .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder);
 
                 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
                         .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder);
index 8d55f55dd874b8a1f11af7371c6eada3891decf4..366b61a37cc434b85283a496a1e32bef8b8a52e1 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.ActionExtensionHelper;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwDstReactor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwSrcReactor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IPProtocols;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
@@ -345,7 +346,7 @@ public final class ActionConvertor {
         } else {
             SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
             SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-            MatchReactor.getInstance().convert(match, version, setFieldBuilder, datapathid);
+            MatchReactor.getInstance().convert(match, version, setFieldBuilder);
             setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
             actionBuilder.setActionChoice(setFieldCaseBuilder.build());
 
@@ -643,7 +644,7 @@ public final class ActionConvertor {
             final ActionBuilder actionBuilder, final short version) {
 
         try {
-            ActionSetNwSrcReactor.getInstance().convert((SetNwSrcActionCase) action, version, actionBuilder, null);
+            ActionSetNwSrcReactor.getInstance().convert((SetNwSrcActionCase) action, version, actionBuilder);
         } catch (Exception e) {
             LOG.error(e.getMessage(), e);
             return null;
@@ -657,7 +658,7 @@ public final class ActionConvertor {
             final ActionBuilder actionBuilder, final short version) {
 
         try {
-            ActionSetNwDstReactor.getInstance().convert((SetNwDstActionCase) action, version, actionBuilder, null);
+            ActionSetNwDstReactor.getInstance().convert((SetNwDstActionCase) action, version, actionBuilder);
         } catch (Exception e) {
             LOG.error(e.getMessage(), e);
             return null;
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManager.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManager.java
new file mode 100644 (file)
index 0000000..db46143
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * 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
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ParametrizedConvertor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Manages various convertors and allows to use them all in one generic way
+ */
+public class ConvertorManager {
+    private static final Logger LOG = LoggerFactory.getLogger(ConvertorManager.class);
+    private static ConvertorManager INSTANCE;
+
+    static {
+        INSTANCE = new ConvertorManager();
+        // All convertors are registered here
+    }
+
+    // Actual convertor keys
+    private List<Class<?>> convertorKeys = new ArrayList<>();
+    private List<Class<?>> parametrizedConvertorKeys = new ArrayList<>();
+
+    // Cache, that holds all registered convertors, but they can have multiple keys,
+    // based on instanceof checks in the convert method
+    private Map<Class<?>, Convertor> convertors = new HashMap<>();
+    private Map<Class<?>, ParametrizedConvertor> parametrizedConvertors = new HashMap<>();
+
+    private ConvertorManager() {
+        // Hiding implicit constructor
+    }
+
+    /**
+     * Gets instance of Convertor Manager.
+     *
+     * @return the instance
+     */
+    public static ConvertorManager getInstance() {
+        return INSTANCE;
+    }
+
+    /**
+     * Register convertor.
+     *
+     * @param convertor the convertor
+     * @return if registration was successful
+     */
+    public boolean registerConvertor(final Convertor convertor) {
+        final Class<?> type = convertor.getType();
+
+        if (convertors.containsKey(type)) {
+            LOG.warn("Convertor for type {} is already registered", type);
+            return false;
+        }
+
+        convertorKeys.add(type);
+        convertors.put(type, convertor);
+        LOG.debug("{} is now converted by {}", type, convertor);
+        return true;
+    }
+
+    /**
+     * Register convertor.
+     *
+     * @param convertor the convertor
+     * @return if registration was successful
+     */
+    public boolean registerConvertor(final ParametrizedConvertor convertor) {
+        final Class<?> type = convertor.getType();
+
+        if (parametrizedConvertors.containsKey(type)) {
+            LOG.warn("Convertor for type {} is already registered", type);
+            return false;
+        }
+
+        parametrizedConvertorKeys.add(type);
+        parametrizedConvertors.put(type, convertor);
+        LOG.debug("{} is now converted by {}", type, convertor);
+        return true;
+    }
+
+    /**
+     * Lookup and use convertor by specified type, then converts source and returns converted result
+     *
+     * @param <FROM> the source type
+     * @param <TO>   the result type
+     * @param source the source
+     * @return the result (can be empty, if no convertor was found)
+     */
+    @SuppressWarnings("unchecked")
+    public <FROM, TO> Optional<TO> convert(final FROM source) {
+        if (Objects.isNull(source)) {
+            LOG.trace("Cannot convert source, because it is null");
+            return Optional.empty();
+        }
+
+        Class<?> type = source.getClass();
+
+        if (source instanceof Collection) {
+            final Iterator it = ((Collection) source).iterator();
+            Object next = null;
+
+            if (it.hasNext()) {
+                next = it.next();
+            }
+
+            if (Objects.isNull(next)) {
+                LOG.trace("Cannot convert {}, because it is empty collection", type);
+                return Optional.empty();
+            }
+
+            type = next.getClass();
+        }
+
+        Convertor convertor = null;
+
+        if (!convertors.containsKey(type)) {
+            boolean found = false;
+
+            for (Class<?> key : convertorKeys) {
+                if (key.isAssignableFrom(type)) {
+                    convertor = convertors.get(key);
+                    convertors.put(type, convertor);
+                    LOG.debug("{} is now converted by {}", type, convertor);
+                    found = true;
+                    break;
+                }
+            }
+
+            if (!found) {
+                LOG.error("Convertor for {} not found", type);
+                return Optional.empty();
+            }
+        }
+
+        if (Objects.isNull(convertor)) {
+            convertor = convertors.get(type);
+        }
+
+        final Object result = convertor.convert(source);
+        return Optional.of((TO) result);
+    }
+
+    /**
+     * Lookup and use convertor by specified type, then converts source and returns converted result
+     *
+     * @param <FROM> the source type
+     * @param <TO>   the result type
+     * @param <DATA> the data type
+     * @param source the source
+     * @param data   convertor data
+     * @return the result (can be empty, if no convertor was found)
+     */
+    @SuppressWarnings("unchecked")
+    public <FROM, TO, DATA extends ConvertorData> Optional<TO> convert(final FROM source, final DATA data) {
+        if (Objects.isNull(source)) {
+            LOG.trace("Cannot convert source, because it is null");
+            return Optional.empty();
+        }
+
+        Class<?> type = source.getClass();
+
+        if (source instanceof Collection) {
+            final Iterator it = ((Collection) source).iterator();
+            Object next = null;
+
+            if (it.hasNext()) {
+                next = it.next();
+            }
+
+            if (Objects.isNull(next)) {
+                LOG.trace("Cannot convert {}, because it is empty collection", type);
+                return Optional.empty();
+            }
+
+            type = next.getClass();
+        }
+
+        ParametrizedConvertor convertor = null;
+
+        if (!parametrizedConvertors.containsKey(type)) {
+            boolean found = false;
+
+            for (Class<?> key : parametrizedConvertorKeys) {
+                if (key.isAssignableFrom(type)) {
+                    convertor = parametrizedConvertors.get(key);
+                    parametrizedConvertors.put(type, convertor);
+                    LOG.debug("{} is now converted by {}", type, convertor);
+                    found = true;
+                    break;
+                }
+            }
+
+            if (!found) {
+                LOG.error("Convertor for {} not found", type);
+                return Optional.empty();
+            }
+        }
+
+        if (Objects.isNull(convertor)) {
+            convertor = parametrizedConvertors.get(type);
+        }
+
+        final Object result = convertor.convert(source, data);
+        return Optional.of((TO) result);
+    }
+}
\ No newline at end of file
index 0115b55560799d0c88de9a74b5f6dd42bb3b8ed4..401227b800973af342216de35ce9b02a7acc08c5 100644 (file)
@@ -198,10 +198,10 @@ public class FlowConvertor {
         salToOFFlowOutGroup(flow, flowMod);
 
         // convert and inject flowFlags
-        FlowFlagReactor.getInstance().convert(flow.getFlags(), version, flowMod, datapathid);
+        FlowFlagReactor.getInstance().convert(flow.getFlags(), version, flowMod);
 
         // convert and inject match
-        MatchReactor.getInstance().convert(flow.getMatch(), version, flowMod, datapathid);
+        MatchReactor.getInstance().convert(flow.getMatch(), version, flowMod);
 
         if (flow.getInstructions() != null) {
             flowMod.setInstruction(toInstructions(flow, version, datapathid));
index 0ea9d72addd6196ffab5854e09ebf0a60ccfa222..15909e8fa042546d6af8585b05a6556ba6ec80f3 100644 (file)
@@ -8,8 +8,7 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;
 
-import java.math.BigInteger;
-
+import com.google.common.base.Splitter;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
@@ -18,8 +17,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.addr
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
 
-import com.google.common.base.Splitter;
-
 /**
  * Utility class for converting a MD-SAL action subelement into the OF subelement
  */
@@ -27,7 +24,12 @@ public class ActionSetNwDstConvertorImpl implements Convertor<SetNwDstActionCase
     private static final Splitter PREFIX_SPLITTER = Splitter.on('/');
 
     @Override
-    public Object convert(final SetNwDstActionCase source, final BigInteger datapathid) {
+    public Class<?> getType() {
+        return SetNwDstActionCase.class;
+    }
+
+    @Override
+    public Object convert(final SetNwDstActionCase source) {
         Address address = source.getSetNwDstAction().getAddress();
         if (address instanceof Ipv4) {
             Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
index 576a995a8c773b944abe82a9c53ab5ad5b8231fc..0a3293495d2d041650fefce8dd26bec0e3d6713e 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;
 
-import java.math.BigInteger;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
@@ -21,7 +20,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.addr
 public class ActionSetNwDstConvertorV10Impl implements Convertor<SetNwDstActionCase, Object> {
 
     @Override
-    public Object convert(SetNwDstActionCase source, BigInteger datapathid) {
+    public Class<?> getType() {
+        return SetNwDstActionCase.class;
+    }
+
+    @Override
+    public Object convert(SetNwDstActionCase source) {
         Address address = source.getSetNwDstAction().getAddress();
         if (address instanceof Ipv4) {
             //FIXME use of substring should be removed and OF models should distinguish where
index 766970502cfdad0d6b71d5c211cd9e8c26edf965..afbdb4a56bdbda9df3c0a2bbc11a7dc5977b1673 100644 (file)
@@ -12,7 +12,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionResultTargetKey;
index 6702c0524ac89587a446340cad1e4904c16c2c37..0b58ae0c5dd5ad7f2d10051d7e954bb56c3d9689 100644 (file)
@@ -8,8 +8,7 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;
 
-import java.math.BigInteger;
-
+import com.google.common.base.Splitter;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
@@ -18,8 +17,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.addr
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
 
-import com.google.common.base.Splitter;
-
 /**
  * Utility class for converting a MD-SAL action subelement into the OF subelement
  */
@@ -28,7 +25,12 @@ public class ActionSetNwSrcConvertorImpl implements Convertor<SetNwSrcActionCase
     private static final Splitter PREFIX_SPLITTER = Splitter.on('/');
 
     @Override
-    public Object convert(final SetNwSrcActionCase source, final BigInteger datapathid) {
+    public Class<?> getType() {
+        return SetNwSrcActionCase.class;
+    }
+
+    @Override
+    public Object convert(final SetNwSrcActionCase source) {
         Address address = source.getSetNwSrcAction().getAddress();
         if (address instanceof Ipv4) {
             Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
index d7e8e8c32c9828e7dc4cf1bb0d8b3fc31686544a..fc988aa2bcad5471414d0a40cd2d2a83b855c8c2 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;
 
-import java.math.BigInteger;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
@@ -21,7 +20,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.addr
 public class ActionSetNwSrcConvertorV10Impl implements Convertor<SetNwSrcActionCase, Object> {
 
     @Override
-    public Object convert(SetNwSrcActionCase source, BigInteger datapathid) {
+    public Class<?> getType() {
+        return SetNwSrcActionCase.class;
+    }
+
+    @Override
+    public Object convert(SetNwSrcActionCase source) {
         Address address = source.getSetNwSrcAction().getAddress();
         if (address instanceof Ipv4) {
             //FIXME use of substring should be removed and OF models should distinguish where
index 675a913eeeebbfeeaac731b4c3c87ccf295800b9..a7d43108f1a1ea533e1cf19dbe8ecb1676d98c17 100644 (file)
@@ -13,7 +13,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionResultTargetKey;
index d6e60b2a420a13b6aad60881a3a071f91f3c19d8..5127570a2aca81eb3c13402a84bfc9939e4afa92 100644 (file)
@@ -8,12 +8,10 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
 
-import java.math.BigInteger;
+import com.google.common.collect.ImmutableMap;
 import java.util.HashMap;
 import java.util.Map;
 
-import com.google.common.collect.ImmutableMap;
-
 /**
  * @param <FROM> source type for conversion
  *
@@ -44,19 +42,18 @@ public abstract class ConvertReactor<FROM> {
      * @param source convert from
      * @param version openflow version
      * @param target convert to
-     * @param datapathid datapath id
      * @param <RESULT> result
      * @param <TARGET> target
      */
     @SuppressWarnings("unchecked")
-    public <RESULT, TARGET> void convert(final FROM source, final short version, final TARGET target, final BigInteger datapathid) {
+    public <RESULT, TARGET> void convert(final FROM source, final short version, final TARGET target) {
 
         //lookup converter
         Convertor<FROM, RESULT> convertor = (Convertor<FROM, RESULT>) conversionMapping.get(version);
         if (convertor == null) {
             throw new IllegalArgumentException("convertor for given version ["+version+"] not found");
         }
-        RESULT convertedItem = convertor.convert(source,datapathid);
+        RESULT convertedItem = convertor.convert(source);
 
         //lookup injection
         InjectionKey key = buildInjectionKey(version, convertedItem, target);
index 4583a15587c2ee7d45dcfd5e0a636ea8b7068ef8..0e94005c07d0234bb0ac2ccc49975f664d750563 100644 (file)
@@ -1,5 +1,5 @@
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,20 +8,27 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
 
-import java.math.BigInteger;
-
-
 /**
- * converting from MD-SAL model into appropriate OF-API model
- * @param <FROM>  type of source
- * @param <TO>  type of result
+ * Converts OpenflowJava to MDSal model and vice versa
+ *
+ * @param <FROM> type of source
+ * @param <TO>   type of result
  */
 public interface Convertor<FROM, TO> {
-    
+
+    /**
+     * Gets type of convertor, used in
+     * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager}.
+     *
+     * @return the type of convertor
+     */
+    Class<?> getType();
+
     /**
-     * @param source source type
-     * @param datapathid  datapath id
-     * @return converted match (into OF-API model)
+     * Converts source to result
+     *
+     * @param source source
+     * @return converted source
      */
-    TO convert(FROM source,BigInteger datapathid);
+    TO convert(FROM source);
 }
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorCase.java
new file mode 100644 (file)
index 0000000..aa9ea1f
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * 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
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
+
+import com.google.common.base.Preconditions;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+
+/**
+ * The Convertor case used in {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor}.
+ *
+ * @param <FROM> the source type
+ * @param <TO>   the result type
+ * @param <DATA> the data type
+ */
+public abstract class ConvertorCase<FROM, TO, DATA extends ConvertorData> {
+    private final List<Short> supportedVersions;
+    private final Class<FROM> type;
+    private final boolean errorOnEmpty;
+
+    /**
+     * Instantiates a new Convertor case.
+     *
+     * @param type              the type
+     * @param errorOnEmpty      the error on empty
+     * @param supportedVersions the supported versions
+     */
+    protected ConvertorCase(Class<FROM> type, boolean errorOnEmpty, Short... supportedVersions) {
+        this.type = type;
+        this.errorOnEmpty = errorOnEmpty;
+        this.supportedVersions = Arrays.asList(Preconditions.checkNotNull(supportedVersions));
+    }
+
+    /**
+     * Process source and return result, what can be empty
+     *
+     * @param source the source
+     * @param data   the data
+     * @return the optional
+     */
+    public abstract Optional<TO> process(@Nonnull final FROM source, final DATA data);
+
+    /**
+     * Should {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor}
+     * throw error when result of process method is empty?
+     *
+     * @return the boolean
+     */
+    boolean isErrorOnEmpty() {
+        return errorOnEmpty;
+    }
+
+    /**
+     * Cast untyped source to type of this case and sends it to actual process method.
+     *
+     * @param source the source
+     * @param data   the data
+     * @return the optional
+     */
+    Optional<TO> processRaw(@Nonnull final Object source, final DATA data) {
+        return process(getType().cast(source), data);
+    }
+
+    /**
+     * Gets type of this convertor case.
+     *
+     * @return the type
+     */
+    Class<FROM> getType() {
+        return type;
+    }
+
+    /**
+     * Gets supported Openflow versions.
+     *
+     * @return the supported versions
+     */
+    List<Short> getSupportedVersions() {
+        return supportedVersions;
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorData.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorData.java
new file mode 100644 (file)
index 0000000..43f8701
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * 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
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
+
+/**
+ * The base class for all convertor data.
+ */
+public abstract class ConvertorData {
+    private short version;
+
+    /**
+     * Instantiates a new Convertor data.
+     *
+     * @param version the version
+     */
+    public ConvertorData(final short version) {
+        this.version = version;
+    }
+
+    /**
+     * Gets Openflow version.
+     *
+     * @return the version
+     */
+    public short getVersion() {
+        return version;
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorProcessor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ConvertorProcessor.java
new file mode 100644 (file)
index 0000000..b42db61
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * 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
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Processes source and return result based on convertor cases added to this processor.
+ *
+ * @param <FROM> the source type
+ * @param <TO>   the result type
+ * @param <DATA> the type of convertor data
+ */
+public class ConvertorProcessor<FROM, TO, DATA extends ConvertorData> {
+    private static final short OFP_VERSION_ALL = 0x00;
+    private static final Logger LOG = LoggerFactory.getLogger(ConvertorProcessor.class);
+
+    private final Map<InjectionKey, ConvertorCase<?, TO, DATA>> conversions = new HashMap<>();
+    private ConvertorCase<?, TO, DATA> defaultCase;
+
+    /**
+     * Add convertor processor case.
+     *
+     * @param processorCase the processor case
+     * @return the convertor processor
+     */
+    public ConvertorProcessor<FROM, TO, DATA> addCase(final ConvertorCase<?, TO, DATA> processorCase) {
+        if (processorCase.getSupportedVersions().isEmpty()) {
+            final InjectionKey key = new InjectionKey(OFP_VERSION_ALL, processorCase.getType());
+            conversions.putIfAbsent(key, processorCase);
+        } else {
+            for (short supportedVersion : processorCase.getSupportedVersions()) {
+                final InjectionKey key = new InjectionKey(supportedVersion, processorCase.getType());
+                conversions.putIfAbsent(key, processorCase);
+            }
+        }
+
+        return this;
+    }
+
+    /**
+     * Process source and return result based on convertor cases, or empty if no match is found.
+     *
+     * @param source the source
+     * @return the optional
+     */
+    public Optional<TO> process(final FROM source) {
+        return process(source, null);
+    }
+
+    /**
+     * Process source and return result based on convertor cases, or empty if no match is found.
+     *
+     * @param source the source
+     * @param data   the data
+     * @return the optional
+     */
+    public Optional<TO> process(final FROM source, final DATA data) {
+        Optional<TO> result = Optional.empty();
+        final short version = data != null ? data.getVersion() : OFP_VERSION_ALL;
+
+        if (source == null) {
+            LOG.trace("Failed to convert null for version {}", version);
+            return result;
+        }
+
+        Class<?> clazz = source.getClass();
+        final Class<?>[] interfaces = clazz.getInterfaces();
+
+        if (interfaces.length > 0) {
+            clazz = interfaces[0];
+        }
+
+        final InjectionKey key = new InjectionKey(version, clazz);
+        ConvertorCase<?, TO, DATA> rule = defaultCase;
+
+        if (conversions.containsKey(key)) {
+            rule = conversions.get(key);
+        }
+
+        if (rule != null) {
+            result = rule.processRaw(source, data);
+
+            if (rule.isErrorOnEmpty() && !result.isPresent()) {
+                LOG.error("Failed to convert {} for version {}", clazz, version);
+            }
+        } else {
+            LOG.trace("Failed to convert {} for version {}", clazz, version);
+        }
+
+        return result;
+    }
+
+    /**
+     * Sets default case, what will be used when we do not find any matching convertor case for source.
+     *
+     * @param defaultCase the default case
+     * @return the default case
+     */
+    public ConvertorProcessor<FROM, TO, DATA> setDefaultCase(final ConvertorCase<?, TO, DATA> defaultCase) {
+        this.defaultCase = defaultCase;
+        return this;
+    }
+}
similarity index 93%
rename from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IPProtocols.java
rename to openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IPProtocols.java
index 2e6a386204ac377cd50f7bd471235f418ecf12b6..caec87b676742533c44f1394c143abda29c58b68 100644 (file)
@@ -1,11 +1,12 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * 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
  */
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
@@ -1,12 +1,12 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc., Brocade, Communications Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * 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
  */
 
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
 
 import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ParametrizedConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/ParametrizedConvertor.java
new file mode 100644 (file)
index 0000000..885d924
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * 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
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
+
+/**
+ * Converts OpenflowJava to MDSal model and vice versa
+ *
+ * @param <FROM> type of source
+ * @param <TO>   type of result
+ * @param <DATA>   type of convertor data
+ */
+public interface ParametrizedConvertor<FROM, TO, DATA extends ConvertorData> {
+
+    /**
+     * Gets type of convertor, used in
+     * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager}.
+     *
+     * @return the type of convertor
+     */
+    Class<?> getType();
+
+    /**
+     * Converts source to result
+     *
+     * @param source source
+     * @param data   convertor data
+     * @return converted source
+     */
+    TO convert(FROM source, DATA data);
+}
index fc798c9fbfcab04c68a9c6d0ea6509caf426b7e8..d1011f3042fcb25b7099c0b6437d20cf0394fe4e 100644 (file)
@@ -8,8 +8,6 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag;
 
-import java.math.BigInteger;
-
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
 
@@ -18,12 +16,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMo
  * @param <E>  type of converted match
  */
 public interface FlowFlagConvertor<E> extends Convertor<FlowModFlags, E> {
+
+    default Class<?> getType() {
+        return FlowModFlags.class;
+    }
     
     /**
      * @param source flow mode flags
-     * @param datapathid  datapath id
      * @return converted match (into OF-API model)
      */
     @Override
-    E convert(FlowModFlags source,BigInteger datapathid);
+    E convert(FlowModFlags source);
 }
index af119b1bd92d2ea04102e53d425b55ea39459311..2dfb2acf854c1d62ceb9c32f7c0be8ef10e9e966 100644 (file)
@@ -8,8 +8,6 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag;
 
-import java.math.BigInteger;
-
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
 
@@ -20,7 +18,7 @@ public class FlowFlagsConvertorImpl implements FlowFlagConvertor<FlowModFlags> {
 
     @Override
     public FlowModFlags convert(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags source, BigInteger datapathid) {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags source) {
     
         FlowModFlags ofFlowModFlags = null;
         if (source != null) {
index 478b0c00c27a900895d3ebefddc9d51f1af8775e..ee5dac9b1d493dde8acad0b53140a9e447075c50 100644 (file)
@@ -8,8 +8,6 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag;
 
-import java.math.BigInteger;
-
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10;
 
@@ -20,7 +18,7 @@ public class FlowFlagsConvertorV10Impl implements FlowFlagConvertor<FlowModFlags
 
     @Override
     public FlowModFlagsV10 convert(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags source, BigInteger datapathid) {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags source) {
     
         FlowModFlagsV10 ofFlowModFlags = null;
         if (source != null) {
index c51761c9e3454be3c0f2098e1bc118988fb39880..0192fffedd5d2e503ee6e7121af2461d7aeb2d4b 100644 (file)
@@ -8,8 +8,6 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 
-import java.math.BigInteger;
-
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 
@@ -18,12 +16,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
  * @param <E>  type of converted match
  */
 public interface MatchConvertor<E> extends Convertor<Match, E> {
+
+    default Class<?> getType() {
+        return Match.class;
+    }
     
     /**
      * @param source match input
-     * @param datapathid datapath id
      * @return converted match (into OF-API model)
      */
     @Override
-    E convert(Match source,BigInteger datapathid);
+    E convert(Match source);
 }
index fd1e7c94ea5ee756ecdf82082029138b52742919..7c326954458b8da17f15872064b70d107629cee4 100644 (file)
@@ -23,8 +23,8 @@ import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionResolvers;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.OFApprovedExperimenterIds;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
@@ -36,8 +36,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetField;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
@@ -94,8 +94,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.Pbb;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainerBuilder;
@@ -155,7 +155,86 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Vlan
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOpBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpShaBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpaBuilder;
@@ -230,7 +309,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
 
     @Override
     public List<MatchEntry> convert(
-            final org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match, final BigInteger datapathid) {
+            final org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match) {
         List<MatchEntry> matchEntryList = new ArrayList<>();
         if (match == null) {
             return matchEntryList;
index 43a46c4121ae661de341f7979376169cee88fae9..70fcc0281298c1b95ab58aab4be7972fb628fce2 100644 (file)
@@ -8,13 +8,11 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 
-import java.math.BigInteger;
 import java.util.Iterator;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
@@ -55,7 +53,7 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
      * @author avishnoi@in.ibm.com
      */
     @Override
-    public MatchV10 convert(final Match match,final BigInteger datapathid) {
+    public MatchV10 convert(final Match match) {
         MatchV10Builder matchBuilder = new MatchV10Builder();
         boolean _dLDST = true;
         boolean _dLSRC = true;
index d104f030f0f77a350a41245ae8676afb3ce3e1c8..557fc1016aabc5917d3a72a61431d2fd73bc304d 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManagerTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManagerTest.java
new file mode 100644 (file)
index 0000000..df20423
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * 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
+ */
+
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ParametrizedConvertor;
+
+public class ConvertorManagerTest {
+    private static final String CONVERT_INPUT = "10";
+    private static final Integer CONVERT_EXPECTED_RESULT = 10;
+    private static final Short P_CONVERT_INPUT = 0x01;
+    private static final String P_CONVERT_RESULT = "12";
+    private static final Short P_CONVERT_VERSION = 0x02;
+
+    private Convertor<CharSequence, Integer> convertor;
+    private ParametrizedConvertor<Number, String, TestConvertorData> parametrizedConvertor;
+
+    @Before
+    public void setUp() throws Exception {
+        convertor = new Convertor<CharSequence, Integer>() {
+            @Override
+            public Class<?> getType() {
+                return CharSequence.class;
+            }
+
+            @Override
+            public Integer convert(CharSequence source) {
+                return Integer.valueOf(source.toString());
+            }
+        };
+
+        parametrizedConvertor = new ParametrizedConvertor<Number, String, TestConvertorData>() {
+            @Override
+            public Class<?> getType() {
+                return Number.class;
+            }
+
+            @Override
+            public String convert(Number source, TestConvertorData testConvertorData) {
+                return String.valueOf(source) + String.valueOf(testConvertorData.getVersion());
+            }
+        };
+
+        ConvertorManager.getInstance().registerConvertor(convertor);
+        ConvertorManager.getInstance().registerConvertor(parametrizedConvertor);
+    }
+
+    @Test
+    public void testRegisterConvertor() throws Exception {
+        boolean success = ConvertorManager.getInstance().registerConvertor(convertor);
+        assertFalse("Convertor should be already registered", success);
+    }
+
+    @Test
+    public void testRegisterParametrizedConvertor() throws Exception {
+        boolean success = ConvertorManager.getInstance().registerConvertor(parametrizedConvertor);
+        assertFalse("Parametrized convertor should be already registered", success);
+    }
+
+    @Test
+    public void testConvert() throws Exception {
+        final Optional<Integer> result = ConvertorManager.getInstance().convert(CONVERT_INPUT);
+
+        assertTrue("Failed to convert string to integer", result.isPresent());
+        assertEquals("Wrong conversion between string and integer", CONVERT_EXPECTED_RESULT, result.get());
+    }
+
+    @Test
+    public void testCollectionConvert() throws Exception {
+        final Optional<List<Boolean>> result = ConvertorManager.getInstance().convert(
+                Collections.singletonList(Boolean.TRUE));
+
+        assertFalse("Convertor result should be empty on wrong convertor", result.isPresent());
+    }
+
+    @Test
+    public void testEmptyCollectionConvert() throws Exception {
+        final Optional<List<Boolean>> result = ConvertorManager.getInstance().convert(Collections.emptyList());
+
+        assertFalse("Convertor result should be empty on empty collection", result.isPresent());
+    }
+
+    @Test
+    public void testFailedConvert() throws Exception {
+        final Optional<Integer> result = ConvertorManager.getInstance().convert(null);
+
+        assertFalse("Convertor result should be empty on null input", result.isPresent());
+    }
+
+    @Test
+    public void testNotFoundConvert() throws Exception {
+        final Optional<Boolean> result = ConvertorManager.getInstance().convert(Boolean.TRUE);
+
+        assertFalse("Convertor result should be empty on wrong input", result.isPresent());
+    }
+
+    @Test
+    public void testParametrizedConvert() throws Exception {
+        final TestConvertorData data = new TestConvertorData(P_CONVERT_VERSION);
+        final Optional<String> result = ConvertorManager.getInstance().convert(P_CONVERT_INPUT, data);
+
+        assertTrue("Failed to convert short with data to string", result.isPresent());
+        assertEquals("Wrong conversion between short with data and string", P_CONVERT_RESULT, result.get());
+    }
+
+    @Test
+    public void testCollectionParametrizedConvert() throws Exception {
+        final TestConvertorData data = new TestConvertorData(P_CONVERT_VERSION);
+        final Optional<List<Boolean>> result = ConvertorManager.getInstance().convert(
+                Collections.singletonList(Boolean.TRUE), data);
+
+        assertFalse("Convertor result should be empty on wrong convertor", result.isPresent());
+    }
+
+    @Test
+    public void testEmptyCollectionParametrizedConvert() throws Exception {
+        final TestConvertorData data = new TestConvertorData(P_CONVERT_VERSION);
+        final Optional<List<Boolean>> result = ConvertorManager.getInstance().convert(Collections.emptyList(), data);
+
+        assertFalse("Convertor result should be empty on empty collection", result.isPresent());
+    }
+
+    @Test
+    public void testFailedParametrizedConvert() throws Exception {
+        final TestConvertorData data = new TestConvertorData(P_CONVERT_VERSION);
+        final Optional<String> result = ConvertorManager.getInstance().convert(null, data);
+
+        assertFalse("Parametrized convertor result should be empty on null input", result.isPresent());
+    }
+
+    @Test
+    public void testNotFoundParametrizedConvert() throws Exception {
+        final TestConvertorData data = new TestConvertorData(P_CONVERT_VERSION);
+        final Optional<Boolean> result = ConvertorManager.getInstance().convert(Boolean.TRUE, data);
+
+        assertFalse("Parametrized convertor result should be empty on wrong input", result.isPresent());
+    }
+
+    private class TestConvertorData extends ConvertorData {
+        TestConvertorData(short version) {
+            super(version);
+        }
+    }
+}
\ No newline at end of file
index 5ec41c55f43552508a03c3af9ba5973a83e36275..d3f51e9cc421e3451eb3f6ef9c08c675fde7bb76 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;
 
-import java.math.BigInteger;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -52,7 +51,7 @@ public class ActionSetNwDstReactorTest {
         for (final Address address : addresses) {
             final SetNwDstActionCase action = prepareSetNwDstActionCase(address);
             ActionSetNwDstReactor.getInstance().convert(action,
-                    OFConstants.OFP_VERSION_1_3, target, BigInteger.ONE);
+                    OFConstants.OFP_VERSION_1_3, target);
             final Object mEntry = target.getActionChoice();
 /*
             Assert.assertNotNull(mEntry);
@@ -89,12 +88,12 @@ public class ActionSetNwDstReactorTest {
 
             if (address instanceof Ipv4) {
                 ActionSetNwDstReactor.getInstance().convert(action,
-                        OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
+                        OFConstants.OFP_VERSION_1_0, target);
 //                Assert.assertNotNull(target.getAugmentation(IpAddressAction.class).getIpAddress());
             } else {
                 try {
                     ActionSetNwDstReactor.getInstance().convert(action,
-                            OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
+                            OFConstants.OFP_VERSION_1_0, target);
                     Assert.fail("address of this type must not pass the reactor: " + address.getClass().getName());
                 } catch (final Exception e) {
                     //expected
index b326b0f96002837a7813ef7aad3436d7d3f47b53..fc15fb46c9ef221567b61d75e5b437f0c443167f 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;
 
-import java.math.BigInteger;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -53,7 +52,7 @@ public class ActionSetNwSrcReactorTest {
         for (final Address address : addresses) {
             final SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
             ActionSetNwSrcReactor.getInstance().convert(action,
-                    OFConstants.OFP_VERSION_1_3, target, BigInteger.ONE);
+                    OFConstants.OFP_VERSION_1_3, target);
 /*
             MatchEntry mEntry = target.getActionChoice() getAugmentation(OxmFieldsAction.class).getMatchEntry().get(0);
             Assert.assertNotNull(mEntry);
@@ -90,11 +89,11 @@ public class ActionSetNwSrcReactorTest {
 
             if (address instanceof Ipv4) {
                 ActionSetNwSrcReactor.getInstance().convert(action,
-                        OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
+                        OFConstants.OFP_VERSION_1_0, target);
             } else {
                 try {
                     ActionSetNwSrcReactor.getInstance().convert(action,
-                            OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
+                            OFConstants.OFP_VERSION_1_0, target);
                     Assert.fail("address of this type must not pass the reactor: " + address.getClass().getName());
                 } catch (final Exception e) {
                     //expected
@@ -12,6 +12,7 @@ import java.util.Arrays;
 import org.junit.Assert;\r
 import org.junit.Test;\r
 import org.opendaylight.openflowjava.util.ByteBufUtils;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;\r
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;\r
index 0e2c685b5a2ef3e6a04d8982eb78b8c088c64f6d..ac54c827bbc6fa231e466fa08cd8884d6f8ff9ce 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag;
 
-import java.math.BigInteger;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -43,7 +42,7 @@ public class FlowFlagReactorTest {
         for (FlowModFlags fFlag : flowFlags) {
             target.setFlags(null);
             FlowFlagReactor.getInstance().convert(fFlag,
-                    OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
+                    OFConstants.OFP_VERSION_1_3, target);
             Assert.assertNotNull(target.getFlags());
         }
     }
@@ -57,7 +56,7 @@ public class FlowFlagReactorTest {
         for (FlowModFlags fFlag : flowFlags) {
             target.setFlagsV10(null);
             FlowFlagReactor.getInstance().convert(fFlag,
-                    OFConstants.OFP_VERSION_1_0, target,BigInteger.valueOf(1));
+                    OFConstants.OFP_VERSION_1_0, target);
             Assert.assertNotNull(target.getFlagsV10());
         }
     }
index f6e9ba27e59ab946bd8ed1bfb39172f0b5f89506..09da99443dbd04352634b1a7882fd0d4bc89b738 100644 (file)
@@ -151,22 +151,22 @@ public class MatchConvertorImpl2Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testEmptyAndNullInput() {\r
         MatchBuilder builder = new MatchBuilder();\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(null, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(null);\r
         Assert.assertEquals("Wrong entries size", 0, entries.size());\r
 \r
-        entries = convertor.convert(match, new BigInteger("42"));\r
+        entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 0, entries.size());\r
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testConversion() {\r
@@ -228,7 +228,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 24, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, InPort.class, false);\r
@@ -338,7 +338,7 @@ public class MatchConvertorImpl2Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testIpv4MatchArbitraryBitMaskwithNoMask(){\r
@@ -349,7 +349,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
 \r
         MatchEntry entry = entries.get(0);\r
@@ -361,7 +361,7 @@ public class MatchConvertorImpl2Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testIpv4MatchArbitraryBitMaskwithMask(){\r
@@ -374,7 +374,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
 \r
         MatchEntry entry = entries.get(0);\r
@@ -386,7 +386,7 @@ public class MatchConvertorImpl2Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testUdpMatchConversion() {\r
@@ -397,7 +397,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer4Match(udpMatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, UdpSrc.class, false);\r
@@ -410,7 +410,7 @@ public class MatchConvertorImpl2Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testSctpMatchConversion() {\r
@@ -421,7 +421,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer4Match(sctpMatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, SctpSrc.class, false);\r
@@ -434,7 +434,7 @@ public class MatchConvertorImpl2Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testArpMatchConversion() {\r
@@ -452,7 +452,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(arpBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 5, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, ArpOp.class, false);\r
@@ -477,7 +477,7 @@ public class MatchConvertorImpl2Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testArpMatchConversionWithMasks() {\r
@@ -497,7 +497,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(arpBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 4, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         entry = entries.get(0);\r
@@ -527,7 +527,7 @@ public class MatchConvertorImpl2Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testIpv6MatchConversion() {\r
@@ -547,7 +547,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6Builder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 7, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         /* Due to conversion ambiguities, we always get "has mask" because \r
@@ -583,7 +583,7 @@ public class MatchConvertorImpl2Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testIpv6MatchConversionWithMasks() {\r
@@ -594,7 +594,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6Builder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, Ipv6Src.class, true);\r
@@ -612,7 +612,7 @@ public class MatchConvertorImpl2Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testIpv6ExtHeaderConversion() {\r
@@ -625,7 +625,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6Builder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 1, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, Ipv6Exthdr.class, true);\r
@@ -636,7 +636,7 @@ public class MatchConvertorImpl2Test {
     }\r
 \r
     /**\r
-     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match, java.math.BigInteger)}\r
+     * Test {@link MatchConvertorImpl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}\r
      */\r
     @Test\r
     public void testConversionWithMasks() {\r
@@ -677,7 +677,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 8, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, Metadata.class, true);\r
@@ -745,7 +745,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
+        List<MatchEntry> entries = convertor.convert(match);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
 \r
         MatchEntry entry = entries.get(0);\r
index 223988bb038b8c19d7cbf5b09c32783a086f89bb..f454f4de004b906415773d67710c47de5205a7c2 100644 (file)
@@ -68,7 +68,7 @@ public class MatchConvertorV10ImplTest {
      * Test method for {@link MatchConvertorV10Impl#convert(Match,BigInteger)}
      */
     public void testConvert() {
-        MatchV10 matchV10 = matchConvertorV10.convert(createL4UdpMatch().build(), dataPathId);
+        MatchV10 matchV10 = matchConvertorV10.convert(createL4UdpMatch().build());
 
         assertEquals(ZERO_MAC, matchV10.getDlDst());
         assertEquals(FF_MAC, matchV10.getDlSrc());
@@ -83,24 +83,24 @@ public class MatchConvertorV10ImplTest {
         assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpSrc().intValue());
         assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpDst().intValue());
 
-        matchV10 = matchConvertorV10.convert(createL4TcpMatch().build(), dataPathId);
+        matchV10 = matchConvertorV10.convert(createL4TcpMatch().build());
         assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpSrc().intValue());
         assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpDst().intValue());
 
-        matchV10 = matchConvertorV10.convert(createVlanTcpMatch().build(), dataPathId);
+        matchV10 = matchConvertorV10.convert(createVlanTcpMatch().build());
         assertEquals(DEFAULT_VLAN_ID.getValue().intValue(), matchV10.getDlVlan().intValue());
 
     }
 
     /**
      * ICMPv4 match test for
-     * {@link MatchConvertorV10Impl#convert(Match,BigInteger)}.
+     * {@link MatchConvertorV10Impl#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)}.
      */
     @Test
     public void testConvertIcmpv4() {
         MatchBuilder matchBuilder = createMatchBuilderWithDefaults();
         Match match = matchBuilder.build();
-        MatchV10 matchV10 = matchConvertorV10.convert(match, dataPathId);
+        MatchV10 matchV10 = matchConvertorV10.convert(match);
         Integer zero = 0;
         boolean wcTpSrc = true;
         boolean wcTpDst = true;
@@ -131,7 +131,7 @@ public class MatchConvertorV10ImplTest {
             wcTpDst, wcTpSrc);
         match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).
             build();
-        matchV10 = matchConvertorV10.convert(match, dataPathId);
+        matchV10 = matchConvertorV10.convert(match);
         assertEquals(ZERO_MAC, matchV10.getDlDst());
         assertEquals(FF_MAC, matchV10.getDlSrc());
         assertEquals(0, matchV10.getDlType().intValue());
@@ -157,7 +157,7 @@ public class MatchConvertorV10ImplTest {
             wcTpDst, wcTpSrc);
         match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).
             build();
-        matchV10 = matchConvertorV10.convert(match, dataPathId);
+        matchV10 = matchConvertorV10.convert(match);
         assertEquals(ZERO_MAC, matchV10.getDlDst());
         assertEquals(FF_MAC, matchV10.getDlSrc());
         assertEquals(0, matchV10.getDlType().intValue());
@@ -185,7 +185,7 @@ public class MatchConvertorV10ImplTest {
             wcTpDst, wcTpSrc);
         match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).
             build();
-        matchV10 = matchConvertorV10.convert(match, dataPathId);
+        matchV10 = matchConvertorV10.convert(match);
         assertEquals(ZERO_MAC, matchV10.getDlDst());
         assertEquals(FF_MAC, matchV10.getDlSrc());
         assertEquals(0, matchV10.getDlType().intValue());
index e32dfe53b06963f815f14e8344d0f20f3d25ff0e..e2d7de2439dd85f2bc04e9613a97fa2079c23950 100644 (file)
@@ -18,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
-import java.math.BigInteger;
 
 /**
  * match conversion and injection test
@@ -47,7 +46,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV13_flow() {
         FlowModInputBuilder target = new FlowModInputBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_3, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_3, target);
         Assert.assertNotNull(target.getMatch());
     }
 
@@ -58,7 +57,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV10_flow() {
         FlowModInputBuilder target = new FlowModInputBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_0, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_0, target);
         Assert.assertNotNull(target.getMatchV10());
     }
 
@@ -70,7 +69,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV13_mpRequestFlow() {
         MultipartRequestFlowBuilder target = new MultipartRequestFlowBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_3, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_3, target);
         Assert.assertNotNull(target.getMatch());
     }
 
@@ -81,7 +80,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV10_mpRequestFlow() {
         MultipartRequestFlowBuilder target = new MultipartRequestFlowBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_0, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_0, target);
         Assert.assertNotNull(target.getMatchV10());
     }
 
@@ -89,7 +88,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV10_null() {
         MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
         MatchReactor.getInstance().convert(null,
-                OFConstants.OFP_VERSION_1_0, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_0, target);
         Assert.assertNotNull(target.getMatchV10());
     }
 
@@ -100,7 +99,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV13_mpRequestAggregate() {
         MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_3, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_3, target);
         Assert.assertNotNull(target.getMatch());
     }
 
@@ -108,7 +107,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV13_null() {
         MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
         MatchReactor.getInstance().convert(null,
-                OFConstants.OFP_VERSION_1_3, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_3, target);
         Assert.assertNotNull(target.getMatch());
         Assert.assertEquals(0, target.getMatch().getMatchEntry().size());
     }
@@ -120,7 +119,7 @@ public class MatchReactorTest {
     public void testMatchConvertorV10_mpRequestAggregate() {
         MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
         MatchReactor.getInstance().convert(matchBuilder.build(),
-                OFConstants.OFP_VERSION_1_0, target, BigInteger.valueOf(1));
+                OFConstants.OFP_VERSION_1_0, target);
         Assert.assertNotNull(target.getMatchV10());
     }