I'm trying to make sure that after some actions, no new records have appeared in the database, for this I use the following construction:
messages = new String[] {"message1", "message2"};
await("wait")
.during(Duration.ofSeconds(15))
.atMost(Duration.ofSeconds(19))
.pollInterval(Duration.ofSeconds(1))
.until(() -> databaseService.getJournalRecords().stream()
.map(JournalRecord::getMessage)
.filter(Arrays.asList(messages)::contains)
.findFirst()
.orElse(null), Matchers.nullValue()
);
But I am getting an error:
org.awaitility.core.ConditionTimeoutException: Condition with alias 'wait' didn't complete within 19 seconds because lambda expression in my.path.MyClass: expected null but was null.
when using the construction
.orElse("some value"), Matchers.equalTo("some value")
I get a similar error
org.awaitility.core.ConditionTimeoutException: Condition with alias 'wait' didn't complete within 19 seconds because lambda expression in my.path.MyClass: expected "some value" but was "some value".
How to build awaitility correctly, what is my mistake?