-
Notifications
You must be signed in to change notification settings - Fork 9
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
Update to 4.0.0-M2 #321
Merged
Merged
Update to 4.0.0-M2 #321
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grimmjo
force-pushed
the
graalTests
branch
2 times, most recently
from
April 24, 2023 10:48
92bf6a1
to
84fb8f6
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
melix
added a commit
to micronaut-projects/micronaut-test-resources
that referenced
this pull request
Apr 28, 2023
This commit introduces a new annotation, `@TestResourceProperties`, which can be applied on a test in order to tell that the test needs to resolve one or more test resource properties _before_ the application context is available. For example, with: ```java @MicronautTest @TestResourcesProperties( value = "redis.url" ) class SomeTest { ... } ``` Then the value of the `redis.url` property will automatically be fetched from the test resources service and made available as if it had been done in a `TestPropertyProvider`. The difference is that this without this annotation, it was required to call the test resources client directly in the provider, which was error prone. In particular, the `properties` argument of the `resolve` call are not easy to figure out. This annotation is therefore a convention to avoid having to call the client directly. However, in some cases it might be necessary to read a property in order to compute a different one which needs to be available in the test. This can be done by adding a `providers` argument to the annotation: ```java @TestResourcesProperties( value = "rabbitmq.uri", providers = RabbitTest.RabbitMQProvider.class ) class RabbitTest { // ... @ReflectiveAccess public static class RabbitMQProvider implements TestResourcesPropertyProvider { @OverRide public Map<String, String> provide(Map<String, Object> testProperties) { String uri = (String) testProperties.get("rabbitmq.uri"); return Map.of( "rabbitmq.servers.product-cluster.port", String.valueOf(URI.create(uri).getPort()) ); } } } ``` The `TestResourcesPropertyProvider` type has access to all properties which are already resolved at the moment it is called, which includes the properties asked in `@TestResourcesProperties`. This should make the implementation of micronaut-projects/micronaut-nats#321 easier.
melix
added a commit
to micronaut-projects/micronaut-test-resources
that referenced
this pull request
May 3, 2023
* Implement test resources property provider factory This commit introduces a new annotation, `@TestResourceProperties`, which can be applied on a test in order to tell that the test needs to resolve one or more test resource properties _before_ the application context is available. For example, with: ```java @MicronautTest @TestResourcesProperties( value = "redis.url" ) class SomeTest { ... } ``` Then the value of the `redis.url` property will automatically be fetched from the test resources service and made available as if it had been done in a `TestPropertyProvider`. The difference is that this without this annotation, it was required to call the test resources client directly in the provider, which was error prone. In particular, the `properties` argument of the `resolve` call are not easy to figure out. This annotation is therefore a convention to avoid having to call the client directly. However, in some cases it might be necessary to read a property in order to compute a different one which needs to be available in the test. This can be done by adding a `providers` argument to the annotation: ```java @TestResourcesProperties( value = "rabbitmq.uri", providers = RabbitTest.RabbitMQProvider.class ) class RabbitTest { // ... @ReflectiveAccess public static class RabbitMQProvider implements TestResourcesPropertyProvider { @OverRide public Map<String, String> provide(Map<String, Object> testProperties) { String uri = (String) testProperties.get("rabbitmq.uri"); return Map.of( "rabbitmq.servers.product-cluster.port", String.valueOf(URI.create(uri).getPort()) ); } } } ``` The `TestResourcesPropertyProvider` type has access to all properties which are already resolved at the moment it is called, which includes the properties asked in `@TestResourcesProperties`. This should make the implementation of micronaut-projects/micronaut-nats#321 easier. * Remove accidentally added files * Add javadocs * Add missing test * Make spotless happy * Add nullability annotations * Fix checkstyle and japicmp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Things done:
io.micronaut.build.shared.settings
to6.4.1
4.0.0-M2
2.16.10
1.18.0
Relates to micronaut-projects/micronaut-core#9083