WIP:BAD
[demos/testing] / src / test / java / de / juplo / demo / RemoteContentServiceTest.java
index 40a85b5..e458479 100644 (file)
@@ -1,39 +1,47 @@
 package de.juplo.demo;
 
 
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.when;
-import org.mockito.junit.jupiter.MockitoExtension;
 import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.springframework.web.reactive.function.client.WebClient;
 import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec;
 import org.springframework.web.reactive.function.client.WebClient.RequestHeadersUriSpec;
 import org.springframework.web.reactive.function.client.WebClient.ResponseSpec;
 import reactor.core.publisher.Mono;
+import reactor.test.StepVerifier;
 
 
 /**
  * Unit-Test for class {@link RemoteContentService}.
  * @author Kai Moritz
  */
-@ExtendWith(MockitoExtension.class)
+@ExtendWith(SpringExtension.class)
 public class RemoteContentServiceTest
 {
   RemoteContentService service;
 
   @MockBean
   WebClient webClient;
-  @MockBean
+  @MockBean(name = "uriSpec")
   RequestHeadersUriSpec uriSpec;
-  @MockBean
+  @MockBean(name = "headersSpec")
   RequestHeadersSpec headersSpec;
-  @MockBean
+  @MockBean(name = "responseSpec")
   ResponseSpec responseSpec;
 
 
+  @BeforeEach
+  void setUp()
+  {
+    service = new RemoteContentService(webClient);
+  }
+
+
   @Test
   void test()
   {
@@ -44,7 +52,9 @@ public class RemoteContentServiceTest
 
     Mono<String> result = service.getRemoteText("/foo");
 
-    assertThat(result).isNotNull();
-    assertThat(result.block()).isEqualTo("bar");
+    StepVerifier
+        .create(result)
+        .expectNext("bar")
+        .verifyComplete();
   }
 }