use of org.onosproject.mapping.instructions.UnicastMappingInstruction in project onos by opennetworkinglab.
the class MappingInstructionCodecTest method testMappingInstructionDecode.
/**
* Tests the decoding of mapping instruction from JSON object.
*
* @throws IOException if processing the resource fails
*/
@Test
public void testMappingInstructionDecode() throws IOException {
UnicastMappingInstruction instruction = (UnicastMappingInstruction) getInstruction("MappingInstruction.json");
assertThat(instruction.type().toString(), is(UNICAST_TYPE_STRING));
assertThat(instruction.subtype().toString(), is(WEIGHT_SUBTYPE_STRING));
}
use of org.onosproject.mapping.instructions.UnicastMappingInstruction in project onos by opennetworkinglab.
the class EncodeMappingInstructionCodecHelper method encodeUnicast.
/**
* Encodes an unicast mapping instruction.
*
* @param result json node that the mapping instruction
* attributes are added to
*/
private void encodeUnicast(ObjectNode result) {
UnicastMappingInstruction unicastInstruction = (UnicastMappingInstruction) instruction;
result.put(MappingInstructionCodec.SUBTYPE, unicastInstruction.subtype().name());
switch(unicastInstruction.subtype()) {
case WEIGHT:
UnicastMappingInstruction.WeightMappingInstruction wmi = (UnicastMappingInstruction.WeightMappingInstruction) unicastInstruction;
result.put(MappingInstructionCodec.UNICAST_WEIGHT, wmi.weight());
break;
case PRIORITY:
UnicastMappingInstruction.PriorityMappingInstruction pmi = (UnicastMappingInstruction.PriorityMappingInstruction) unicastInstruction;
result.put(MappingInstructionCodec.UNICAST_PRIORITY, pmi.priority());
break;
default:
log.info("Cannot convert unicast subtype of {}", unicastInstruction.subtype());
}
}
Aggregations