Source:
<code>public void toServiceBusMessageTest() { final ServiceBusReceivedMessage originalMessage = new ServiceBusReceivedMessage(PAYLOAD_BYTES); originalMessage.setMessageId("mid"); originalMessage.setContentType("type"); originalMessage.setCorrelationId("cid"); originalMessage.setReplyTo("rto"); originalMessage.setViaPartitionKey("something"); originalMessage.setTimeToLive(Duration.ofSeconds(10)); originalMessage.setReplyToSessionId("rsessionid"); originalMessage.setLabel("label"); originalMessage.setTo("to"); final ServiceBusMessage messageToSend = originalMessage.toServiceBusMessage(); Assertions.assertNotNull(messageToSend); Assertions.assertNotNull(messageToSend.getBody()); Assertions.assertEquals(PAYLOAD, new String(messageToSend.getBody(), UTF_8)); Assertions.assertEquals(originalMessage.getMessageId(), messageToSend.getMessageId()); Assertions.assertEquals(originalMessage.getContentType(), messageToSend.getContentType()); Assertions.assertEquals(originalMessage.getCorrelationId(), messageToSend.getCorrelationId()); Assertions.assertEquals(originalMessage.getReplyTo(), messageToSend.getReplyTo()); Assertions.assertEquals(originalMessage.getViaPartitionKey(), messageToSend.getViaPartitionKey()); <START> Assertions.assertTrue( <END> originalMessage.getTimeToLive().toMillis() == messageToSend.getTimeToLive().toMillis()); Assertions.assertEquals(originalMessage.getLabel(), messageToSend.getLabel()); Assertions.assertEquals(originalMessage.getReplyToSessionId(), messageToSend.getReplyToSessionId()); Assertions.assertEquals(originalMessage.getTo(), messageToSend.getTo()); }</code><technical_language>equality check for durations</technical_language>

Target:
public void toServiceBusMessageTest() { final ServiceBusReceivedMessage originalMessage = new ServiceBusReceivedMessage(PAYLOAD_BYTES); originalMessage.setMessageId("mid"); originalMessage.setContentType("type"); originalMessage.setCorrelationId("cid"); originalMessage.setReplyTo("rto"); originalMessage.setViaPartitionKey("something"); originalMessage.setTimeToLive(Duration.ofSeconds(10)); originalMessage.setReplyToSessionId("rsessionid"); originalMessage.setLabel("label"); originalMessage.setTo("to"); final ServiceBusMessage messageToSend = originalMessage.toServiceBusMessage(); Assertions.assertNotNull(messageToSend); Assertions.assertNotNull(messageToSend.getBody()); Assertions.assertEquals(PAYLOAD, new String(messageToSend.getBody(), UTF_8)); Assertions.assertEquals(originalMessage.getMessageId(), messageToSend.getMessageId()); Assertions.assertEquals(originalMessage.getContentType(), messageToSend.getContentType()); Assertions.assertEquals(originalMessage.getCorrelationId(), messageToSend.getCorrelationId()); Assertions.assertEquals(originalMessage.getReplyTo(), messageToSend.getReplyTo()); Assertions.assertEquals(originalMessage.getViaPartitionKey(), messageToSend.getViaPartitionKey()); Assertions.assertEquals(originalMessage.getTimeToLive().toMillis(), messageToSend.getTimeToLive().toMillis()); Assertions.assertEquals(originalMessage.getLabel(), messageToSend.getLabel()); Assertions.assertEquals(originalMessage.getReplyToSessionId(), messageToSend.getReplyToSessionId()); Assertions.assertEquals(originalMessage.getTo(), messageToSend.getTo()); }