LanguageTranslatorImpl implements LanguageTranslator { public void registerDecoder(String subject, BaseDecoder baseDecoder) { if (!decoders.containsKey(subject)) { decoders.put(subject, baseDecoder); } } @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);  }
@Test public void testRegisterDecoderWhenDecoderExist() { final String subject = "subject"; final BaseDecoder baseDecoder = mock(BaseDecoder.class); when(mockDecoderRegistry.containsKey(subject)).thenReturn(true); languageTranslatorImplUnderTest.registerDecoder(subject, baseDecoder); verify(mockDecoderRegistry, never()).put(anyString(), any(BaseDecoder.class)); }
@Test public void testRegisterDecoderWhenDecoderNotExist() { final String subject = "subject"; final BaseDecoder baseDecoder = mock(BaseDecoder.class); when(mockDecoderRegistry.containsKey(subject)).thenReturn(false); languageTranslatorImplUnderTest.registerDecoder(subject, baseDecoder); verify(mockDecoderRegistry).put(anyString(), any(BaseDecoder.class)); }