@Override
    public ObjectNode encode(Instruction instruction, CodecContext context) {
        checkNotNull(instruction, "Instruction cannot be null");

        return new EncodeInstructionCodecHelper(instruction, context).encode();
    }
@Test
    public void piInstructionEncodingTest() {
        PiActionId actionId = PiActionId.of("set_egress_port");
        PiActionParamId actionParamId = PiActionParamId.of("port");
        PiActionParam actionParam = new PiActionParam(actionParamId, ImmutableByteSequence.copyFrom(10));
        PiTableAction action = PiAction.builder().withId(actionId).withParameter(actionParam).build();
        final PiInstruction actionInstruction = Instructions.piTableAction(action);
        final ObjectNode actionInstructionJson =
                instructionCodec.encode(actionInstruction, context);
        assertThat(actionInstructionJson, matchesInstruction(actionInstruction));

        PiTableAction actionGroupId = PiActionProfileGroupId.of(10);
        final PiInstruction actionGroupIdInstruction = Instructions.piTableAction(actionGroupId);
        final ObjectNode actionGroupIdInstructionJson =
                instructionCodec.encode(actionGroupIdInstruction, context);
        assertThat(actionGroupIdInstructionJson, matchesInstruction(actionGroupIdInstruction));

        PiTableAction actionProfileMemberId = PiActionProfileMemberId.of(10);
        final PiInstruction actionProfileMemberIdInstruction = Instructions.piTableAction(actionProfileMemberId);
        final ObjectNode actionProfileMemberIdInstructionJson =
                instructionCodec.encode(actionProfileMemberIdInstruction, context);
        assertThat(actionProfileMemberIdInstructionJson, matchesInstruction(actionProfileMemberIdInstruction));
    }