Added support for input Collection param
Added support for function parameter type Collection Updated both Jackson and Gson mappers Defined a new toObject() operation on JsonMapper and deprecated the old Resolves #210
This commit is contained in:
committed by
Dave Syer
parent
435e4d0438
commit
2e5c6d22b5
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.function.test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
|
||||
import org.springframework.cloud.function.context.test.FunctionalSpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@FunctionalSpringBootTest("spring.main.web-application-type=reactive")
|
||||
@AutoConfigureWebTestClient
|
||||
public class FunctionalWithInputCollectionTests {
|
||||
|
||||
@Autowired
|
||||
private WebTestClient client;
|
||||
|
||||
@Test
|
||||
public void words() throws Exception {
|
||||
client.post().uri("/").body(Mono.just("[\"foo\", \"bar\"]"), String.class).exchange()
|
||||
.expectStatus().isOk().expectBody(String.class).isEqualTo("[FOO, BAR]");
|
||||
}
|
||||
|
||||
@SpringBootConfiguration
|
||||
protected static class TestConfiguration implements Function<List<String>, String> {
|
||||
@Override
|
||||
public String apply(List<String> value) {
|
||||
return value.toString().toUpperCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user