Ok, i have a database which gets filled up with random objects type of MandantEntity. I have a finder, which finds items by a given array of ids. I would like to check if the returned list has all the items (ids), that I ask for (ids array) so i thought to do it like the following:
@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))));
}
but does not work...
java.lang.AssertionError: Expected: iterable containing [hasProperty("id", iterable containing [[<1L>, <2L>, <3L>, <4L>, <5L>, <6L>, <7L>, <8L>, <9L>, <10L>]])] but: item 0: property 'id' was <1L>
I have no idea how to arrange this. Have anyone an Idea ?
Greetings Jens