### Question:
LocalPeerBean extends ServerBean implements LocalPeerMXBean { @Override public boolean isLeader() { return peer.isLeader(peer.getId()); } LocalPeerBean(QuorumPeer peer); String getName(); boolean isHidden(); int getTickTime(); int getMaxClientCnxnsPerHost(); int getMinSessionTimeout(); int getMaxSessionTimeout(); int getInitLimit(); int getSyncLimit(); void setInitLimit(int initLimit); void setSyncLimit(int syncLimit); int getTick(); String getState(); String getQuorumAddress(); int getElectionType(); String getElectionAddress(); String getClientAddress(); String getLearnerType(); long getConfigVersion(); @Override String getQuorumSystemInfo(); @Override boolean isPartOfEnsemble(); @Override boolean isLeader(); @Override int getMaxCnxns();  }### Answer:
@Test public void testLocalPeerIsLeader() throws Exception { long localPeerId = 7; QuorumPeer peer = mock(QuorumPeer.class); when(peer.getId()).thenReturn(localPeerId); when(peer.isLeader(eq(localPeerId))).thenReturn(true); LocalPeerBean localPeerBean = new LocalPeerBean(peer); assertTrue(localPeerBean.isLeader()); }
@Test public void testLocalPeerIsNotLeader() throws Exception { long localPeerId = 7; QuorumPeer peer = mock(QuorumPeer.class); when(peer.getId()).thenReturn(localPeerId); when(peer.isLeader(eq(localPeerId))).thenReturn(false); LocalPeerBean localPeerBean = new LocalPeerBean(peer); assertFalse(localPeerBean.isLeader()); }