Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(core): test useFqn configuration in core integration test #1078

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {}
}
Loading