我有以下代码
public class Employee{
private List<String> employeeDetails=new ArrayList<>();
@Autowired
private EmployeeEntity employeeEntity;// this is an interface
public Map<String, List<String>> saveEmployee(Stream<Employee> employeeStream) {
employeeDetails= employeeEntity.findEntities(Arrays.asList(employeeNameAttribute, employeeAccountAttribute));
}
employeeDetails.save() //null pointer at this place
}
In the interface it is defined as:
@Repository
public interface EmployeeEntity extends JpaRepository<Entities,Long> {
List<String> findEntities(@Param(value = "attributeNames") List<String> attributeNames);
}
我想为Employee类编写常规测试,但是变量employeeDetails被计算为null,因此抛出NPE。