Fix invalid String representation for composed RequestPredicates

Issue: SPR-17594
This commit is contained in:
Arjen Poutsma
2018-12-12 15:33:11 +01:00
parent 106ae0cc5b
commit 058608021e
3 changed files with 42 additions and 25 deletions

View File

@@ -23,8 +23,15 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import static org.junit.Assert.*;
import static org.springframework.web.reactive.function.server.RequestPredicates.*;
import static org.springframework.web.reactive.function.server.RouterFunctions.*;
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RequestPredicates.accept;
import static org.springframework.web.reactive.function.server.RequestPredicates.contentType;
import static org.springframework.web.reactive.function.server.RequestPredicates.method;
import static org.springframework.web.reactive.function.server.RequestPredicates.methods;
import static org.springframework.web.reactive.function.server.RequestPredicates.path;
import static org.springframework.web.reactive.function.server.RequestPredicates.pathExtension;
import static org.springframework.web.reactive.function.server.RequestPredicates.queryParam;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
/**
* @author Arjen Poutsma
@@ -75,6 +82,11 @@ public class ToStringVisitorTests {
testPredicate(method(HttpMethod.GET).or(path("/foo")), "(GET || /foo)");
testPredicate(method(HttpMethod.GET).negate(), "!(GET)");
testPredicate(GET("/foo")
.or(contentType(MediaType.TEXT_PLAIN))
.and(accept(MediaType.APPLICATION_JSON).negate()),
"(((GET && /foo) || Content-Type: text/plain) && !(Accept: application/json))");
}
private void testPredicate(RequestPredicate predicate, String expected) {