### Question:
BullyMessageManager extends AbstractMessageManager { @Override public void sendHeartbeatInvokeMessage(int currentId) { var nextInstance = this.findNextInstance(currentId); var heartbeatInvokeMessage = new Message(MessageType.HEARTBEAT_INVOKE, ""); nextInstance.onMessage(heartbeatInvokeMessage); } 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 testSendHeartbeatInvokeMessage() { try { var instance1 = new BullyInstance(null, 1, 1); var instance2 = new BullyInstance(null, 1, 2); var instance3 = new BullyInstance(null, 1, 3); Map<Integer, Instance> instanceMap = Map.of(1, instance1, 2, instance2, 3, instance3); var messageManager = new BullyMessageManager(instanceMap); messageManager.sendHeartbeatInvokeMessage(2); var message = new Message(MessageType.HEARTBEAT_INVOKE, ""); var instanceClass = AbstractInstance.class; var messageQueueField = instanceClass.getDeclaredField("messageQueue"); messageQueueField.setAccessible(true); var messageSent = ((Queue<Message>) messageQueueField.get(instance3)).poll(); assertEquals(messageSent.getType(), message.getType()); assertEquals(messageSent.getContent(), message.getContent()); } catch (NoSuchFieldException | IllegalAccessException e) { fail("Error to access private field."); } }