diff --git a/java-reporter-core/src/main/java/io/testomat/core/client/request/NativeRequestBodyBuilder.java b/java-reporter-core/src/main/java/io/testomat/core/client/request/NativeRequestBodyBuilder.java index 60b02bf..f2dede9 100644 --- a/java-reporter-core/src/main/java/io/testomat/core/client/request/NativeRequestBodyBuilder.java +++ b/java-reporter-core/src/main/java/io/testomat/core/client/request/NativeRequestBodyBuilder.java @@ -27,7 +27,8 @@ * with support for parameterized tests, shared runs, and configurable properties. */ public class NativeRequestBodyBuilder implements RequestBodyBuilder { - private final String createParam; + private static final String TRUE = "true"; + private final Boolean createParam; private final String sharedRun; private final String sharedRunTimeout; private final String publishParam; @@ -41,7 +42,7 @@ public NativeRequestBodyBuilder() { this.sharedRun = getPropertySafely(SHARED_RUN_PROPERTY_NAME); this.sharedRunTimeout = getPropertySafely(SHARED_TIMEOUT_PROPERTY_NAME); this.objectMapper = new ObjectMapper(); - this.createParam = getPropertySafely(CREATE_TEST_PROPERTY_NAME); + this.createParam = getCreateParam(); } @Override @@ -137,15 +138,16 @@ private Map buildTestResultMap(TestResult result) { body.put("rid", result.getRid()); } - if (this.createParam != null) { - body.put("create", "true"); + if (createParam) { + body.put("create", TRUE); } return body; } /** - * Safely retrieves property value, returning null if property is not found or any exception occurs. + * Safely retrieves property value, returning null if property is not + * found or any exception occurs. * Centralizes exception handling for all property access operations. * * @param propertyName the name of the property to retrieve @@ -158,4 +160,12 @@ private String getPropertySafely(String propertyName) { return null; } } + + private boolean getCreateParam() { + try { + return provider.getProperty(CREATE_TEST_PROPERTY_NAME).equalsIgnoreCase(TRUE); + } catch (Exception e) { + return false; + } + } } \ No newline at end of file diff --git a/java-reporter-junit/src/main/java/io/testomat/junit/methodexporter/MethodExportManager.java b/java-reporter-junit/src/main/java/io/testomat/junit/methodexporter/MethodExportManager.java index 4517892..c737f7a 100644 --- a/java-reporter-junit/src/main/java/io/testomat/junit/methodexporter/MethodExportManager.java +++ b/java-reporter-junit/src/main/java/io/testomat/junit/methodexporter/MethodExportManager.java @@ -192,8 +192,7 @@ public void loadTestBodyIfRequired(final ExtensionContext extensionContext) { private boolean isInitializeExportRequired() { try { - String propertyValue = provider.getProperty(EXPORT_REQUIRED_PROPERTY_NAME); - return propertyValue != null; + return provider.getProperty(EXPORT_REQUIRED_PROPERTY_NAME).equalsIgnoreCase("true"); } catch (Exception e) { return false; } diff --git a/java-reporter-junit/src/test/java/io/testomat/junit/methodexporter/MethodExportManagerTest.java b/java-reporter-junit/src/test/java/io/testomat/junit/methodexporter/MethodExportManagerTest.java index 91cd11a..9a77501 100644 --- a/java-reporter-junit/src/test/java/io/testomat/junit/methodexporter/MethodExportManagerTest.java +++ b/java-reporter-junit/src/test/java/io/testomat/junit/methodexporter/MethodExportManagerTest.java @@ -568,7 +568,7 @@ void shouldHandleCompleteSuccessfulFlow() { List testCases = createTestCases(5); when(mockPropertyProvider.getProperty(MethodExportManager.EXPORT_REQUIRED_PROPERTY_NAME)) - .thenReturn("enabled"); + .thenReturn("true"); when(mockFileFinder.getTestClassFilePath(TestClassA.class)).thenReturn(filepath); when(mockFileParser.parseFile(filepath)).thenReturn(mockCompilationUnit); when(mockMethodCaseExtractor.extractTestCases(mockCompilationUnit, filepath)) diff --git a/java-reporter-testng/src/main/java/io/testomat/testng/methodexporter/TestNgMethodExportManager.java b/java-reporter-testng/src/main/java/io/testomat/testng/methodexporter/TestNgMethodExportManager.java index d35c8fc..5ea98ff 100644 --- a/java-reporter-testng/src/main/java/io/testomat/testng/methodexporter/TestNgMethodExportManager.java +++ b/java-reporter-testng/src/main/java/io/testomat/testng/methodexporter/TestNgMethodExportManager.java @@ -149,9 +149,7 @@ public void loadTestBodyForClass(Class testClass) { private boolean isInitializeExportRequired() { try { - String propertyValue = provider.getProperty(EXPORT_REQUIRED_PROPERTY_NAME); - log.debug("Property {} value: {}", EXPORT_REQUIRED_PROPERTY_NAME, propertyValue); - return propertyValue != null; + return provider.getProperty(EXPORT_REQUIRED_PROPERTY_NAME).equalsIgnoreCase("true"); } catch (Exception e) { log.error("Error checking export required property: {}", e.getMessage(), e); return false;