* 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.flow;
-import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import org.junit.Assert;
import org.junit.Before;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.AbstractAugmentable;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
/**
* Unit tests for flow conversion.
public void test() {
RemoveFlowInputBuilder flowBuilder = new RemoveFlowInputBuilder();
flowBuilder.setBarrier(false);
- flowBuilder.setCookie(new FlowCookie(new BigInteger("4")));
- flowBuilder.setCookieMask(new FlowCookie(new BigInteger("5")));
- flowBuilder.setTableId((short) 6);
+ flowBuilder.setCookie(new FlowCookie(Uint64.valueOf(4)));
+ flowBuilder.setCookieMask(new FlowCookie(Uint64.valueOf(5)));
+ flowBuilder.setTableId(Uint8.valueOf(6));
flowBuilder.setStrict(true);
- flowBuilder.setIdleTimeout(50);
- flowBuilder.setHardTimeout(500);
- flowBuilder.setPriority(40);
- flowBuilder.setBufferId(18L);
- flowBuilder.setOutPort(new BigInteger("65535"));
- flowBuilder.setOutGroup(5000L);
+ flowBuilder.setIdleTimeout(Uint16.valueOf(50));
+ flowBuilder.setHardTimeout(Uint16.valueOf(500));
+ flowBuilder.setPriority(Uint16.valueOf(40));
+ flowBuilder.setBufferId(Uint32.valueOf(18));
+ flowBuilder.setOutPort(Uint64.valueOf(65535));
+ flowBuilder.setOutGroup(Uint32.valueOf(5000));
flowBuilder.setFlags(null);
flowBuilder.setMatch(null);
RemoveFlowInput flow = flowBuilder.build();
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
- data.setDatapathId(new BigInteger("42"));
+ data.setDatapathId(Uint64.valueOf(42));
List<FlowModInputBuilder> flowMod = convert(flow, data);
Assert.assertEquals("Wrong match",
"org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType",
flowMod.get(0).getMatch().getType().getName());
- Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().getMatchEntry().size());
+ Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().nonnullMatchEntry().size());
}
/**
UpdatedFlow flow = flowBuilder.build();
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
- data.setDatapathId(new BigInteger("42"));
+ data.setDatapathId(Uint64.valueOf(42));
List<FlowModInputBuilder> flowMod = convert(flow, data);
InstructionBuilder instructionBuilder = new InstructionBuilder();
GoToTableCaseBuilder goToCaseBuilder = new GoToTableCaseBuilder();
GoToTableBuilder goToBuilder = new GoToTableBuilder();
- goToBuilder.setTableId((short) 1);
+ goToBuilder.setTableId(Uint8.ONE);
goToCaseBuilder.setGoToTable(goToBuilder.build());
instructionBuilder.setInstruction(goToCaseBuilder.build());
instructionBuilder.setOrder(0);
instructionBuilder = new InstructionBuilder();
WriteMetadataCaseBuilder metaCaseBuilder = new WriteMetadataCaseBuilder();
WriteMetadataBuilder metaBuilder = new WriteMetadataBuilder();
- metaBuilder.setMetadata(new BigInteger("2"));
- metaBuilder.setMetadataMask(new BigInteger("3"));
+ metaBuilder.setMetadata(Uint64.valueOf(2));
+ metaBuilder.setMetadataMask(Uint64.valueOf(3));
metaCaseBuilder.setWriteMetadata(metaBuilder.build());
instructionBuilder.setInstruction(metaCaseBuilder.build());
instructionBuilder.setOrder(1);
instructionBuilder = new InstructionBuilder();
WriteActionsCaseBuilder writeCaseBuilder = new WriteActionsCaseBuilder();
WriteActionsBuilder writeBuilder = new WriteActionsBuilder();
- List<Action> actions = new ArrayList<>();
- writeBuilder.setAction(actions);
+ writeBuilder.setAction(Map.of());
writeCaseBuilder.setWriteActions(writeBuilder.build());
instructionBuilder.setInstruction(writeCaseBuilder.build());
instructionBuilder.setOrder(2);
instructionBuilder = new InstructionBuilder();
ApplyActionsCaseBuilder applyCaseBuilder = new ApplyActionsCaseBuilder();
ApplyActionsBuilder applyBuilder = new ApplyActionsBuilder();
- actions = new ArrayList<>();
- applyBuilder.setAction(actions);
+ applyBuilder.setAction(Map.of());
applyCaseBuilder.setApplyActions(applyBuilder.build());
instructionBuilder.setInstruction(applyCaseBuilder.build());
instructionBuilder.setOrder(3);
instructionBuilder = new InstructionBuilder();
ClearActionsCaseBuilder clearCaseBuilder = new ClearActionsCaseBuilder();
ClearActionsBuilder clearBuilder = new ClearActionsBuilder();
- actions = new ArrayList<>();
- clearBuilder.setAction(actions);
+ clearBuilder.setAction(Map.of());
clearCaseBuilder.setClearActions(clearBuilder.build());
instructionBuilder.setInstruction(clearCaseBuilder.build());
instructionBuilder.setOrder(4);
instructionBuilder = new InstructionBuilder();
MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
MeterBuilder meterBuilder = new MeterBuilder();
- meterBuilder.setMeterId(new MeterId(5L));
+ meterBuilder.setMeterId(new MeterId(Uint32.valueOf(5)));
meterCaseBuilder.setMeter(meterBuilder.build());
instructionBuilder.setInstruction(meterCaseBuilder.build());
instructionBuilder.setOrder(5);
AddFlowInput flow = flowBuilder.build();
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
- data.setDatapathId(new BigInteger("42"));
+ data.setDatapathId(Uint64.valueOf(42));
List<FlowModInputBuilder> flowMod = convert(flow, data);
Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());
.grouping.Instruction instruction = flowMod.get(0).getInstruction().get(0);
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ ".instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase",
- instruction.getInstructionChoice().getImplementedInterface().getName());
+ instruction.getInstructionChoice().implementedInterface().getName());
GotoTableCase gotoTableCase = (GotoTableCase) instruction.getInstructionChoice();
Assert.assertEquals("Wrong table id", 1, gotoTableCase.getGotoTable().getTableId().intValue());
instruction = flowMod.get(0).getInstruction().get(1);
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ ".instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase",
- instruction.getInstructionChoice().getImplementedInterface().getName());
+ instruction.getInstructionChoice().implementedInterface().getName());
WriteMetadataCase writeMetadataCase = (WriteMetadataCase) instruction.getInstructionChoice();
Assert.assertArrayEquals("Wrong metadata", new byte[]{0, 0, 0, 0, 0, 0, 0, 2},
writeMetadataCase.getWriteMetadata().getMetadata());
instruction = flowMod.get(0).getInstruction().get(2);
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ ".instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase",
- instruction.getInstructionChoice().getImplementedInterface().getName());
+ instruction.getInstructionChoice().implementedInterface().getName());
WriteActionsCase writeActionsCase = (WriteActionsCase) instruction.getInstructionChoice();
- Assert.assertEquals("Wrong actions size", 0, writeActionsCase.getWriteActions().getAction().size());
+ Assert.assertEquals("Wrong actions size", 0, writeActionsCase.getWriteActions().nonnullAction().size());
instruction = flowMod.get(0).getInstruction().get(3);
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ ".instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase",
- instruction.getInstructionChoice().getImplementedInterface().getName());
+ instruction.getInstructionChoice().implementedInterface().getName());
ApplyActionsCase applyActionsCase = (ApplyActionsCase) instruction.getInstructionChoice();
- Assert.assertEquals("Wrong actions size", 0, applyActionsCase.getApplyActions().getAction().size());
+ Assert.assertEquals("Wrong actions size", 0, applyActionsCase.getApplyActions().nonnullAction().size());
instruction = flowMod.get(0).getInstruction().get(4);
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ ".instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase",
- instruction.getInstructionChoice().getImplementedInterface().getName());
+ instruction.getInstructionChoice().implementedInterface().getName());
instruction = flowMod.get(0).getInstruction().get(5);
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ ".instruction.rev130731.instruction.grouping.instruction.choice.MeterCase",
- instruction.getInstructionChoice().getImplementedInterface().getName());
+ instruction.getInstructionChoice().implementedInterface().getName());
MeterCase meterCase = (MeterCase) instruction.getInstructionChoice();
Assert.assertEquals("Wrong meter id", 5, meterCase.getMeter().getMeterId().intValue());
}
MockFlow mockFlow = new MockFlow();
Action action1 = createAction(
new SetVlanIdActionCaseBuilder().setSetVlanIdAction(
- new SetVlanIdActionBuilder().setVlanId(new VlanId(10)).build())
+ new SetVlanIdActionBuilder().setVlanId(new VlanId(Uint16.TEN)).build())
.build(),
0);
mockFlow.setInstructions(toApplyInstruction(Collections.singletonList(action1)));
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
- data.setDatapathId(BigInteger.ONE);
+ data.setDatapathId(Uint64.ONE);
List<FlowModInputBuilder> flowModInputBuilders = convert(mockFlow, data);
}
- private List<FlowModInputBuilder> convert(Flow flow, VersionDatapathIdConvertorData data) {
+ private List<FlowModInputBuilder> convert(final Flow flow, final VersionDatapathIdConvertorData data) {
Optional<List<FlowModInputBuilder>> flowModOptional = convertorManager.convert(flow, data);
Assert.assertTrue("Flow convertor not found", flowModOptional.isPresent());
return flowModOptional.get();
}
private static EthernetMatch createEthernetMatch() {
- EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
- ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(33024L)).build());
- return ethernetMatchBuilder.build();
+ return new EthernetMatchBuilder()
+ .setEthernetType(new EthernetTypeBuilder().setType(new EtherType(Uint32.valueOf(33024))).build())
+ .build();
}
private static Instructions toApplyInstruction(
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions) {
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list
+ .Action> actions) {
return new InstructionsBuilder().setInstruction(Collections.singletonList(new InstructionBuilder().setOrder(0)
.setInstruction(new ApplyActionsCaseBuilder()
.setApplyActions(new ApplyActionsBuilder().setAction(actions).build()).build())
.build())).build();
}
- private static class MockFlow implements AddFlowInput {
+ private static class MockFlow extends AbstractAugmentable<AddFlowInput> implements AddFlowInput {
private Instructions instructions;
private Match match;
this.match = match;
}
-
@Override
public FlowRef getFlowRef() {
return null;
}
- @Override
- public <E extends Augmentation<AddFlowInput>> E augmentation(final Class<E> augmentationType) {
- return null;
- }
-
@Override
public FlowTableRef getFlowTable() {
return null;
}
@Override
- public Long getBufferId() {
+ public Uint32 getBufferId() {
return null;
}
@Override
- public BigInteger getOutPort() {
+ public Uint64 getOutPort() {
return null;
}
@Override
- public Long getOutGroup() {
+ public Uint32 getOutGroup() {
return null;
}
}
@Override
- public Boolean isInstallHw() {
+ public Boolean getInstallHw() {
return null;
}
@Override
- public Boolean isBarrier() {
+ public Boolean getBarrier() {
return null;
}
@Override
- public Boolean isStrict() {
+ public Boolean getStrict() {
return null;
}
@Override
- public Integer getPriority() {
+ public Uint16 getPriority() {
return null;
}
@Override
- public Integer getIdleTimeout() {
+ public Uint16 getIdleTimeout() {
return null;
}
@Override
- public Integer getHardTimeout() {
+ public Uint16 getHardTimeout() {
return null;
}
}
@Override
- public Short getTableId() {
+ public Uint8 getTableId() {
return null;
}
public Uri getTransactionUri() {
return null;
}
-
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- return Flow.class;
- }
}
}