@Test
void onReceive() {

    // SETUP
    when(this.messageMetadata.getMessageType()).thenReturn("test-message-type");
    when(this.messageMetadata.getCorrelationUid()).thenReturn("test-correlation-uuid");
    when(this.messageMetadata.getOrganisationIdentification()).thenReturn("test-organisation-id");
    when(this.messageMetadata.getDeviceIdentification()).thenReturn("test-device-id");
    when(this.messageMetadata.getMessagePriority()).thenReturn(2345);
    when(this.messageMetadata.isBypassRetry()).thenReturn(true);
    // Note: messageMetadata.isScheduled is not used
    // by DeviceMessageMetadata. It is derived from scheduleTime
    when(this.messageMetadata.getScheduleTime()).thenReturn(null);
    when(this.messageMetadata.getDomain()).thenReturn("test-device-id");
    when(this.messageMetadata.getDomainVersion()).thenReturn("test-device-id");
    final String payload = "12345";
    final byte[] bytes = payload.getBytes();
    // CALL
    this.instance.onReceive(this.mqttClientAdapter, bytes);
    // VERIFY
    verify(this.outboundOsgpCoreResponseMessageSender).send(this.protocolResponseMessageCaptor.capture());
    final ProtocolResponseMessage protocolResponseMessage = this.protocolResponseMessageCaptor.getValue();
    assertEquals(this.messageMetadata.getMessageType(), protocolResponseMessage.getMessageType());
    assertEquals(this.messageMetadata.getCorrelationUid(), protocolResponseMessage.getCorrelationUid());
    assertEquals(this.messageMetadata.getOrganisationIdentification(),
            protocolResponseMessage.getOrganisationIdentification());
    assertEquals(this.messageMetadata.getDeviceIdentification(), protocolResponseMessage.getDeviceIdentification());
    assertEquals(this.messageMetadata.getMessagePriority(), protocolResponseMessage.getMessagePriority());
    assertEquals(this.messageMetadata.isBypassRetry(), protocolResponseMessage.bypassRetry());
    assertFalse(protocolResponseMessage.isScheduled());
    assertEquals(this.messageMetadata.getDomain(), protocolResponseMessage.getDomain());
    assertEquals(this.messageMetadata.getDomainVersion(), protocolResponseMessage.getDomainVersion());
    assertEquals(payload, protocolResponseMessage.getDataObject());
    assertEquals(ResponseMessageResultType.OK, protocolResponseMessage.getResult());
}