@Override
    public ObjectNode encode(MastershipTerm term, CodecContext context) {
        checkNotNull(term, "Mastership term cannot be null");
        ObjectNode result = context.mapper().createObjectNode()
                .put(MASTER, term.master().id())
                .put(TERM_NUMBER, term.termNumber());

        return result;
    }
@Test
    public void testMastershipTermEncode() {
        NodeId masterNodeId = NodeId.nodeId("1");
        long termNumber = 10;

        MastershipTerm mastershipTerm = MastershipTerm.of(masterNodeId, termNumber);
        ObjectNode mastershipTermJson = mastershipTermCodec.encode(mastershipTerm, context);
        assertThat(mastershipTermJson, MastershipTermJsonMatcher.matchesMastershipTerm(mastershipTerm));
    }