### Question:
BullyMessageManager extends AbstractMessageManager { @Override public boolean sendLeaderMessage(int currentId, int leaderId) { var leaderMessage = new Message(MessageType.LEADER, String.valueOf(leaderId)); instanceMap.keySet() .stream() .filter((i) -> i != currentId) .forEach((i) -> instanceMap.get(i).onMessage(leaderMessage)); return false; } BullyMessageManager(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 BullyInstance(null, 1, 1); var instance2 = new BullyInstance(null, 1, 2); var instance3 = new BullyInstance(null, 1, 3); var instance4 = new BullyInstance(null, 1, 4); Map<Integer, Instance> instanceMap = Map.of(1, instance1, 2, instance2, 3, instance3, 4, instance4); instance1.setAlive(false); var messageManager = new BullyMessageManager(instanceMap); messageManager.sendLeaderMessage(2, 2); var instanceClass = AbstractInstance.class; var messageQueueField = instanceClass.getDeclaredField("messageQueue"); messageQueueField.setAccessible(true); var message3 = ((Queue<Message>) messageQueueField.get(instance3)).poll(); var message4 = ((Queue<Message>) messageQueueField.get(instance4)).poll(); var expectedMessage = new Message(MessageType.LEADER, "2"); assertEquals(message3, expectedMessage); assertEquals(message4, expectedMessage); } catch (IllegalAccessException | NoSuchFieldException e) { fail("Error to access private field."); } }