@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)); }
@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; }
MastershipTermCodec extends JsonCodec<MastershipTerm> { @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; } }
MastershipTermCodec extends JsonCodec<MastershipTerm> { @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; }  }
MastershipTermCodec extends JsonCodec<MastershipTerm> { @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; }  @Override ObjectNode encode(MastershipTerm term, CodecContext context); @Override MastershipTerm decode(ObjectNode json, CodecContext context); }
MastershipTermCodec extends JsonCodec<MastershipTerm> { @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; }  @Override ObjectNode encode(MastershipTerm term, CodecContext context); @Override MastershipTerm decode(ObjectNode json, CodecContext context);  }