JUnit assertions within in Java 8 stream
问题 Say I have three objects that I save to the database and set the db generated ID into. I don't know the order of the objects returned from the method saveToDb . But I want to junit test that those generated IDs are there. How do I do that within in stream? I want to do something like this: List<MyObject> myObjects = getObjects(); numRecords = saveToDb(myObjects); // numRecords=3 List<Integer> intArray = Arrays.asList(1, 2, 3); intArray.stream() .forEach(it -> myObjects.stream() .filter(it2 ->