WIP
authorKai Moritz <kai@juplo.de>
Mon, 13 Jan 2020 14:35:24 +0000 (15:35 +0100)
committerKai Moritz <kai@juplo.de>
Mon, 13 Jan 2020 18:54:07 +0000 (19:54 +0100)
--
TODO

* IT auf TestWebClient umstellen? MockMvc funktioniert nicht!
* Commit für IT ordentlich beschreiben
* RemoteContentRestController bei Einführung in RestController umbenennen
** Dort ordentlich die Scheidung text/html | text/plain umsetzen
** Dort Testfall kontrollieren
* Danach: Commit für RestController nach IT-Test verschieben
* Anpassung / Ergänzung des IT-Tests?

src/main/java/de/juplo/demo/RemoteContentController.java [deleted file]
src/main/java/de/juplo/demo/RemoteContentRestController.java [new file with mode: 0644]
src/test/java/de/juplo/demo/RemoteContentControllerTest.java [deleted file]
src/test/java/de/juplo/demo/RemoteContentRestControllerTest.java [new file with mode: 0644]

diff --git a/src/main/java/de/juplo/demo/RemoteContentController.java b/src/main/java/de/juplo/demo/RemoteContentController.java
deleted file mode 100644 (file)
index 422f5a6..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-package de.juplo.demo;
-
-
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-import reactor.core.publisher.Mono;
-
-
-/**
- * Fetches and returns data from remote-webserver.
- * @author Kai Moritz
- */
-@RestController
-public class RemoteContentController
-{
-  RemoteContentService service;
-
-
-  public RemoteContentController(RemoteContentService service)
-  {
-    this.service = service;
-  }
-
-
-  @GetMapping("/")
-  public Mono<String> fetch(@RequestParam String path)
-  {
-    return service.getRemoteText(path);
-  }
-}
diff --git a/src/main/java/de/juplo/demo/RemoteContentRestController.java b/src/main/java/de/juplo/demo/RemoteContentRestController.java
new file mode 100644 (file)
index 0000000..312dd3f
--- /dev/null
@@ -0,0 +1,32 @@
+package de.juplo.demo;
+
+
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Mono;
+
+
+/**
+ * Fetches and returns data from remote-webserver.
+ * @author Kai Moritz
+ */
+@RestController
+public class RemoteContentRestController
+{
+  RemoteContentService service;
+
+
+  public RemoteContentRestController(RemoteContentService service)
+  {
+    this.service = service;
+  }
+
+
+  @GetMapping(path = "/", produces = MediaType.TEXT_PLAIN_VALUE)
+  public Mono<String> fetch(@RequestParam String path)
+  {
+    return service.getRemoteText(path);
+  }
+}
diff --git a/src/test/java/de/juplo/demo/RemoteContentControllerTest.java b/src/test/java/de/juplo/demo/RemoteContentControllerTest.java
deleted file mode 100644 (file)
index fdba099..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-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 org.mockito.Mockito;
-import static org.mockito.Mockito.when;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-import reactor.core.publisher.Mono;
-
-
-/**
- * Unit-Test for class {@link RemoteContentController}.
- * @author Kai Moritz
- */
-@ExtendWith(SpringExtension.class)
-public class RemoteContentControllerTest
-{
-  RemoteContentController controller;
-  RemoteContentService service;
-
-
-  @BeforeEach
-  void setUp()
-  {
-    service = Mockito.mock(RemoteContentService.class);
-    controller = new RemoteContentController(service);
-  }
-
-
-  @Test
-  void test()
-  {
-    Mono<String> mono = Mono.empty();
-    when(service.getRemoteText("foo")).thenReturn(mono);
-
-    // when
-    Mono<String> result = controller.fetch("foo");
-
-    assertThat(result).isSameAs(mono);
-  }
-}
diff --git a/src/test/java/de/juplo/demo/RemoteContentRestControllerTest.java b/src/test/java/de/juplo/demo/RemoteContentRestControllerTest.java
new file mode 100644 (file)
index 0000000..c034f0f
--- /dev/null
@@ -0,0 +1,44 @@
+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 org.mockito.Mockito;
+import static org.mockito.Mockito.when;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import reactor.core.publisher.Mono;
+
+
+/**
+ * Unit-Test for class {@link RemoteContentRestController}.
+ * @author Kai Moritz
+ */
+@ExtendWith(SpringExtension.class)
+public class RemoteContentRestControllerTest
+{
+  RemoteContentRestController controller;
+  RemoteContentService service;
+
+
+  @BeforeEach
+  void setUp()
+  {
+    service = Mockito.mock(RemoteContentService.class);
+    controller = new RemoteContentRestController(service);
+  }
+
+
+  @Test
+  void test()
+  {
+    Mono<String> mono = Mono.empty();
+    when(service.getRemoteText("foo")).thenReturn(mono);
+
+    // when
+    Mono<String> result = controller.fetch("foo");
+
+    assertThat(result).isSameAs(mono);
+  }
+}