0

I am writing the test cases for one of the Spring Webflux function as:

public Mono<ClassTempKey> getKey(Param param1) {
    return getKeyFromBaseClass();
}

StepVerifier.create(class.getKey(param1)
   .assertNext(key -> {
      assertThat(key.getValue().isEqualTo(value);
   }).verifyComplete();

I am getting the following output

expected: onNext()  actual: onComplete()

The method will return a single key value. Not sure where I am doing wrong.

suchit
  • 57
  • 9
  • It means your flow is not returning value (onNext signal) but returning empty (onComplete signal). You can add `log()` operator to your flow to see details – Alex Dec 29 '22 at 16:35

1 Answers1

0

That would be clearer if you'd post the actual code of getKeyFromBaseClass() method.

But it looks like that method returns empty Mono, without any value. In reactor empty mono without additional handling returns onComplete signal (not onNext), so you can see it in your test.

kerbermeister
  • 2,985
  • 3
  • 11
  • 30