Command { public String getInvalidCommandReason() { if (isValid()) { throw new IllegalStateException("command is valid"); } return validationError.get(); } private  Command(
            final Optional<String> validationError,
            final Message message,
            final String tenantId,
            final String deviceId,
            final String correlationId,
            final String replyToId,
            final String requestId); static Command from(
            final Message message,
            final String tenantId,
            final String deviceId); Message getCommandMessage(); boolean isOneWay(); boolean isValid(); String getInvalidCommandReason(); String getName(); String getTenant(); String getDeviceId(); boolean isTargetedAtGateway(); String getOriginalDeviceId(); String getRequestId(); Buffer getPayload(); int getPayloadSize(); String getContentType(); String getReplyToId(); String getReplyToEndpoint(); String getCorrelationId(); Map<String, Object> getApplicationProperties(); static String getRequestId(final String correlationId, final String replyToId, final String deviceId); @Override String toString(); static String getDeviceFacingReplyToId(final String replyToId, final String deviceId);  }
@Test public void testGetInvalidCommandReason() { final Message message = mock(Message.class); when(message.getReplyTo()).thenReturn("invalid-reply-to"); final Command command = Command.from(message, Constants.DEFAULT_TENANT, "4712"); assertFalse(command.isValid()); assertThat(command.getInvalidCommandReason()).contains("address"); assertThat(command.getInvalidCommandReason()).contains("subject"); assertThat(command.getInvalidCommandReason()).contains("correlation-id"); assertThat(command.getInvalidCommandReason()).contains("reply-to"); }