| 31 | import org.springframework.boot.test.context.SpringBootTest; |
| 32 | |
| 33 | @SpringBootTest(webEnvironment = DEFINED_PORT, classes = Server.class) |
| 34 | class FormPropertyTest { |
| 35 | |
| 36 | private static FormClient API; |
| 37 | |
| 38 | @TempDir static Path logDir; |
| 39 | |
| 40 | @BeforeAll |
| 41 | static void configureClient() { |
| 42 | var logFile = logDir.resolve("log.txt").toString(); |
| 43 | |
| 44 | API = |
| 45 | Feign.builder() |
| 46 | .encoder(new FormEncoder(new JacksonEncoder())) |
| 47 | .logger(new JavaLogger(FormPropertyTest.class).appendToFile(logFile)) |
| 48 | .logLevel(FULL) |
| 49 | .target(FormClient.class, "http://localhost:8080"); |
| 50 | } |
| 51 | |
| 52 | @Test |
| 53 | void test() { |
| 54 | var dto = new FormDto("Amigo", 23); |
| 55 | |
| 56 | assertThat(API.postData(dto)).isEqualTo("Amigo=23"); |
| 57 | } |
| 58 | |
| 59 | interface FormClient { |
| 60 | |
| 61 | @RequestLine("POST /form-data") |
| 62 | @Headers("Content-Type: application/x-www-form-urlencoded") |
| 63 | String postData(FormDto dto); |
| 64 | } |
| 65 | } |
nothing calls this directly
no outgoing calls
no test coverage detected