IntegrationContextServiceImpl implements IntegrationContextService { @Override public IntegrationContextEntity findById(String id) { return commandExecutor.execute(new RetrieveIntegrationContextsCmd(id)); } IntegrationContextServiceImpl(CommandExecutor commandExecutor); @Override IntegrationContextEntity findById(String id); @Override void deleteIntegrationContext(IntegrationContextEntity integrationContextEntity);  }
@Test public void findByIdShouldExecuteRetrieveIntegrationContextCmd() { IntegrationContextEntity entity = mock(IntegrationContextEntity.class); given(commandExecutor.execute(any(RetrieveIntegrationContextsCmd.class))).willReturn(entity); IntegrationContextEntity commandResult = integrationContextService.findById("id"); assertThat(commandResult).isEqualTo(entity); }