<properties>
<java.version>1.8</java.version>
+ <jsoup.version>1.12.1</jsoup.version>
</properties>
<dependencies>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jsoup</groupId>
+ <artifactId>jsoup</artifactId>
+ <version>${jsoup.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ </plugin>
</plugins>
</build>
--- /dev/null
+package de.juplo.demo;
+
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+import org.springframework.test.web.reactive.server.WebTestClient;
+import reactor.core.publisher.Mono;
+
+
+/**
+ * Narrow Integration-Test for the {@link HtmlController}.
+ * @author Kai Moritz
+ */
+@ExtendWith(SpringExtension.class)
+@WebFluxTest()
+public class HtmlControllerIT
+{
+ @Autowired
+ WebTestClient webClient;
+ @MockBean
+ RemoteContentService service;
+
+
+ @Test
+ @DisplayName("Mapping for HtmlController: /?path=foo")
+ void testUriWithParameter()
+ {
+ when(service.getRemoteText("foo")).thenReturn(Mono.just("bar"));
+ webClient
+ .get()
+ .uri("/?path=foo")
+ .exchange()
+ .expectStatus().isOk()
+ .expectBody(String.class).value(rendered ->
+ {
+ Document doc = Jsoup.parse(rendered);
+ assertThat(
+ doc.select("html > body > main > div > div > div > pre").text())
+ .isEqualTo("bar");
+ });
+ verify(service).getRemoteText("foo");
+ }
+}