|
30 | 30 | import static org.assertj.core.api.AssertionsForClassTypes.assertThat; |
31 | 31 | import static org.junit.jupiter.api.Assertions.assertEquals; |
32 | 32 | import static org.junit.jupiter.api.Assertions.assertNotEquals; |
| 33 | +import static org.junit.jupiter.api.Assertions.assertNull; |
33 | 34 | import static org.junit.jupiter.api.Assertions.assertTrue; |
34 | 35 | import static org.mockito.ArgumentMatchers.any; |
35 | 36 | import static org.mockito.Mockito.mock; |
@@ -68,8 +69,8 @@ void getAsyncHeaders(Class<?> classWithOperationBindingProcessor) throws NoSuchM |
68 | 69 | SchemaObject headerWithoutValueResolved = |
69 | 70 | (SchemaObject) headers.getProperties().get("headerWithoutValueResolved"); |
70 | 71 | assertEquals("string", headerWithoutValueResolved.getType()); |
71 | | - assertTrue(headerWithoutValueResolved.getExamples().isEmpty()); |
72 | | - assertTrue(headerWithoutValueResolved.getEnumValues().isEmpty()); |
| 72 | + assertNull(headerWithoutValueResolved.getExamples()); |
| 73 | + assertNull(headerWithoutValueResolved.getEnumValues()); |
73 | 74 | assertEquals("descriptionResolved", headerWithoutValueResolved.getDescription()); |
74 | 75 | } |
75 | 76 |
|
@@ -120,6 +121,36 @@ void getAsyncHeadersWithoutSchemaName() throws NoSuchMethodException { |
120 | 121 | .build()); |
121 | 122 | } |
122 | 123 |
|
| 124 | + @Test |
| 125 | + void getAsyncHeadersWithoutValue() throws NoSuchMethodException { |
| 126 | + // given |
| 127 | + Method m = ClassWithHeaders.class.getDeclaredMethod("withoutValue", String.class); |
| 128 | + AsyncOperation operation = m.getAnnotation(AsyncListener.class).operation(); |
| 129 | + |
| 130 | + StringValueResolver stringValueResolver = mock(StringValueResolver.class); |
| 131 | + when(stringValueResolver.resolveStringValue(any())) |
| 132 | + .thenAnswer(invocation -> invocation.getArgument(0).toString() + "Resolved"); |
| 133 | + |
| 134 | + // when |
| 135 | + SchemaObject headers = AsyncAnnotationUtil.getAsyncHeaders(operation, stringValueResolver); |
| 136 | + |
| 137 | + // then |
| 138 | + assertThat(headers) |
| 139 | + .isEqualTo(SchemaObject.builder() |
| 140 | + .type(SchemaType.OBJECT) |
| 141 | + .title("Headers-472917891") |
| 142 | + .properties(Map.of( |
| 143 | + "headerResolved", |
| 144 | + SchemaObject.builder() |
| 145 | + .type(SchemaType.STRING) |
| 146 | + .title("headerResolved") |
| 147 | + .description("descriptionResolved") |
| 148 | + .enumValues(null) |
| 149 | + .examples(null) |
| 150 | + .build())) |
| 151 | + .build()); |
| 152 | + } |
| 153 | + |
123 | 154 | @Test |
124 | 155 | void generatedHeaderSchemaNameShouldBeUnique() throws NoSuchMethodException { |
125 | 156 | // given |
@@ -424,6 +455,20 @@ private void emptyHeaders(String payload) {} |
424 | 455 | @TestOperationBindingProcessor.TestOperationBinding() |
425 | 456 | private void withoutSchemaName(String payload) {} |
426 | 457 |
|
| 458 | + @AsyncListener( |
| 459 | + operation = |
| 460 | + @AsyncOperation( |
| 461 | + channelName = "${test.property.test-channel}", |
| 462 | + headers = |
| 463 | + @AsyncOperation.Headers( |
| 464 | + values = { |
| 465 | + @AsyncOperation.Headers.Header( |
| 466 | + name = "header", |
| 467 | + description = "description") |
| 468 | + }))) |
| 469 | + @TestOperationBindingProcessor.TestOperationBinding() |
| 470 | + private void withoutValue(String payload) {} |
| 471 | + |
427 | 472 | @AsyncListener( |
428 | 473 | operation = |
429 | 474 | @AsyncOperation( |
|
0 commit comments