@Test public void testOnCommandPreparedDecodedRegistred() { final InboundCommandPrepared commandPrepared = mock(InboundCommandPrepared.class); final String subject = "subject"; final CommandMeta meta = mock(CommandMeta.class); final BaseDecoder decoder = mock(BaseDecoder.class); final BaseTransactionEvent event = mock(BaseTransactionEvent.class); when(mockDecoderRegistry.containsKey(anyString())).thenReturn(true); when(commandPrepared.getMeta()).thenReturn(meta); when(mockDecoderRegistry.get(anyString())).thenReturn(decoder); when(decoder.decode(meta)).thenReturn(event); languageTranslatorImplUnderTest.onCommandPrepared(commandPrepared); verify(mockBubbleCache, atLeastOnce()).addBubble(anyString(), any(BubbleMessage.class)); verify(mockPublisher).publishEvent(any(BaseTransactionEvent.class)); }
@Override @EventListener public void onCommandPrepared(InboundCommandPrepared commandPrepared) { final CommandMeta meta = commandPrepared.getMeta(); final String subject = meta.getSubject(); if (decoders.containsKey(subject)) { final BaseDecoder decoder = decoders.get(subject); final BaseTransactionEvent event = decoder.decode(meta); addBubbleMessage(meta,Stream.of(event)); this.publisher.publishEvent(event); }else { throw new DecoderNotFoundException(subject); } }
LanguageTranslatorImpl implements LanguageTranslator { @Override @EventListener public void onCommandPrepared(InboundCommandPrepared commandPrepared) { final CommandMeta meta = commandPrepared.getMeta(); final String subject = meta.getSubject(); if (decoders.containsKey(subject)) { final BaseDecoder decoder = decoders.get(subject); final BaseTransactionEvent event = decoder.decode(meta); addBubbleMessage(meta,Stream.of(event)); this.publisher.publishEvent(event); }else { throw new DecoderNotFoundException(subject); } } }
LanguageTranslatorImpl implements LanguageTranslator { @Override @EventListener public void onCommandPrepared(InboundCommandPrepared commandPrepared) { final CommandMeta meta = commandPrepared.getMeta(); final String subject = meta.getSubject(); if (decoders.containsKey(subject)) { final BaseDecoder decoder = decoders.get(subject); final BaseTransactionEvent event = decoder.decode(meta); addBubbleMessage(meta,Stream.of(event)); this.publisher.publishEvent(event); }else { throw new DecoderNotFoundException(subject); } } @Autowired  LanguageTranslatorImpl(CommandRepository commandRepository, ApplicationEventPublisher publisher,
			BubbleCache bubbleCache, DecoderRegistry decoderRegistry, KermossTxLogger txLogger); }
LanguageTranslatorImpl implements LanguageTranslator { @Override @EventListener public void onCommandPrepared(InboundCommandPrepared commandPrepared) { final CommandMeta meta = commandPrepared.getMeta(); final String subject = meta.getSubject(); if (decoders.containsKey(subject)) { final BaseDecoder decoder = decoders.get(subject); final BaseTransactionEvent event = decoder.decode(meta); addBubbleMessage(meta,Stream.of(event)); this.publisher.publishEvent(event); }else { throw new DecoderNotFoundException(subject); } } @Autowired  LanguageTranslatorImpl(CommandRepository commandRepository, ApplicationEventPublisher publisher,
			BubbleCache bubbleCache, DecoderRegistry decoderRegistry, KermossTxLogger txLogger); void registerDecoder(String subject, BaseDecoder baseDecoder); @Async @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) @Transactional(propagation = Propagation.REQUIRES_NEW) void onCommandStarted(final InboundCommandStarted commandStarted); @Override @EventListener void onCommandPrepared(InboundCommandPrepared commandPrepared); void addBubbleMessage(CommandMeta meta, Stream<BaseTransactionEvent> events); BubbleCache getBubbleCache(); CommandRepository getCommandRepository(); ApplicationEventPublisher getPublisher(); Map<String, BaseDecoder> getDecoders(); void setDecoders(DecoderRegistry decoders); }
LanguageTranslatorImpl implements LanguageTranslator { @Override @EventListener public void onCommandPrepared(InboundCommandPrepared commandPrepared) { final CommandMeta meta = commandPrepared.getMeta(); final String subject = meta.getSubject(); if (decoders.containsKey(subject)) { final BaseDecoder decoder = decoders.get(subject); final BaseTransactionEvent event = decoder.decode(meta); addBubbleMessage(meta,Stream.of(event)); this.publisher.publishEvent(event); }else { throw new DecoderNotFoundException(subject); } } @Autowired  LanguageTranslatorImpl(CommandRepository commandRepository, ApplicationEventPublisher publisher,
			BubbleCache bubbleCache, DecoderRegistry decoderRegistry, KermossTxLogger txLogger); void registerDecoder(String subject, BaseDecoder baseDecoder); @Async @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) @Transactional(propagation = Propagation.REQUIRES_NEW) void onCommandStarted(final InboundCommandStarted commandStarted); @Override @EventListener void onCommandPrepared(InboundCommandPrepared commandPrepared); void addBubbleMessage(CommandMeta meta, Stream<BaseTransactionEvent> events); BubbleCache getBubbleCache(); CommandRepository getCommandRepository(); ApplicationEventPublisher getPublisher(); Map<String, BaseDecoder> getDecoders(); void setDecoders(DecoderRegistry decoders);  }