### Question:
NodeGroup { int getMatchIndexOfMajor() { List<NodeMatchIndex> matchIndices = new ArrayList<>(); for (GroupMember member : memberMap.values()) { if (member.isMajor() && !member.idEquals(selfId)) { matchIndices.add(new NodeMatchIndex(member.getId(), member.getMatchIndex())); } } int count = matchIndices.size(); if (count == 0) { throw new IllegalStateException("standalone or no major node"); } Collections.sort(matchIndices); logger.debug("match indices {}", matchIndices); return matchIndices.get(count / 2).getMatchIndex(); } NodeGroup(NodeEndpoint endpoint);   NodeGroup(Collection<NodeEndpoint> endpoints, NodeId selfId);   }### Answer:
@Test public void testGetMatchIndexOfMajor() { Set<NodeEndpoint> endpoints = new HashSet<>(); endpoints.add(new NodeEndpoint("A", "localhost", 2333)); endpoints.add(new NodeEndpoint("B", "localhost", 2334)); endpoints.add(new NodeEndpoint("C", "localhost", 2335)); NodeGroup group = new NodeGroup(endpoints, NodeId.of("A")); group.resetReplicatingStates(1); group.findMember(NodeId.of("B")).advanceReplicatingState(10); Assert.assertEquals(10, group.getMatchIndexOfMajor()); group.findMember(NodeId.of("C")).advanceReplicatingState(10); Assert.assertEquals(10, group.getMatchIndexOfMajor()); }