import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import static org.mockito.Mockito.when;
+import org.springframework.web.reactive.function.client.WebClientResponseException;
+import org.springframework.web.reactive.function.client.WebClientResponseException.NotFound;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
.expectComplete()
.verify();
}
+
+ @Test
+ @DisplayName("Data not found on remote-server")
+ void testResponseNotFoud()
+ {
+ when(service.getRemoteText("foo")).thenReturn(Mono.error(exception(404)));
+
+ Mono<String> result = controller.fetch("foo");
+
+ StepVerifier
+ .create(result)
+ .expectError(NotFound.class)
+ .verify();
+ }
+
+
+ WebClientResponseException exception(int status)
+ {
+ return WebClientResponseException.create(status, "", null, null, null);
+ }
}