【发布时间】:2021-04-14 00:38:51
【问题描述】:
好的,我有一个数据库,里面填满了 MandantEntity 的随机对象类型。我有一个查找器,它通过给定的 id 数组查找项目。 我想检查返回的列表是否包含我要求的所有项目(ids)(ids array),所以我想这样做如下:
@Test
public void testFindById() {
long[] ids = new long[10];
for (int j = 0; j < ids.length; j++) {
long l = ids[j];
MandantEntity mandantEntity = getMandant(j);
MandantEntity save = mandantRepository.save(mandantEntity);
ids[j] = save.getId();
}
final List<MandantEntity> entities = mandantRepository.findById(ids);
assertTrue(entities.size() == ids.length);
assertThat(entities, contains(hasProperty("id", contains(ids))));
}
但不起作用...
java.lang.AssertionError: 预期:可迭代包含 [hasProperty("id",可迭代包含 [[, , , , , , , , , ]])] 但是:第 0 项:属性 'id' 是
我不知道如何安排。 有人有想法吗?
你好,詹斯
【问题讨论】:
标签: java arrays junit hamcrest