PrimaryTerm { public PrimaryTerm( final long term, final GroupMember primary, final List<GroupMember> candidates) { this.term = term; this.primary = primary; this.candidates = candidates; } PrimaryTerm(
      final long term, final GroupMember primary, final List<GroupMember> candidates); long term(); GroupMember primary(); List<GroupMember> candidates(); List<GroupMember> backups(final int numBackups); @Override int hashCode(); @Override boolean equals(final Object object); @Override String toString();  }
@Test public void testPrimaryTerm() throws Exception { final GroupMember primary = new GroupMember(MemberId.from("1"), MemberGroupId.from("1")); final List<GroupMember> candidates = Arrays.asList( new GroupMember(MemberId.from("1"), MemberGroupId.from("1")), new GroupMember(MemberId.from("2"), MemberGroupId.from("2")), new GroupMember(MemberId.from("3"), MemberGroupId.from("2")), new GroupMember(MemberId.from("4"), MemberGroupId.from("3")), new GroupMember(MemberId.from("5"), MemberGroupId.from("3"))); final PrimaryTerm term = new PrimaryTerm(1, primary, candidates); assertEquals(primary, term.primary()); assertEquals(candidates, term.candidates()); assertEquals(Arrays.asList(), term.backups(0)); assertEquals(Arrays.asList(candidates.get(1)), term.backups(1)); assertEquals(Arrays.asList(candidates.get(1), candidates.get(2)), term.backups(2)); assertEquals( Arrays.asList(candidates.get(1), candidates.get(2), candidates.get(3)), term.backups(3)); assertEquals( Arrays.asList(candidates.get(1), candidates.get(2), candidates.get(3), candidates.get(4)), term.backups(4)); assertEquals( Arrays.asList(candidates.get(1), candidates.get(2), candidates.get(3), candidates.get(4)), term.backups(5)); }