### Question:
RemotePeerBean implements RemotePeerMXBean, ZKMBeanInfo { @Override public boolean isLeader() { return localPeer.isLeader(peer.getId()); } RemotePeerBean(QuorumPeer localPeer, QuorumPeer.QuorumServer peer); void setQuorumServer(QuorumPeer.QuorumServer peer); String getName(); boolean isHidden(); String getQuorumAddress(); String getElectionAddress(); String getClientAddress(); String getLearnerType(); @Override boolean isLeader();  }### Answer:
@Test @SuppressWarnings("unchecked") public void testIsLeader() { long peerId = 7; QuorumPeer.QuorumServer quorumServerMock = mock(QuorumPeer.QuorumServer.class); when(quorumServerMock.getId()).thenReturn(peerId); QuorumPeer peerMock = mock(QuorumPeer.class); RemotePeerBean remotePeerBean = new RemotePeerBean(peerMock, quorumServerMock); when(peerMock.isLeader(eq(peerId))).thenReturn(true); assertTrue(remotePeerBean.isLeader()); when(peerMock.isLeader(eq(peerId))).thenReturn(false); assertFalse(remotePeerBean.isLeader()); }