### Question:
DeFiBusClientUtil { public static Message createReplyMessage(MessageExt sourceMsg, byte[] content) { String cluster = sourceMsg.getUserProperty(DeFiBusConstant.PROPERTY_MESSAGE_CLUSTER); String replyTopic = DeFiBusConstant.RR_REPLY_TOPIC; if (!StringUtils.isEmpty(cluster)) { replyTopic = cluster + "-" + replyTopic; } else { LOGGER.warn("no cluster info from message, can not reply"); return null; } Message msg = new Message(); msg.setTopic(replyTopic); msg.setBody(content); msg.putUserProperty(DeFiBusConstant.PROPERTY_MESSAGE_REPLY_TO, sourceMsg.getUserProperty(DeFiBusConstant.PROPERTY_MESSAGE_REPLY_TO)); msg.putUserProperty(DeFiBusConstant.PROPERTY_RR_REQUEST_ID, sourceMsg.getUserProperty(DeFiBusConstant.PROPERTY_RR_REQUEST_ID)); String sourceBroker = sourceMsg.getUserProperty(DeFiBusConstant.PROPERTY_MESSAGE_BROKER); if (!StringUtils.isEmpty(sourceBroker)) { msg.putUserProperty(DeFiBusConstant.PROPERTY_MESSAGE_BROKER, sourceBroker); } return msg; }  static Message createReplyMessage(MessageExt sourceMsg, byte[] content); static final Logger LOGGER; }### Answer:
@Test public void createReplyMessage_Success() { MessageExt msg = new MessageExt(); msg.setTopic("Test"); msg.putUserProperty(DeFiBusConstant.PROPERTY_MESSAGE_CLUSTER, "ClusterName"); msg.putUserProperty(DeFiBusConstant.PROPERTY_MESSAGE_REPLY_TO, "reply_to"); msg.putUserProperty(DeFiBusConstant.PROPERTY_RR_REQUEST_ID, "w/request_id"); msg.putUserProperty(DeFiBusConstant.PROPERTY_MESSAGE_BROKER, "BrokerName"); byte[] replyContent = "reply content".getBytes(); Message replyMsg = DeFiBusClientUtil.createReplyMessage(msg, replyContent); assertThat(replyMsg).isNotNull(); assertThat(replyContent).isEqualTo(replyMsg.getBody()); }
@Test public void createReplyMessage_Fail() { MessageExt msg = new MessageExt(); msg.setTopic("Test"); msg.putUserProperty(DeFiBusConstant.PROPERTY_MESSAGE_REPLY_TO, "reply_to"); msg.putUserProperty(DeFiBusConstant.PROPERTY_RR_REQUEST_ID, "w/request_id"); byte[] replyContent = "reply content".getBytes(); Message replyMsg = DeFiBusClientUtil.createReplyMessage(msg, replyContent); assertThat(replyMsg).isNull(); }