From fa4138ed29b61d30b529639c646016d7ce864de2 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 26 Mar 2015 15:07:24 +0100 Subject: [PATCH] Action experimenterId fix Change-Id: Idebe6abbaf24977209857c5d47efe67717e6a027 Signed-off-by: Michal Polkorab --- .../src/main/yang/openflow-action.yang | 3 +++ .../impl/util/TypeKeyMakerFactory.java | 14 ++++---------- .../impl/util/TypeKeyMakerFactoryTest.java | 19 ++++++------------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/openflow-protocol-api/src/main/yang/openflow-action.yang b/openflow-protocol-api/src/main/yang/openflow-action.yang index 4655d15a..576a7f45 100644 --- a/openflow-protocol-api/src/main/yang/openflow-action.yang +++ b/openflow-protocol-api/src/main/yang/openflow-action.yang @@ -31,6 +31,9 @@ grouping actions-grouping { list action { uses action-grouping; + leaf experimenter-id { + type oft:experimenter-id; + } } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index e74ac05f..e954a436 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.util; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -64,15 +63,10 @@ public abstract class TypeKeyMakerFactory { return new AbstractTypeKeyMaker(version) { @Override public MessageTypeKey make(Action entry) { - if (entry.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow - .augments.rev150225.action.container.action.choice.ExperimenterIdCase) { - org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action - .container.action.choice.ExperimenterIdCase expIdCase = (org.opendaylight.yang.gen.v1.urn - .opendaylight.openflow.augments.rev150225.action.container.action.choice - .ExperimenterIdCase) entry.getActionChoice(); - return new ExperimenterActionSerializerKey(getVersion(), - expIdCase.getExperimenter().getExperimenter().getValue(), - expIdCase.getExperimenter().getSubType()); + if (entry.getExperimenterId() != null) { + return new ActionSerializerKey<>(getVersion(), + (Class) entry.getActionChoice().getImplementedInterface(), + entry.getExperimenterId().getValue()); } return new ActionSerializerKey<>(getVersion(), (Class) entry.getActionChoice().getImplementedInterface(), null); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java index dd766389..c6278285 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -11,7 +11,6 @@ package org.opendaylight.openflowjava.protocol.impl.util; import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -20,6 +19,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; @@ -69,22 +70,14 @@ public class TypeKeyMakerFactoryTest { Assert.assertNotNull("Null keyMaker", keyMaker); org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder builder = new ActionBuilder(); - org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice - .ExperimenterIdCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments - .rev150225.action.container.action.choice.ExperimenterIdCaseBuilder(); - org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice - .experimenter.id._case.ExperimenterBuilder expIdBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight - .openflow.augments.rev150225.action.container.action.choice.experimenter.id._case.ExperimenterBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - expIdBuilder.setSubType(ActionSubtypeClass.class); - caseBuilder.setExperimenter(expIdBuilder.build()); - builder.setActionChoice(caseBuilder.build()); + builder.setExperimenterId(new ExperimenterId(42L)); + builder.setActionChoice(new CopyTtlInCaseBuilder().build()); Action action = builder.build(); MessageTypeKey key = keyMaker.make(action); Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, - ActionSubtypeClass.class), key); + Assert.assertEquals("Wrong key", new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, + CopyTtlInCase.class, 42L), key); } /** -- 2.36.6