@Test void findByIdTest() { Specification genericEntity = new Specification(); when(specificationRepo.findById(anyLong())).thenReturn(Optional.of(genericEntity)); Specification foundEntity = specificationService.findById(anyLong()); assertEquals(genericEntity, foundEntity); }
@Override public Specification findById(Long id) { log.info(LogMessage.IN_FIND_BY_ID, id); return specificationRepo .findById(id) .orElseThrow( () -> new NotFoundException(ErrorMessage.SPECIFICATION_VALUE_NOT_FOUND_BY_ID + id)); }
SpecificationServiceImpl implements SpecificationService { @Override public Specification findById(Long id) { log.info(LogMessage.IN_FIND_BY_ID, id); return specificationRepo .findById(id) .orElseThrow( () -> new NotFoundException(ErrorMessage.SPECIFICATION_VALUE_NOT_FOUND_BY_ID + id)); } }
SpecificationServiceImpl implements SpecificationService { @Override public Specification findById(Long id) { log.info(LogMessage.IN_FIND_BY_ID, id); return specificationRepo .findById(id) .orElseThrow( () -> new NotFoundException(ErrorMessage.SPECIFICATION_VALUE_NOT_FOUND_BY_ID + id)); }  }
SpecificationServiceImpl implements SpecificationService { @Override public Specification findById(Long id) { log.info(LogMessage.IN_FIND_BY_ID, id); return specificationRepo .findById(id) .orElseThrow( () -> new NotFoundException(ErrorMessage.SPECIFICATION_VALUE_NOT_FOUND_BY_ID + id)); }  @Override Specification save(Specification specification); @Override Specification findById(Long id); @Override List<Specification> findAll(); @Override Long deleteById(Long id); @Override Specification findByName(String specificationName); @Override List<SpecificationNameDto> findAllSpecificationDto(); }
SpecificationServiceImpl implements SpecificationService { @Override public Specification findById(Long id) { log.info(LogMessage.IN_FIND_BY_ID, id); return specificationRepo .findById(id) .orElseThrow( () -> new NotFoundException(ErrorMessage.SPECIFICATION_VALUE_NOT_FOUND_BY_ID + id)); }  @Override Specification save(Specification specification); @Override Specification findById(Long id); @Override List<Specification> findAll(); @Override Long deleteById(Long id); @Override Specification findByName(String specificationName); @Override List<SpecificationNameDto> findAllSpecificationDto();  }