我怎样才能做一个汉克雷斯特Assert?它应该询问一个项目列表是否具有另一个列表中的属性?

r3i60tvu  于 2021-06-27  发布在  Java
关注(0)|答案(0)|浏览(197)

好的,我有一个数据库,里面装满了随机对象,比如mandantity。我有一个finder,它通过给定的id数组查找项目。我想检查返回的列表是否包含我请求的所有项(ID)(ID数组),因此我想按以下方式执行:

@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:应为:iterable containing[hasproperty(“id”,iterable containing[[<1l>,<2l>,<3l>,<4l>,<5l>,<6l>,<7l>,<8l>,<9l>,<10l>]),但:项0:属性“id”为<1l>
我不知道怎么安排。有人知道吗?
你好,詹斯

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题