Can any explain why this code fails with “java.lang.AssertionError: Expected value Hey for key OID, key not present”:
@Test
void name() {
StepVerifier.create(Mono.just("Start")
.map(val -> Optional.of(val)).defaultIfEmpty(Optional.empty()) // <---- point of interest 1
.flatMap(val -> Mono.just(val).then().contextWrite(ctx -> ctx.put(OID, "Hey"))))
.expectAccessibleContext()
.contains("OID", "Hey") // <---- point of interest 2
.then()
.verifyComplete();
}
The flatMap is never executed.
The code succeeds if I’m removing “point of interest 1”:
@Test
void name() {
StepVerifier.create(Mono.just("Start")
.flatMap(val -> Mono.just(val).then().contextWrite(ctx -> ctx.put(OID, "Hey"))))
.expectAccessibleContext()
.contains("OID", "Hey") // <---- point of interest 2
.then()
.verifyComplete();
}
My clear idea is that expectAccessibleContext()
may be what causes this odd behaviour. But I don’t have any good reason why.
StepVerifier to succeed
So Hard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.