### Question:
BlockchainEventServiceImpl implements BlockchainEventService { @Override public Optional<BlockchainEventDto> findOne(final Long id) { return mapper.mapToOptional(blockchainEventRepo.findOne(id).orElse(null)); } BlockchainEventServiceImpl(final BlockchainEventRepository blockchainEventRepo, final BlockchainEventDtoMapper mapper); @Override Optional<BlockchainEventDto> findOne(final Long id);  }### Answer:
@Test void findOne() { final long blockcheinEventId = 7546L; final BlockchainEvent blockchainEvent = mock(BlockchainEvent.class); final BlockchainEventDto blockchainEventDto = mock(BlockchainEventDto.class); when(blockchainEventRepo.findOne(blockcheinEventId)).thenReturn(Optional.of(blockchainEvent)); when(mapper.mapToOptional(same(blockchainEvent))).thenReturn(Optional.of(blockchainEventDto)); final Optional<BlockchainEventDto> result = service.findOne(blockcheinEventId); assertThat(result).containsSame(blockchainEventDto); }
@Test void findOne_notFound() { final long blockcheinEventId = 7546L; when(blockchainEventRepo.findOne(blockcheinEventId)).thenReturn(Optional.empty()); when(mapper.mapToOptional(null)).thenReturn(Optional.empty()); final Optional<BlockchainEventDto> result = service.findOne(blockcheinEventId); assertThat(result).isEmpty(); }