use of org.onosproject.mapping.actions.DropMappingAction in project onos by opennetworkinglab.
the class EncodeMappingActionCodecHelper method encodeDropMappingAction.
/**
* Encodes a drop mapping action.
*
* @param result json node that the mapping action attributes are added to
*/
private void encodeDropMappingAction(ObjectNode result) {
DropMappingAction dropMappingAction = (DropMappingAction) action;
result.put(MappingActionCodec.TYPE, dropMappingAction.type().name());
}
use of org.onosproject.mapping.actions.DropMappingAction in project onos by opennetworkinglab.
the class MappingActionCodecTest method dropActionTest.
/**
* Tests the encoding of drop mapping action.
*/
@Test
public void dropActionTest() {
final DropMappingAction action = MappingActions.drop();
final ObjectNode actionJson = actionCodec.encode(action, context);
assertThat(actionJson, matchesAction(action));
}
use of org.onosproject.mapping.actions.DropMappingAction in project onos by opennetworkinglab.
the class MappingActionJsonMatcher method matchDropAction.
/**
* Matches the contents of a drop mapping action.
*
* @param node JSON action to match
* @param description object used for recording errors
* @return true if the contents match, false otherwise
*/
private boolean matchDropAction(JsonNode node, Description description) {
DropMappingAction actionToMatch = (DropMappingAction) action;
final String jsonType = node.get(MappingActionCodec.TYPE).textValue();
if (!actionToMatch.type().name().equals(jsonType)) {
description.appendText("type was " + jsonType);
return false;
}
return true;
}
use of org.onosproject.mapping.actions.DropMappingAction in project onos by opennetworkinglab.
the class MappingActionJsonMatcher method matchesSafely.
@Override
protected boolean matchesSafely(JsonNode jsonNode, Description description) {
// check type
final JsonNode jsonTypeNode = jsonNode.get(MappingActionCodec.TYPE);
final String jsonType = jsonTypeNode.textValue();
final String type = action.type().name();
if (!jsonType.equals(type)) {
description.appendText("type was " + type);
return false;
}
if (action instanceof NoMappingAction) {
return matchNoAction(jsonNode, description);
} else if (action instanceof DropMappingAction) {
return matchDropAction(jsonNode, description);
} else if (action instanceof ForwardMappingAction) {
return matchForwardAction(jsonNode, description);
} else if (action instanceof NativeForwardMappingAction) {
return matchNativeForwardAction(jsonNode, description);
}
return false;
}
Aggregations