--- /dev/null
+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);
+ }
+}
--- /dev/null
+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);
+ }
+}