### Question:
ProducerImpl extends AbstractOMSProducer implements Producer { @Override public SendResult send(final Message message) { return send(message, this.rocketmqProducer.getSendMsgTimeout()); } ProducerImpl(final KeyValue properties); @Override KeyValue properties(); @Override SendResult send(final Message message); @Override SendResult send(final Message message, final KeyValue properties); @Override Promise<SendResult> sendAsync(final Message message); @Override Promise<SendResult> sendAsync(final Message message, final KeyValue properties); @Override void sendOneway(final Message message); @Override void sendOneway(final Message message, final KeyValue properties);  }### Answer:
@Test public void testSend_OK() throws InterruptedException, RemotingException, MQClientException, MQBrokerException { SendResult sendResult = new SendResult(); sendResult.setMsgId("TestMsgID"); sendResult.setSendStatus(SendStatus.SEND_OK); when(rocketmqProducer.send(any(Message.class), anyLong())).thenReturn(sendResult); io.openmessaging.SendResult omsResult = producer.send(producer.createBytesMessageToTopic("HELLO_TOPIC", new byte[] {'a'})); assertThat(omsResult.messageId()).isEqualTo("TestMsgID"); }
@Test public void testSend_Not_OK() throws InterruptedException, RemotingException, MQClientException, MQBrokerException { SendResult sendResult = new SendResult(); sendResult.setSendStatus(SendStatus.FLUSH_DISK_TIMEOUT); when(rocketmqProducer.send(any(Message.class), anyLong())).thenReturn(sendResult); try { producer.send(producer.createBytesMessageToTopic("HELLO_TOPIC", new byte[] {'a'})); failBecauseExceptionWasNotThrown(OMSRuntimeException.class); } catch (Exception e) { assertThat(e).hasMessageContaining("Send message to RocketMQ broker failed."); } }
@Test public void testSend_WithException() throws InterruptedException, RemotingException, MQClientException, MQBrokerException { when(rocketmqProducer.send(any(Message.class), anyLong())).thenThrow(MQClientException.class); try { producer.send(producer.createBytesMessageToTopic("HELLO_TOPIC", new byte[] {'a'})); failBecauseExceptionWasNotThrown(OMSRuntimeException.class); } catch (Exception e) { assertThat(e).hasMessageContaining("Send message to RocketMQ broker failed."); } }