@Test
public void testMapToWhenBubbleMessageExistAndCommandIdNotNull() {

    // Setup
    final BaseGlobalTransactionEvent event = mock(BaseGlobalTransactionEvent.class);
    final WorkerMeta meta = mock(WorkerMeta.class);
    final BubbleMessage bubbleMessage = mock(BubbleMessage.class);
    final InboundCommand command = mock(InboundCommand.class);
    final String txName = "txname";
    final String gtx = "gtx";
    final String pgtx = "pgtx";
    final String traceId = "traceId";
    final String commandId = "commandId";
    final GlobalTransactionStepDefinition<BaseGlobalTransactionEvent> pipeline = GlobalTransactionStepDefinition.builder()
            .in(event)
            .meta(meta)
            .build();
    when(mockTransactionUtilities.getBubleMessage(pipeline)).thenReturn(Optional.of(bubbleMessage));
    when(bubbleMessage.getGLTX()).thenReturn(gtx);
    when(bubbleMessage.getPGTX()).thenReturn(pgtx);
    when(bubbleMessage.getTraceId()).thenReturn(traceId);
    when(bubbleMessage.getCommandId()).thenReturn(commandId);
    when(meta.getTransactionName()).thenReturn(txName);
    when(mockCommandRepository.findOne(commandId)).thenReturn(command);
    // Run the test
    final RequestGlobalTransaction result = globalTransactionMapperUnderTest.mapTo(pipeline).get();
    // Verify the results
    assertEquals(result.getName(), txName);
    assertEquals(result.getEventRequestor(), event);
    assertEquals(result.getGTX(), gtx);
    assertEquals(result.getParent(), pgtx);
    assertEquals(result.getTraceId(), traceId);
    assertEquals(result.getCommandRequestor(), command);
}