This is an automated email from the ASF dual-hosted git repository. mridulpathak pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit 2c8fc6dc61ab989a10d4c11299a4f58f2b6203cd Author: Mridul Pathak <[email protected]> AuthorDate: Fri Oct 16 17:21:50 2026 +0530 Fixed: The tests of the text find and range find fields reference the static mock of UtilProperties (OFBIZ-13681) The three tests opened the static mock of UtilProperties in a try-with-resources statement without referencing it in the body, which made the Java compiler warn about an auto-closeable resource that is never referenced. The tests now create the mock in the statement and stub the labels through it. --- .../macro/RenderableFtlFormElementsBuilderTest.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/RenderableFtlFormElementsBuilderTest.java b/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/RenderableFtlFormElementsBuilderTest.java index a5d0e296ca..6d63f6699f 100644 --- a/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/RenderableFtlFormElementsBuilderTest.java +++ b/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/RenderableFtlFormElementsBuilderTest.java @@ -1073,11 +1073,9 @@ public final class RenderableFtlFormElementsBuilderTest { assertThat(renderableFtlFormElementsBuilder.postMultiFormContent(context) instanceof RenderableFtlString, equalTo(true)); } - private static MockedStatic<UtilProperties> labelsReturningTheirKey() { - final MockedStatic<UtilProperties> utilProperties = mockStatic(UtilProperties.class, CALLS_REAL_METHODS); + private static void labelsReturningTheirKey(final MockedStatic<UtilProperties> utilProperties) { utilProperties.when(() -> UtilProperties.getMessage(anyString(), anyString(), nullable(Locale.class))) .thenAnswer(invocation -> invocation.<String>getArgument(1) + "_MESSAGE"); - return utilProperties; } @Test @@ -1091,7 +1089,8 @@ public final class RenderableFtlFormElementsBuilderTest { when(modelFormField.getEntry(notNull(), nullable(String.class))).thenReturn("say \"hi\" ${1+1}"); when(modelFormField.getParameterName(notNull())).thenReturn("FIELDNAME"); - try (MockedStatic<UtilProperties> ignored = labelsReturningTheirKey()) { + try (MockedStatic<UtilProperties> utilProperties = mockStatic(UtilProperties.class, CALLS_REAL_METHODS)) { + labelsReturningTheirKey(utilProperties); assertThat(renderableFtlFormElementsBuilder.textFindField(new HashMap<>(), textFindField), MacroCallMatcher.hasNameAndParameters("renderTextFindField", MacroCallParameterMatcher.hasNameAndStringValue("name", "FIELDNAME"), @@ -1112,7 +1111,8 @@ public final class RenderableFtlFormElementsBuilderTest { when(textFindField.getHideOptions()).thenReturn(true); when(textFindField.getMaxlength()).thenReturn(null); - try (MockedStatic<UtilProperties> ignored = labelsReturningTheirKey()) { + try (MockedStatic<UtilProperties> utilProperties = mockStatic(UtilProperties.class, CALLS_REAL_METHODS)) { + labelsReturningTheirKey(utilProperties); assertThat(renderableFtlFormElementsBuilder.textFindField(new HashMap<>(), textFindField), MacroCallMatcher.hasNameAndParameters("renderTextFindField", MacroCallParameterMatcher.hasNameAndStringValue("opEquals", ""), @@ -1132,7 +1132,8 @@ public final class RenderableFtlFormElementsBuilderTest { when(modelFormField.getEntry(notNull(), nullable(String.class))).thenReturn("AAA ${1+1}"); when(modelFormField.getEntry(notNull())).thenReturn("BBB"); - try (MockedStatic<UtilProperties> ignored = labelsReturningTheirKey()) { + try (MockedStatic<UtilProperties> utilProperties = mockStatic(UtilProperties.class, CALLS_REAL_METHODS)) { + labelsReturningTheirKey(utilProperties); assertThat(renderableFtlFormElementsBuilder.rangeFindField(new HashMap<>(), rangeFindField), MacroCallMatcher.hasNameAndParameters("renderRangeFindField", MacroCallParameterMatcher.hasNameAndStringValue("value", "AAA ${1+1}"),

