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

Update to 4.0.0-M2 #321

Merged
merged 10 commits into from
Apr 26, 2023
Merged

Update to 4.0.0-M2 #321

merged 10 commits into from
Apr 26, 2023

Conversation

grimmjo
Copy link
Collaborator

@grimmjo grimmjo commented Apr 24, 2023

Things done:

  • update io.micronaut.build.shared.settings to 6.4.1
  • update to 4.0.0-M2
  • adds native tests
  • adds testResources
  • updates jnats to 2.16.10
  • updates testcontainers to 1.18.0

Relates to micronaut-projects/micronaut-core#9083

@grimmjo grimmjo force-pushed the graalTests branch 2 times, most recently from 92bf6a1 to 84fb8f6 Compare April 24, 2023 10:48
@grimmjo grimmjo marked this pull request as ready for review April 26, 2023 14:06
@sonarcloud
Copy link

sonarcloud bot commented Apr 26, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 10 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@graemerocher graemerocher merged commit ed3ba83 into master Apr 26, 2023
@graemerocher graemerocher deleted the graalTests branch April 26, 2023 17:25
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
Labels
type: dependency-upgrade Upgrade a dependency
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants