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

Doc for @AddConfigBlock #8807 #8825

Merged
merged 3 commits into from
Jun 4, 2024
Merged

Doc for @AddConfigBlock #8807 #8825

merged 3 commits into from
Jun 4, 2024

Conversation

jbescos
Copy link
Member

@jbescos jbescos commented May 31, 2024

Description

#8807

Documentation

Included in this PR

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label May 31, 2024
@jbescos jbescos requested a review from tjquinno May 31, 2024 10:05
@jbescos jbescos self-assigned this May 31, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Signed-off-by: Jorge Bescos Gascon <[email protected]>
@tvallin tvallin linked an issue May 31, 2024 that may be closed by this pull request
Copy link
Member

@tjquinno tjquinno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few changes, please.

| `@AddConfigBlock(type = "properties", value = """ +
some.key1=some.value1 +
some.key2=some.value2 +
""")` | Defines a new configuration (either on class level, or method level) by adding a single configuration key/value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please:

  1. Change line 110: "Define a new" to "Define additional"

  2. Change line 110: "a single configuration key/value." to "one or more configuration key/value pairs."

  3. Change line 106: "Define a new" to "Define additional"

    I know line 106 is not part of your changes in this PR but the original "Define a new" could be interpreted to mean "replace" which is not what it does.

  4. Add code illustrating @AddConfigBlock to the snippet referenced immediately after the table.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. It is done now.

Signed-off-by: Jorge Bescos Gascon <[email protected]>
Copy link
Member

@tjquinno tjquinno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, one more small change request.

@@ -92,6 +93,12 @@ void testConfiguredGreeting(WebTarget webTarget) {
validate(webTarget, "/greet", "Unite World!");
}

@Test
@AddConfigBlock("app.greeting=Unite")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example should illustrate what we can do with this annotation that we cannot do with the other...declare multiple settings as in the text you added to the doc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that the helidon/examples/quickstarts/helidon-quickstart-mp only uses one config property, so there is no point to add more.

I cannot create new config properties to inject in the test as a field, because of:
java.lang.RuntimeException: When a class is annotated with @HelidonTest(resetPerTest=true), injection into fields or constructor is not supported, as each test method uses a different CDI container. Field private java.lang.String io.helidon.microprofile.tests.testing.junit5.TestAddConfigBlockProperties.value1 is annotated with @Inject

Basically I need to create a new Snippet to test something like:

@HelidonTest
@AddConfigBlock("""
    some.key1=some.value1
    some.key2=some.value2
""")
class TestAddConfigBlockProperties {

    @Inject
    @ConfigProperty(name = "some.key1")
    private String value1;

    @Inject
    @ConfigProperty(name = "some.key2")
    private String value2;

    @Test
    void testValue() {
        assertThat(value1, is("some.value1"));
        assertThat(value2, is("some.value2"));
    }
}

Do you agree with it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed the change. Just let me know whether you are fine with it.

@jbescos jbescos merged commit 0b76c6c into helidon-io:main Jun 4, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No doc for @AddConfigBlock
2 participants