Skip to content

Commit

Permalink
test(core): test useFqn configuration in core integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
timonback committed Nov 18, 2024
1 parent f3dbccb commit 9b7e2b1
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
package io.github.springwolf.core.integrationtests;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.github.springwolf.asyncapi.v3.jackson.AsyncApiSerializerService;
import io.github.springwolf.asyncapi.v3.model.AsyncAPI;
import io.github.springwolf.asyncapi.v3.model.channel.message.Message;
import io.github.springwolf.asyncapi.v3.model.channel.message.MessageObject;
import io.github.springwolf.asyncapi.v3.model.channel.message.MessageReference;
import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject;
import io.github.springwolf.core.asyncapi.AsyncApiService;
import io.github.springwolf.core.asyncapi.scanners.common.headers.AsyncHeadersNotDocumented;
import io.github.springwolf.core.fixtures.MinimalIntegrationTestContextConfiguration;
import io.github.springwolf.core.integrationtests.application.fqn.FqnApplication;
import io.github.springwolf.core.integrationtests.application.listener.ListenerApplication;
import io.github.springwolf.core.integrationtests.application.polymorphic.PolymorphicPayloadApplication;
import io.github.springwolf.core.integrationtests.application.publisher.PublisherApplication;
Expand Down Expand Up @@ -154,6 +158,42 @@ void asyncPublisherAnnotationIsFound() {
}
}

@Nested
@SpringBootTest(classes = FqnApplication.class)
@MinimalIntegrationTestContextConfiguration
@TestPropertySource(
properties = {
"springwolf.docket.base-package=io.github.springwolf.core.integrationtests.application.fqn",
"springwolf.use-fqn=false",
})
class FqnTest {
@Autowired
private AsyncApiService asyncApiService;

@Autowired
private AsyncApiSerializerService asyncApiSerializerService;

@Test
void allClassesHaveSimpleNameNotFullQualifiedTest() throws JsonProcessingException {
AsyncAPI asyncAPI = asyncApiService.getAsyncAPI();
assertThat(asyncAPI).isNotNull();
String serialized = asyncApiSerializerService.toJsonString(asyncAPI);

assertThat(serialized)
.contains(
"string",
"integer",
FqnApplication.Foo.class.getSimpleName(),
FqnApplication.Bar.class.getSimpleName(),
AsyncHeadersNotDocumented.NOT_DOCUMENTED.getTitle())
.doesNotContain(
String.class.getName(),
Integer.class.getName(),
FqnApplication.Foo.class.getName(),
FqnApplication.Bar.class.getName());
}
}

@Nested
@SpringBootTest(classes = PolymorphicPayloadApplication.class)
@MinimalIntegrationTestContextConfiguration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: Apache-2.0
package io.github.springwolf.core.integrationtests.application.fqn;

import io.github.springwolf.core.asyncapi.annotations.AsyncListener;
import io.github.springwolf.core.asyncapi.annotations.AsyncOperation;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.util.List;

@SpringBootApplication
public class FqnApplication {
@Bean
public Listener listener() {
return new Listener();
}

static class Listener {
@AsyncListener(operation = @AsyncOperation(channelName = "listener-channel"))
public void listen(String payload) {}

@AsyncListener(operation = @AsyncOperation(channelName = "listener-channel"))
public void listen2(List<String> payload) {}

@AsyncListener(operation = @AsyncOperation(channelName = "listener-channel"))
public void listen3(Foo payload) {}

@AsyncListener(operation = @AsyncOperation(channelName = "listener-channel"))
public void listen4(Integer payload) {}
}

public record Foo(Bar aFieldInFooRecord) {}

public record Bar(String aFieldInBarRecord) {}
}

0 comments on commit 9b7e2b1

Please sign in to comment.