### Question:
SpanUtils { public static String messageName(Message<?> message) { if (message instanceof CommandMessage) { return messageName(message.getPayloadType(), ((CommandMessage) message).getCommandName()); } else if (message instanceof QueryMessage) { return messageName(message.getPayloadType(), ((QueryMessage) message).getQueryName()); } return message.getPayloadType().getSimpleName(); }  static Tracer.SpanBuilder withMessageTags(Tracer.SpanBuilder spanBuilder, Message<?> message); static Tracer.SpanBuilder withQueryMessageTags(Tracer.SpanBuilder spanBuilder,
                                                          Message<?> queryMessage,
                                                          String queryName); static String resolveMessageType(Message<?> message); static String messageName(Message<?> message);  }### Answer:
@Test void testMessageNameOfMessage() { assertEquals(TEST_MESSAGE.getPayloadType().getSimpleName(), SpanUtils.messageName(TEST_MESSAGE)); }
@Test void testMessageNameOfDefaultCommandMessage() { assertEquals(TEST_COMMAND.getPayloadType().getSimpleName(), SpanUtils.messageName(TEST_COMMAND)); }
@Test void testMessageNameOfCommandMessageWithCustomName() { String expectedMessageName = "my-custom-command-name"; CommandMessage<?> testCommand = new GenericCommandMessage<>(GenericMessage.asMessage("some-payload"), expectedMessageName); assertEquals(expectedMessageName, SpanUtils.messageName(testCommand)); }
@Test void testMessageNameOfDefaultQueryMessage() { assertEquals(TEST_QUERY.getPayloadType().getSimpleName(), SpanUtils.messageName(TEST_QUERY)); }
@Test void testMessageNameOfQueryMessageWithCustomName() { String expectedMessageName = "my-custom-command-name"; QueryMessage<String, String> testQuery = new GenericQueryMessage<>("some-query", expectedMessageName, ResponseTypes.instanceOf(String.class)); assertEquals(expectedMessageName, SpanUtils.messageName(testQuery)); }
@Test void testMessageNameOfEventMessage() { assertEquals(TEST_EVENT.getPayloadType().getSimpleName(), SpanUtils.messageName(TEST_EVENT)); }