TransactionUtilities { public Optional<BubbleMessage> getBubleMessage(GlobalTransactionStepDefinition pipeline) { String eventId = pipeline.getIn().getId(); return bubbleCache.getBubble(eventId); } TransactionUtilities(BubbleCache bubbleCache); Optional<BubbleMessage> getBubleMessage(GlobalTransactionStepDefinition pipeline); Optional<BubbleMessage> getBubleMessage(LocalTransactionStepDefinition pipeline);  }
@Test public void testGetBubleMessageGlobalPipelineWhenEventRegistred() { final GlobalTransactionStepDefinition pipeline = mock(GlobalTransactionStepDefinition.class); final BaseTransactionEvent event = mock(BaseTransactionEvent.class); final String eventId = "eventid"; final BubbleMessage message = mock(BubbleMessage.class); when(pipeline.getIn()).thenReturn(event); when(event.getId()).thenReturn(eventId); when(mockBubbleCache.getBubble(eventId)).thenReturn(Optional.of(message)); final Optional<BubbleMessage> result = transactionUtilitiesUnderTest.getBubleMessage(pipeline); assertEquals(Optional.of(message), result); }
@Test public void testGetBubleMessageGlobalPipelineWhenEventNotRegistred() { final GlobalTransactionStepDefinition pipeline = mock(GlobalTransactionStepDefinition.class); final BaseTransactionEvent event = mock(BaseTransactionEvent.class); final String eventId = "eventid"; when(pipeline.getIn()).thenReturn(event); when(event.getId()).thenReturn(eventId); when(mockBubbleCache.getBubble(eventId)).thenReturn(Optional.empty()); final Optional<BubbleMessage> result = transactionUtilitiesUnderTest.getBubleMessage(pipeline); assertEquals(Optional.empty(), result); }
@Test public void testGetBubleMessageLocalPipelineWhenEventRegistred() { final LocalTransactionStepDefinition pipeline = mock(LocalTransactionStepDefinition.class); final BaseTransactionEvent event = mock(BaseTransactionEvent.class); final String eventId = "eventid"; final BubbleMessage message = mock(BubbleMessage.class); when(pipeline.getIn()).thenReturn(event); when(event.getId()).thenReturn(eventId); when(mockBubbleCache.getBubble(eventId)).thenReturn(Optional.of(message)); final Optional<BubbleMessage> result = transactionUtilitiesUnderTest.getBubleMessage(pipeline); assertEquals(Optional.of(message), result); }
@Test public void testGetBubleMessageLocalPipelineWhenEventNotRegistred() { final LocalTransactionStepDefinition pipeline = mock(LocalTransactionStepDefinition.class); final BaseTransactionEvent event = mock(BaseTransactionEvent.class); final String eventId = "eventid"; when(pipeline.getIn()).thenReturn(event); when(event.getId()).thenReturn(eventId); when(mockBubbleCache.getBubble(eventId)).thenReturn(Optional.empty()); final Optional<BubbleMessage> result = transactionUtilitiesUnderTest.getBubleMessage(pipeline); assertEquals(Optional.empty(), result); }