如何模拟私有实例变量groovy

时间:2018-09-27 08:21:16

标签: groovy java-8

我有以下代码

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。

0 个答案:

没有答案