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

AddConfigBlock doesn't override prod config #9410

Open
danielkec opened this issue Oct 17, 2024 · 1 comment
Open

AddConfigBlock doesn't override prod config #9410

danielkec opened this issue Oct 17, 2024 · 1 comment
Labels
4.x Version 4.x bug Something isn't working P2 testing

Comments

@danielkec
Copy link
Contributor

Environment Details

  • Helidon Version: main

Problem Description

When production config file exists, it is possible to override it with:

@AddConfig(key = "another.key", value = "test.value")

But @AddConfigBlock behaves differently and doesn't override existing properties.

Steps to reproduce

diff --git a/microprofile/tests/testing/junit5/src/test/java/io/helidon/microprofile/tests/testing/junit5/TestAddConfigBlockYaml.java b/microprofile/tests/testing/junit5/src/test/java/io/helidon/microprofile/tests/testing/junit5/TestAddConfigBlockYaml.java
--- a/microprofile/tests/testing/junit5/src/test/java/io/helidon/microprofile/tests/testing/junit5/TestAddConfigBlockYaml.java	(revision d47f53aea182799c1da5f1172b8acf289a24b3a8)
+++ b/microprofile/tests/testing/junit5/src/test/java/io/helidon/microprofile/tests/testing/junit5/TestAddConfigBlockYaml.java	(date 1729174260197)
@@ -29,6 +29,8 @@
 
 @HelidonTest
 @AddConfigBlock(type = "yaml", value = """
+    another:
+      key: "test.value"
     another1:
       key: "another1.value"
     another2:
@@ -36,6 +38,10 @@
 """)
 class TestAddConfigBlockYaml {
 
+    @Inject
+    @ConfigProperty(name = "another.key")
+    private String another;
+
     @Inject
     @ConfigProperty(name = "another1.key")
     private String another1;
@@ -46,6 +52,7 @@
 
     @Test
     void testValue() {
+        assertThat(another, is("test.value"));
         assertThat(another1, is("another1.value"));
         assertThat(another2, is("another2.value"));
     }

diff --git a/microprofile/tests/testing/junit5/src/main/resources/application.yaml b/microprofile/tests/testing/junit5/src/main/resources/application.yaml
new file mode 100644
--- /dev/null	(date 1729174221128)
+++ b/microprofile/tests/testing/junit5/src/main/resources/application.yaml	(date 1729174221128)
@@ -0,0 +1,2 @@
+another:
+  key: "prod.value"
\ No newline at end of file

Result:

java.lang.AssertionError: 
Expected: is "test.value"
     but: was "prod.value"
Expected :test.value
Actual   :prod.value
<Click to see difference>


	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
	at io.helidon.microprofile.tests.testing.junit5.TestAddConfigBlockYaml.testValue(TestAddConfigBlockYaml.java:55)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
@danielkec
Copy link
Contributor Author

Workaround is adding config_ordinal to the block:

@AddConfigBlock(type = "yaml", value = """
    config_ordinal: 205
    another:
      key: "test.value"

@m0mus m0mus added bug Something isn't working P2 testing 4.x Version 4.x labels Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x bug Something isn't working P2 testing
Projects
Status: High priority
Development

No branches or pull requests

2 participants