### Question:
RingMessageManager extends AbstractMessageManager { @Override public boolean sendLeaderMessage(int currentId, int leaderId) { var nextInstance = this.findNextInstance(currentId); var leaderMessage = new Message(MessageType.LEADER, String.valueOf(leaderId)); nextInstance.onMessage(leaderMessage); return true; } RingMessageManager(Map<Integer, Instance> instanceMap); @Override boolean sendHeartbeatMessage(int leaderId); @Override boolean sendElectionMessage(int currentId, String content); @Override boolean sendLeaderMessage(int currentId, int leaderId); @Override void sendHeartbeatInvokeMessage(int currentId);  }### Answer:
@Test public void testSendLeaderMessage() { try { var instance1 = new RingInstance(null, 1, 1); var instance2 = new RingInstance(null, 1, 2); var instance3 = new RingInstance(null, 1, 3); Map<Integer, Instance> instanceMap = Map.of(1, instance1, 2, instance2, 3, instance3); var messageManager = new RingMessageManager(instanceMap); var messageContent = "3"; messageManager.sendLeaderMessage(2, 3); var ringMessage = new Message(MessageType.LEADER, messageContent); var instanceClass = AbstractInstance.class; var messageQueueField = instanceClass.getDeclaredField("messageQueue"); messageQueueField.setAccessible(true); var ringMessageSent = ((Queue<Message>) messageQueueField.get(instance3)).poll(); assertEquals(ringMessageSent, ringMessage); } catch (NoSuchFieldException | IllegalAccessException e) { fail("Error to access private field."); } }