Inspect FunctionType to extract collection item type
Resurrects some code from #222 (the test didn't go far enough when that issue was closed).
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.0.BUILD-SNAPSHOT</version>
|
||||
<version>2.1.0.RC1</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.0.M4</version>
|
||||
<version>2.1.0.RC1</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.0.M1</version>
|
||||
<version>2.1.0.RC1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<spring-cloud-function.version>2.0.0.BUILD-SNAPSHOT</spring-cloud-function.version>
|
||||
<spring-cloud-stream.version>Fishtown.BUILD-SNAPSHOT</spring-cloud-stream.version>
|
||||
<reactor.version>3.1.2.RELEASE</reactor.version>
|
||||
<wrapper.version>1.0.10.RELEASE</wrapper.version>
|
||||
<wrapper.version>1.0.17.RELEASE</wrapper.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.0.M1</version>
|
||||
<version>2.1.0.RC1</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.example;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -41,40 +42,38 @@ public class SampleApplicationTests {
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
private TestRestTemplate rest = new TestRestTemplate();
|
||||
|
||||
@Test
|
||||
public void words() {
|
||||
assertThat(new TestRestTemplate()
|
||||
.getForObject("http://localhost:" + port + "/words", String.class))
|
||||
assertThat(rest.getForObject("http://localhost:" + port + "/words", String.class))
|
||||
.isEqualTo("[{\"value\":\"foo\"},{\"value\":\"bar\"}]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uppercase() {
|
||||
assertThat(new TestRestTemplate().postForObject(
|
||||
"http://localhost:" + port + "/uppercase", "[{\"value\":\"foo\"}]",
|
||||
String.class)).isEqualTo("[{\"value\":\"FOO\"}]");
|
||||
assertThat(rest.postForObject("http://localhost:" + port + "/uppercase",
|
||||
"[{\"value\":\"foo\"}]", String.class))
|
||||
.isEqualTo("[{\"value\":\"FOO\"}]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void composite() {
|
||||
assertThat(new TestRestTemplate()
|
||||
.getForObject("http://localhost:" + port + "/words,uppercase", String.class))
|
||||
.isEqualTo("[{\"value\":\"FOO\"},{\"value\":\"BAR\"}]");
|
||||
assertThat(rest.getForObject("http://localhost:" + port + "/words,uppercase",
|
||||
String.class)).isEqualTo("[{\"value\":\"FOO\"},{\"value\":\"BAR\"}]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void single() {
|
||||
assertThat(new TestRestTemplate().postForObject(
|
||||
"http://localhost:" + port + "/uppercase", "{\"value\":\"foo\"}",
|
||||
String.class)).isEqualTo("{\"value\":\"FOO\"}");
|
||||
assertThat(rest.postForObject("http://localhost:" + port + "/uppercase",
|
||||
"{\"value\":\"foo\"}", String.class)).isEqualTo("{\"value\":\"FOO\"}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lowercase() {
|
||||
assertThat(new TestRestTemplate().postForObject(
|
||||
"http://localhost:" + port + "/lowercase", "[{\"value\":\"Foo\"}]",
|
||||
String.class)).isEqualTo("[{\"value\":\"foo\"}]");
|
||||
assertThat(rest.postForObject("http://localhost:" + port + "/lowercase",
|
||||
"[{\"value\":\"Foo\"}]", String.class))
|
||||
.isEqualTo("[{\"value\":\"foo\"}]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,10 +84,25 @@ public class SampleApplicationTests {
|
||||
map.put("A", Arrays.asList("1", "2", "3"));
|
||||
map.put("B", Arrays.asList("5", "6"));
|
||||
|
||||
assertThat(new TestRestTemplate().exchange(RequestEntity.post(new URI("http://localhost:" + port + "/sum"))
|
||||
.accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_FORM_URLENCODED)
|
||||
.body(map), String.class).getBody())
|
||||
.isEqualTo("[{\"A\":6,\"B\":11}]");
|
||||
assertThat(rest.exchange(
|
||||
RequestEntity.post(new URI("http://localhost:" + port + "/sum"))
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.contentType(MediaType.APPLICATION_FORM_URLENCODED).body(map),
|
||||
String.class).getBody()).isEqualTo("[{\"A\":6,\"B\":11}]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void multipart() throws Exception {
|
||||
|
||||
LinkedMultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
||||
|
||||
map.put("A", Arrays.asList("1", "2", "3"));
|
||||
map.put("B", Arrays.asList("5", "6"));
|
||||
|
||||
assertThat(rest.exchange(
|
||||
RequestEntity.post(new URI("http://localhost:" + port + "/sum")).accept(MediaType.APPLICATION_JSON)
|
||||
.contentType(MediaType.MULTIPART_FORM_DATA).body(map),
|
||||
String.class).getBody()).isEqualTo("[{\"A\":6,\"B\":11}]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.0.M1</version>
|
||||
<version>2.1.0.RC1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud-function.version>2.0.0.BUILD-SNAPSHOT</spring-cloud-function.version>
|
||||
<wrapper.version>1.0.13.RELEASE</wrapper.version>
|
||||
<wrapper.version>1.0.17.RELEASE</wrapper.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
Reference in New Issue
Block a user