Search in sources :

Example 1 with ForwardMappingAction

use of org.onosproject.mapping.actions.ForwardMappingAction in project onos by opennetworkinglab.

the class EncodeMappingActionCodecHelper method encodeForwardMappingAction.

/**
 * Encodes a forward mapping action.
 *
 * @param result json node that the mapping action attributes are added to
 */
private void encodeForwardMappingAction(ObjectNode result) {
    ForwardMappingAction forwardMappingAction = (ForwardMappingAction) action;
    result.put(MappingActionCodec.TYPE, forwardMappingAction.type().name());
}
Also used : ForwardMappingAction(org.onosproject.mapping.actions.ForwardMappingAction) NativeForwardMappingAction(org.onosproject.mapping.actions.NativeForwardMappingAction)

Example 2 with ForwardMappingAction

use of org.onosproject.mapping.actions.ForwardMappingAction in project onos by opennetworkinglab.

the class MappingActionCodecTest method forwardActionTest.

/**
 * Tests the encoding of forward mapping action.
 */
@Test
public void forwardActionTest() {
    final ForwardMappingAction action = MappingActions.forward();
    final ObjectNode actionJson = actionCodec.encode(action, context);
    assertThat(actionJson, matchesAction(action));
}
Also used : NativeForwardMappingAction(org.onosproject.mapping.actions.NativeForwardMappingAction) ForwardMappingAction(org.onosproject.mapping.actions.ForwardMappingAction) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Test(org.junit.Test)

Example 3 with ForwardMappingAction

use of org.onosproject.mapping.actions.ForwardMappingAction in project onos by opennetworkinglab.

the class MappingActionJsonMatcher method matchForwardAction.

/**
 * Matches the contents of a forward 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 matchForwardAction(JsonNode node, Description description) {
    ForwardMappingAction actionToMatch = (ForwardMappingAction) action;
    final String jsonType = node.get(MappingActionCodec.TYPE).textValue();
    if (!actionToMatch.type().name().equals(jsonType)) {
        description.appendText("type was " + jsonType);
        return false;
    }
    return true;
}
Also used : ForwardMappingAction(org.onosproject.mapping.actions.ForwardMappingAction) NativeForwardMappingAction(org.onosproject.mapping.actions.NativeForwardMappingAction)

Example 4 with ForwardMappingAction

use of org.onosproject.mapping.actions.ForwardMappingAction 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;
}
Also used : ForwardMappingAction(org.onosproject.mapping.actions.ForwardMappingAction) NativeForwardMappingAction(org.onosproject.mapping.actions.NativeForwardMappingAction) NoMappingAction(org.onosproject.mapping.actions.NoMappingAction) DropMappingAction(org.onosproject.mapping.actions.DropMappingAction) JsonNode(com.fasterxml.jackson.databind.JsonNode) NativeForwardMappingAction(org.onosproject.mapping.actions.NativeForwardMappingAction)

Aggregations

ForwardMappingAction (org.onosproject.mapping.actions.ForwardMappingAction)4 NativeForwardMappingAction (org.onosproject.mapping.actions.NativeForwardMappingAction)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Test (org.junit.Test)1 DropMappingAction (org.onosproject.mapping.actions.DropMappingAction)1 NoMappingAction (org.onosproject.mapping.actions.NoMappingAction)1