Open itxiaobai123 opened 2 years ago
mock同样遇到byId失败,但byIds成功。 `public interface Repository<AGGREGATE, ID extends Serializable>{
/**
* 按id查找
*
* @param id
* @return
*/
AGGREGATE byId(ID id);
/**
* 按id查找集合
*
* @param ids
* @return
*/
List<AGGREGATE> byIds(List<ID> ids);
} public interface TaskRepository extends Repository<TaskDto,Long>{ }
@Repository public class TaskRepositoryImpl implements TaskRepository { @Override public TaskDto byId(Long id) { return taskMapping.targetToSource(taskInfoDao.selectById(id)); }
@Override
public List<TaskDto> byIds(List<Long> ids) {
final List<TaskEntity> list = new LambdaQueryChainWrapper<>(taskInfoDao).in(TaskEntity::getId, ids).list();
return taskMapping.targetToSource(list);
}
}`
解决了,Mock方法写的不对导致。
正确写法如下
@MockInvoke(targetClass = TaskRepository.class,targetMethod = "byId")
public
mybatisplus的BaseMapper中selectOne方法mock失败而delete却mock成功?有大佬知道这是为什么吗