GH-358 Fixd NPE in flux FunctionWebUtils

added tests

Resolves #358
This commit is contained in:
Oleg Zhurakousky
2019-04-29 16:07:56 +02:00
parent f16a2c76cf
commit d9582a9867
3 changed files with 39 additions and 1 deletions

View File

@@ -62,7 +62,7 @@ public final class FunctionWebUtils {
String name = path;
String[] splitPath = path.split("/");
Function<Object, Object> function = null;
for (int i = 0; i < splitPath.length || function != null; i++) {
for (int i = 0; i < splitPath.length && functionForGet == null; i++) {
String element = splitPath[i];
if (builder.length() > 0) {
builder.append("/");

View File

@@ -244,6 +244,14 @@ public class HttpGetIntegrationTests {
.getBody()).isEqualTo("{\"value\":321}");
}
@Test
public void compose() throws Exception {
ResponseEntity<String> result = this.rest.exchange(RequestEntity
.get(new URI("/concat,reverse/foo")).accept(MediaType.TEXT_PLAIN).build(),
String.class);
assertThat(result.getBody()).isEqualTo("oofoof");
}
private String sse(String... values) {
return "data:" + StringUtils.arrayToDelimitedString(values, "\n\ndata:") + "\n\n";
}
@@ -259,6 +267,17 @@ public class HttpGetIntegrationTests {
args);
}
@Bean
public Function<Flux<String>, Flux<String>> concat() {
return flux -> flux.map(v -> v + v);
}
@Bean
public Function<Flux<String>, Flux<String>> reverse() {
return flux -> flux.log()
.map(value -> new StringBuilder(value.trim()).reverse().toString());
}
@Bean({ "uppercase", "post/more" })
public Function<Flux<String>, Flux<String>> uppercase() {
return flux -> flux.log()

View File

@@ -237,6 +237,14 @@ public class HttpGetIntegrationTests {
.getBody()).isEqualTo("{\"value\":321}");
}
@Test
public void compose() throws Exception {
ResponseEntity<String> result = this.rest.exchange(RequestEntity
.get(new URI("/concat,reverse/foo")).accept(MediaType.TEXT_PLAIN).build(),
String.class);
assertThat(result.getBody()).isEqualTo("oofoof");
}
private String sse(String... values) {
return "data:" + StringUtils.arrayToDelimitedString(values, "\n\ndata:") + "\n\n";
}
@@ -252,6 +260,17 @@ public class HttpGetIntegrationTests {
args);
}
@Bean
public Function<Flux<String>, Flux<String>> concat() {
return flux -> flux.map(v -> v + v);
}
@Bean
public Function<Flux<String>, Flux<String>> reverse() {
return flux -> flux.log()
.map(value -> new StringBuilder(value.trim()).reverse().toString());
}
@Bean({ "uppercase", "post/more" })
public Function<Flux<String>, Flux<String>> uppercase() {
return flux -> flux.log()