diff --git a/spring-cloud-function-samples/spring-cloud-function-sample/pom.xml b/spring-cloud-function-samples/spring-cloud-function-sample/pom.xml index 90f38a29c..033efb6eb 100644 --- a/spring-cloud-function-samples/spring-cloud-function-sample/pom.xml +++ b/spring-cloud-function-samples/spring-cloud-function-sample/pom.xml @@ -38,6 +38,11 @@ spring-boot-configuration-processor true + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/spring-cloud-function-samples/spring-cloud-function-sample/src/test/java/com/example/SampleApplicationTests.java b/spring-cloud-function-samples/spring-cloud-function-sample/src/test/java/com/example/SampleApplicationTests.java new file mode 100644 index 000000000..481ff0172 --- /dev/null +++ b/spring-cloud-function-samples/spring-cloud-function-sample/src/test/java/com/example/SampleApplicationTests.java @@ -0,0 +1,56 @@ +/* + * Copyright 2016 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 com.example; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import org.junit.Test; + +import reactor.core.publisher.Flux; + +public class SampleApplicationTests { + + private final SampleApplication functions = new SampleApplication(); + + @Test + public void testUppercase() { + Flux output = functions.uppercase().apply(Flux.just("foo", "bar")); + List results = output.collectList().block(); + assertEquals(2, results.size()); + assertEquals("FOO", results.get(0)); + assertEquals("BAR", results.get(1)); + } + + @Test + public void testLowercase() { + Flux output = functions.lowercase().apply(Flux.just("FOO", "BAR")); + List results = output.collectList().block(); + assertEquals(2, results.size()); + assertEquals("foo", results.get(0)); + assertEquals("bar", results.get(1)); + } + + @Test + public void testWords() { + Flux output = functions.words().get(); + List results = output.collectList().block(); + assertEquals(2, results.size()); + assertEquals("foo", results.get(0)); + assertEquals("bar", results.get(1)); + } +}