### Question:
MessageIdGenerator { public String generateMessageId(Message message) { String hostname = null; Address[] from = message.getFrom(); if (from != null && from.length >= 1) { hostname = from[0].getHostname(); } if (hostname == null) { Address[] replyTo = message.getReplyTo(); if (replyTo != null && replyTo.length >= 1) { hostname = replyTo[0].getHostname(); } } if (hostname == null) { hostname = "email.android.com"; } String uuid = generateUuid(); return "<" + uuid + "@" + hostname + ">"; } @VisibleForTesting  MessageIdGenerator(); static MessageIdGenerator getInstance(); String generateMessageId(Message message);  }### Answer:
@Test public void generateMessageId_withFromAndReplyToAddress() throws Exception { Message message = new MimeMessage(); message.setFrom(new Address("alice@example.org")); message.setReplyTo(Address.parse("bob@example.com")); String result = messageIdGenerator.generateMessageId(message); assertEquals("<00000000-0000-4000-0000-000000000000@example.org>", result); }
@Test public void generateMessageId_withReplyToAddress() throws Exception { Message message = new MimeMessage(); message.setReplyTo(Address.parse("bob@example.com")); String result = messageIdGenerator.generateMessageId(message); assertEquals("<00000000-0000-4000-0000-000000000000@example.com>", result); }
@Test public void generateMessageId_withoutRelevantHeaders() throws Exception { Message message = new MimeMessage(); String result = messageIdGenerator.generateMessageId(message); assertEquals("<00000000-0000-4000-0000-000000000000@email.android.com>", result); }