I have a method in my service implementation class and i can not add correctly it's testing method. It gives me Null pointer exception. Spring Boot project - JUnit 5.
Method
public Page<CompanyGroup> findByNameContainingIgnoreCase(String name, Pageable pageable) {
log.debug("Request to query all CompanyGroups");
Page<CompanyGroup> result = companyGroupRepository.findByNameContainingIgnoreCase(name, pageable);
return result;
}
Test Method
void findByNameContainingIgnoreCase() {
Pageable pageable = PageRequest.of(0, 5, Sort.by(
Sort.Order.asc("name"),
Sort.Order.desc("id")));
Page<CompanyGroup> result;
result = companyGroupRepository.findByNameContainingIgnoreCase("thrylos", pageable);
assertEquals(0, result.getTotalElements());
result = companyGroupService.findByNameContainingIgnoreCase("Olympiakos", pageable);
assertEquals(1, result.getTotalElements());
result = companyGroupService.findByNameContainingIgnoreCase("olympiakos", pageable);
assertEquals(1, result.getTotalElements());
}
Aucun commentaire:
Enregistrer un commentaire