use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder in project openflowplugin by opendaylight.
the class FlowStatsResponseConvertorTest method testToSALInstruction.
/**
* Test method for {@link FlowInstructionResponseConvertor#convert(List, VersionConvertorData)} }.
*/
@Test
public void testToSALInstruction() {
List<Instruction> instructionsList = new ArrayList<>();
InstructionBuilder instructionBuilder = new InstructionBuilder();
for (int i = 0; i < PRESET_COUNT; i++) {
ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
ActionBuilder actionBuilder = new ActionBuilder();
List<Action> actions = new ArrayList<>();
for (int j = 0; j < PRESET_COUNT; j++) {
actions.add(actionBuilder.build());
}
applyActionsBuilder.setAction(actions);
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
instructionBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
instructionsList.add(instructionBuilder.build());
}
Instructions instructions;
VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
instructions = convert(instructionsList, data);
assertNotNull(instructions);
assertEquals(PRESET_COUNT, instructions.getInstruction().size());
instructionsList = new ArrayList<>();
for (int i = 0; i < PRESET_COUNT; i++) {
GotoTableCaseBuilder gotoTableCaseBuilder = new GotoTableCaseBuilder();
GotoTableBuilder gotoTableBuilder = new GotoTableBuilder();
gotoTableBuilder.setTableId((short) i);
gotoTableCaseBuilder.setGotoTable(gotoTableBuilder.build());
instructionBuilder.setInstructionChoice(gotoTableCaseBuilder.build());
instructionsList.add(instructionBuilder.build());
}
instructions = convert(instructionsList, data);
assertNotNull(instructions);
assertEquals(PRESET_COUNT, instructions.getInstruction().size());
instructionsList = new ArrayList<>();
for (int i = 0; i < PRESET_COUNT; i++) {
MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
MeterBuilder meterBuilder = new MeterBuilder();
meterBuilder.setMeterId((long) i);
meterCaseBuilder.setMeter(meterBuilder.build());
instructionBuilder.setInstructionChoice(meterCaseBuilder.build());
instructionsList.add(instructionBuilder.build());
}
instructions = convert(instructionsList, data);
assertNotNull(instructions);
assertEquals(PRESET_COUNT, instructions.getInstruction().size());
instructionsList = new ArrayList<>();
for (int i = 0; i < PRESET_COUNT; i++) {
WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
ActionBuilder actionBuilder = new ActionBuilder();
List<Action> actions = new ArrayList<>();
for (int j = 0; j < PRESET_COUNT; j++) {
actions.add(actionBuilder.build());
}
writeActionsBuilder.setAction(actions);
writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
instructionBuilder.setInstructionChoice(writeActionsCaseBuilder.build());
instructionsList.add(instructionBuilder.build());
}
instructions = convert(instructionsList, data);
assertNotNull(instructions);
assertEquals(PRESET_COUNT, instructions.getInstruction().size());
instructionsList = new ArrayList<>();
for (int i = 0; i < PRESET_COUNT; i++) {
ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
instructionBuilder.setInstructionChoice(clearActionsCaseBuilder.build());
instructionsList.add(instructionBuilder.build());
}
instructions = convert(instructionsList, data);
assertNotNull(instructions);
int instructionSize = instructions.getInstruction().size();
assertEquals(PRESET_COUNT, instructionSize);
instructionsList = new ArrayList<>();
for (int i = 0; i < PRESET_COUNT; i++) {
WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
metadataBuilder.setMetadata(BigInteger.TEN.setBit(i).toByteArray());
metadataBuilder.setMetadataMask(BigInteger.ONE.setBit(i).toByteArray());
metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
instructionBuilder.setInstructionChoice(metadataCaseBuilder.build());
instructionsList.add(instructionBuilder.build());
}
instructions = convert(instructionsList, data);
assertNotNull(instructions);
assertEquals(PRESET_COUNT, instructions.getInstruction().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder in project openflowplugin by opendaylight.
the class ClearActionsInstructionDeserializer method deserializeHeader.
@Override
public Instruction deserializeHeader(ByteBuf input) {
InstructionBuilder builder = new InstructionBuilder();
input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
builder.setInstructionChoice(new ClearActionsCaseBuilder().build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder in project openflowplugin by opendaylight.
the class TypeKeyMakerFactoryTest method testExperimenterInstructionKeyMaker.
/**
* Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)}.
*/
@Test
public void testExperimenterInstructionKeyMaker() {
TypeKeyMaker<Instruction> keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID);
Assert.assertNotNull("Null keyMaker", keyMaker);
InstructionBuilder builder = new InstructionBuilder();
builder.setExperimenterId(new ExperimenterId(42L));
builder.setInstructionChoice(new ClearActionsCaseBuilder().build());
Instruction instruction = builder.build();
MessageTypeKey<?> key = keyMaker.make(instruction);
Assert.assertNotNull("Null key", key);
Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ClearActionsCase.class, 42L), key);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder in project openflowplugin by opendaylight.
the class ClearActionsInstructionSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Instruction instruction = new ClearActionsCaseBuilder().setClearActions(new ClearActionsBuilder().build()).build();
assertInstruction(instruction, out -> out.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder in project openflowplugin by opendaylight.
the class ClearActionsInstructionDeserializer method deserialize.
@Override
public Instruction deserialize(ByteBuf message) {
processHeader(message);
message.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
return new ClearActionsCaseBuilder().setClearActions(new ClearActionsBuilder().build()).build();
}
Aggregations