|
17 | 17 | package org.springframework.cloud.function.context.catalog;
|
18 | 18 |
|
19 | 19 |
|
| 20 | +import java.lang.reflect.Method; |
20 | 21 | import java.lang.reflect.ParameterizedType;
|
21 | 22 | import java.lang.reflect.Type;
|
| 23 | +import java.util.Date; |
22 | 24 | import java.util.List;
|
23 | 25 | import java.util.Map;
|
| 26 | +import java.util.concurrent.atomic.AtomicReference; |
24 | 27 | import java.util.function.Consumer;
|
25 | 28 | import java.util.function.Function;
|
26 | 29 | import java.util.function.Supplier;
|
|
31 | 34 | import reactor.util.function.Tuple2;
|
32 | 35 | import reactor.util.function.Tuple3;
|
33 | 36 |
|
| 37 | +import org.springframework.core.MethodParameter; |
34 | 38 | import org.springframework.core.ParameterizedTypeReference;
|
35 | 39 | import org.springframework.messaging.Message;
|
| 40 | +import org.springframework.util.ReflectionUtils; |
36 | 41 |
|
37 | 42 | import static org.assertj.core.api.Assertions.assertThat;
|
38 | 43 |
|
|
42 | 47 | *
|
43 | 48 | */
|
44 | 49 | @SuppressWarnings("unused")
|
45 |
| -public class FunctionTypeUtilsTests { |
| 50 | +public class FunctionTypeUtilsTests<T> { |
46 | 51 |
|
47 | 52 | @Test
|
48 | 53 | public void testFunctionTypeFrom() throws Exception {
|
@@ -147,6 +152,21 @@ public void testIsTypeCollection() {
|
147 | 152 | assertThat(FunctionTypeUtils.isTypeCollection(new ParameterizedTypeReference<Flux<Message<List<String>>>>() { }.getType())).isFalse();
|
148 | 153 | }
|
149 | 154 |
|
| 155 | + @Test |
| 156 | + public void testNoNpeFromIsMessage() { |
| 157 | + FunctionTypeUtilsTests<Date> testService = new FunctionTypeUtilsTests<>(); |
| 158 | + |
| 159 | + Method methodUnderTest = |
| 160 | + ReflectionUtils.findMethod(testService.getClass(), "notAMessageMethod", AtomicReference.class); |
| 161 | + MethodParameter methodParameter = MethodParameter.forExecutable(methodUnderTest, 0); |
| 162 | + |
| 163 | + assertThat(FunctionTypeUtils.isMessage(methodParameter.getGenericParameterType())).isFalse(); |
| 164 | + } |
| 165 | + |
| 166 | + void notAMessageMethod(AtomicReference<T> payload) { |
| 167 | + |
| 168 | + } |
| 169 | + |
150 | 170 | private static Function<String, Integer> function() {
|
151 | 171 | return null;
|
152 | 172 | }
|
|
0 commit comments