List<ReservationArrival> resArrivalList = new ArrayList<>();
ReservationArrival reservArr = new ReservationArrival();
reservArr.setArrivalStatus("DISPATCHED");
reservArr.setReservationArrivalId(9888888L);
reservArr.setDispatchTime("2018-03-07 17:29:30");
EasyMock.replay( resArrivalList );
expect(namedParameterJdbcTemplate.query(EasyMock.anyObject(String.class),
EasyMock.anyObject(MapSqlParameterSource.class),
EasyMock.anyObject(ReservationArrivalMapper.class))).andReturn(resArrivalList);
我的模拟对象namedParameterJdbcTemplate返回空列表
答案 0 :(得分:2)
您需要将模拟服务(namedParameterJdbcTemplate
)设置为重播模式,而不是resArrivalList
设置为重播模式,List<ReservationArrival> resArrivalList = new ArrayList<>();
ReservationArrival reservArr = new ReservationArrival();
reservArr.setArrivalStatus("DISPATCHED");
reservArr.setReservationArrivalId(9888888L);
reservArr.setDispatchTime("2018-03-07 17:29:30");
expect(namedParameterJdbcTemplate.query(EasyMock.anyObject(String.class),
EasyMock.anyObject(MapSqlParameterSource.class),
EasyMock.anyObject(ReservationArrivalMapper.class))).andReturn(resArrivalList);
EasyMock.replay( namedParameterJdbcTemplate );
只是模拟对象用作返回值的普通对象。
同样,重播调用必须在模拟程序设置之后进行。
类似的事情应该起作用:
Vagrantfile