@Test public void testMapToWhenBubbleMessageNotExist() { final BaseGlobalTransactionEvent event = mock(BaseGlobalTransactionEvent.class); final WorkerMeta meta = mock(WorkerMeta.class); final String txName = "txname"; final GlobalTransactionStepDefinition<BaseGlobalTransactionEvent> pipeline = GlobalTransactionStepDefinition.builder() .in(event) .meta(meta) .build(); when(meta.getTransactionName()).thenReturn(txName); when(mockTransactionUtilities.getBubleMessage(pipeline)).thenReturn(Optional.empty()); final RequestGlobalTransaction result = globalTransactionMapperUnderTest.mapTo(pipeline).get(); assertEquals(result.getName(), txName); assertEquals(result.getEventRequestor(), event); assertEquals(result.getGTX(), null); assertEquals(result.getParent(), null); assertEquals(result.getTraceId(), null); assertEquals(result.getCommandRequestor(), null); }
Optional<RequestGlobalTransaction> mapTo(GlobalTransactionStepDefinition<BaseGlobalTransactionEvent> pipeline) { Optional<BubbleMessage> bubleMessage = txUtility.getBubleMessage(pipeline); RequestGlobalTransaction.RequestGlobalTransactionBuilder requestGlobalTransactionBuilder = new RequestGlobalTransaction.RequestGlobalTransactionBuilder(); requestGlobalTransactionBuilder.name(pipeline.getMeta().getTransactionName()); requestGlobalTransactionBuilder.eventRequestor(pipeline.getIn()); bubleMessage.ifPresent(bm -> { requestGlobalTransactionBuilder.gtx(bm.getGLTX()).parent(bm.getPGTX()).traceId(bm.getTraceId()); if (bm.getCommandId() != null) { InboundCommand inboundCommand = (InboundCommand) commandRepository.findOne(bm.getCommandId()); requestGlobalTransactionBuilder.commandRequestor(inboundCommand); } }); RequestGlobalTransaction rgt = requestGlobalTransactionBuilder.build(); return Optional.of(rgt); }
GlobalTransactionMapper { Optional<RequestGlobalTransaction> mapTo(GlobalTransactionStepDefinition<BaseGlobalTransactionEvent> pipeline) { Optional<BubbleMessage> bubleMessage = txUtility.getBubleMessage(pipeline); RequestGlobalTransaction.RequestGlobalTransactionBuilder requestGlobalTransactionBuilder = new RequestGlobalTransaction.RequestGlobalTransactionBuilder(); requestGlobalTransactionBuilder.name(pipeline.getMeta().getTransactionName()); requestGlobalTransactionBuilder.eventRequestor(pipeline.getIn()); bubleMessage.ifPresent(bm -> { requestGlobalTransactionBuilder.gtx(bm.getGLTX()).parent(bm.getPGTX()).traceId(bm.getTraceId()); if (bm.getCommandId() != null) { InboundCommand inboundCommand = (InboundCommand) commandRepository.findOne(bm.getCommandId()); requestGlobalTransactionBuilder.commandRequestor(inboundCommand); } }); RequestGlobalTransaction rgt = requestGlobalTransactionBuilder.build(); return Optional.of(rgt); } }
GlobalTransactionMapper { Optional<RequestGlobalTransaction> mapTo(GlobalTransactionStepDefinition<BaseGlobalTransactionEvent> pipeline) { Optional<BubbleMessage> bubleMessage = txUtility.getBubleMessage(pipeline); RequestGlobalTransaction.RequestGlobalTransactionBuilder requestGlobalTransactionBuilder = new RequestGlobalTransaction.RequestGlobalTransactionBuilder(); requestGlobalTransactionBuilder.name(pipeline.getMeta().getTransactionName()); requestGlobalTransactionBuilder.eventRequestor(pipeline.getIn()); bubleMessage.ifPresent(bm -> { requestGlobalTransactionBuilder.gtx(bm.getGLTX()).parent(bm.getPGTX()).traceId(bm.getTraceId()); if (bm.getCommandId() != null) { InboundCommand inboundCommand = (InboundCommand) commandRepository.findOne(bm.getCommandId()); requestGlobalTransactionBuilder.commandRequestor(inboundCommand); } }); RequestGlobalTransaction rgt = requestGlobalTransactionBuilder.build(); return Optional.of(rgt); }  }
GlobalTransactionMapper { Optional<RequestGlobalTransaction> mapTo(GlobalTransactionStepDefinition<BaseGlobalTransactionEvent> pipeline) { Optional<BubbleMessage> bubleMessage = txUtility.getBubleMessage(pipeline); RequestGlobalTransaction.RequestGlobalTransactionBuilder requestGlobalTransactionBuilder = new RequestGlobalTransaction.RequestGlobalTransactionBuilder(); requestGlobalTransactionBuilder.name(pipeline.getMeta().getTransactionName()); requestGlobalTransactionBuilder.eventRequestor(pipeline.getIn()); bubleMessage.ifPresent(bm -> { requestGlobalTransactionBuilder.gtx(bm.getGLTX()).parent(bm.getPGTX()).traceId(bm.getTraceId()); if (bm.getCommandId() != null) { InboundCommand inboundCommand = (InboundCommand) commandRepository.findOne(bm.getCommandId()); requestGlobalTransactionBuilder.commandRequestor(inboundCommand); } }); RequestGlobalTransaction rgt = requestGlobalTransactionBuilder.build(); return Optional.of(rgt); }   }
GlobalTransactionMapper { Optional<RequestGlobalTransaction> mapTo(GlobalTransactionStepDefinition<BaseGlobalTransactionEvent> pipeline) { Optional<BubbleMessage> bubleMessage = txUtility.getBubleMessage(pipeline); RequestGlobalTransaction.RequestGlobalTransactionBuilder requestGlobalTransactionBuilder = new RequestGlobalTransaction.RequestGlobalTransactionBuilder(); requestGlobalTransactionBuilder.name(pipeline.getMeta().getTransactionName()); requestGlobalTransactionBuilder.eventRequestor(pipeline.getIn()); bubleMessage.ifPresent(bm -> { requestGlobalTransactionBuilder.gtx(bm.getGLTX()).parent(bm.getPGTX()).traceId(bm.getTraceId()); if (bm.getCommandId() != null) { InboundCommand inboundCommand = (InboundCommand) commandRepository.findOne(bm.getCommandId()); requestGlobalTransactionBuilder.commandRequestor(inboundCommand); } }); RequestGlobalTransaction rgt = requestGlobalTransactionBuilder.build(); return Optional.of(rgt); }    }