33
44import io .github .springwolf .asyncapi .v3 .model .AsyncAPI ;
55import io .github .springwolf .asyncapi .v3 .model .channel .message .MessageObject ;
6+ import io .github .springwolf .asyncapi .v3 .model .components .ComponentSchema ;
67import io .github .springwolf .asyncapi .v3 .model .schema .SchemaReference ;
78import io .github .springwolf .core .asyncapi .AsyncApiService ;
89import io .github .springwolf .core .fixtures .SpringwolfIntegrationTest ;
9- import io .github .springwolf .core .integrationtests .application .complexSchema .PublisherGroupingComplexSchemaApplication ;
10+ import io .github .springwolf .core .integrationtests .application .complexSchema .ComplexSchemaApplication ;
1011import org .junit .jupiter .api .Nested ;
1112import org .junit .jupiter .api .Test ;
1213import org .springframework .beans .factory .annotation .Autowired ;
1617import static org .assertj .core .api .Assertions .assertThat ;
1718
1819@ Nested
19- @ SpringBootTest (classes = PublisherGroupingComplexSchemaApplication .class )
20+ @ SpringBootTest (classes = ComplexSchemaApplication .class )
2021@ SpringwolfIntegrationTest
2122@ TestPropertySource (
2223 properties = {
@@ -34,36 +35,48 @@ class GroupingWithComplexSchemaIntegrationTest {
3435 private AsyncApiService asyncApiService ;
3536
3637 @ Test
37- void shouldFindOnlyForGroupFoo () {
38+ void shouldFindOnlyForGroupUserMessage () {
3839 AsyncAPI asyncAPI = asyncApiService .getForGroupName ("UserMessage" ).get ();
3940
40- assertThat (asyncAPI .getChannels ().keySet ()).containsExactlyInAnyOrder ("publisher-channel " );
41- assertThat (asyncAPI .getChannels ().get ("publisher-channel " ).getMessages ())
41+ assertThat (asyncAPI .getChannels ().keySet ()).containsExactlyInAnyOrder ("publisher-channel2 " );
42+ assertThat (asyncAPI .getChannels ().get ("publisher-channel2 " ).getMessages ())
4243 .containsOnlyKeys (
43- "io.github.springwolf.core.integrationtests.application.complexSchema.PublisherGroupingComplexSchemaApplication .ComplexPublisher.User" );
44+ "io.github.springwolf.core.integrationtests.application.complexSchema.ComplexSchemaApplication .ComplexPublisher.User" );
4445 assertThat (asyncAPI .getOperations ())
45- .containsOnlyKeys ("publisher-channel_send_publish1 " , "publisher-channel_send_publish2 " );
46+ .containsOnlyKeys ("publisher-channel2_send_publish1 " , "publisher-channel2_send_publish2 " );
4647 assertThat (asyncAPI .getComponents ().getMessages ())
4748 .containsOnlyKeys (
48- "io.github.springwolf.core.integrationtests.application.complexSchema.PublisherGroupingComplexSchemaApplication .ComplexPublisher.User" );
49+ "io.github.springwolf.core.integrationtests.application.complexSchema.ComplexSchemaApplication .ComplexPublisher.User" );
4950 assertThat (asyncAPI .getComponents ().getSchemas ())
5051 .containsOnlyKeys (
5152 "HeadersNotDocumented" ,
52- "io.github.springwolf.core.integrationtests.application.complexSchema.PublisherGroupingComplexSchemaApplication .ComplexPublisher.User" ,
53- "io.github.springwolf.core.integrationtests.application.complexSchema.PublisherGroupingComplexSchemaApplication .ComplexPublisher.Address" ,
54- "io.github.springwolf.core.integrationtests.application.complexSchema.PublisherGroupingComplexSchemaApplication .ComplexPublisher.City" );
53+ "io.github.springwolf.core.integrationtests.application.complexSchema.ComplexSchemaApplication .ComplexPublisher.User" ,
54+ "io.github.springwolf.core.integrationtests.application.complexSchema.ComplexSchemaApplication .ComplexPublisher.Address" ,
55+ "io.github.springwolf.core.integrationtests.application.complexSchema.ComplexSchemaApplication .ComplexPublisher.City" );
5556
5657 MessageObject userMessage = (MessageObject )
5758 asyncAPI .getComponents ()
5859 .getMessages ()
5960 .get (
60- "io.github.springwolf.core.integrationtests.application.complexSchema.PublisherGroupingComplexSchemaApplication .ComplexPublisher.User" );
61+ "io.github.springwolf.core.integrationtests.application.complexSchema.ComplexSchemaApplication .ComplexPublisher.User" );
6162 assertThat (userMessage .getPayload ().getMultiFormatSchema ().getSchema ()).isInstanceOf (SchemaReference .class );
62- SchemaReference fooSchemaRef = (SchemaReference )
63+ SchemaReference userMessageToSchemaRef = (SchemaReference )
6364 userMessage .getPayload ().getMultiFormatSchema ().getSchema ();
64- assertThat (fooSchemaRef .getRef ())
65+ assertThat (userMessageToSchemaRef .getRef ())
6566 .isEqualTo (
66- "#/components/schemas/io.github.springwolf.core.integrationtests.application.complexSchema.PublisherGroupingComplexSchemaApplication.ComplexPublisher.User" );
67+ "#/components/schemas/io.github.springwolf.core.integrationtests.application.complexSchema.ComplexSchemaApplication.ComplexPublisher.User" );
68+
69+ // Verify that collection property is correctly represented using `items`
70+ ComponentSchema addressesSchema = (ComponentSchema ) asyncAPI .getComponents ()
71+ .getSchemas ()
72+ .get (
73+ "io.github.springwolf.core.integrationtests.application.complexSchema.ComplexSchemaApplication.ComplexPublisher.User" )
74+ .getSchema ()
75+ .getProperties ()
76+ .get ("addresses" );
77+ assertThat (addressesSchema .getSchema ().getItems ().getReference ().getRef ())
78+ .isEqualTo (
79+ "#/components/schemas/io.github.springwolf.core.integrationtests.application.complexSchema.ComplexSchemaApplication.ComplexPublisher.Address" );
6780 }
6881
6982 @ Test
0 commit comments