Skip to content

Commit e809783

Browse files
Merge pull request #75 from testomatio/issue-74-fix
Issue 74 fix
2 parents 269d38b + 00d2e9d commit e809783

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

java-reporter-core/src/main/java/io/testomat/core/client/request/NativeRequestBodyBuilder.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
* with support for parameterized tests, shared runs, and configurable properties.
2828
*/
2929
public class NativeRequestBodyBuilder implements RequestBodyBuilder {
30-
private final String createParam;
30+
private static final String TRUE = "true";
31+
private final Boolean createParam;
3132
private final String sharedRun;
3233
private final String sharedRunTimeout;
3334
private final String publishParam;
@@ -41,7 +42,7 @@ public NativeRequestBodyBuilder() {
4142
this.sharedRun = getPropertySafely(SHARED_RUN_PROPERTY_NAME);
4243
this.sharedRunTimeout = getPropertySafely(SHARED_TIMEOUT_PROPERTY_NAME);
4344
this.objectMapper = new ObjectMapper();
44-
this.createParam = getPropertySafely(CREATE_TEST_PROPERTY_NAME);
45+
this.createParam = getCreateParam();
4546
}
4647

4748
@Override
@@ -137,15 +138,16 @@ private Map<String, Object> buildTestResultMap(TestResult result) {
137138
body.put("rid", result.getRid());
138139
}
139140

140-
if (this.createParam != null) {
141-
body.put("create", "true");
141+
if (createParam) {
142+
body.put("create", TRUE);
142143
}
143144

144145
return body;
145146
}
146147

147148
/**
148-
* Safely retrieves property value, returning null if property is not found or any exception occurs.
149+
* Safely retrieves property value, returning null if property is not
150+
* found or any exception occurs.
149151
* Centralizes exception handling for all property access operations.
150152
*
151153
* @param propertyName the name of the property to retrieve
@@ -158,4 +160,12 @@ private String getPropertySafely(String propertyName) {
158160
return null;
159161
}
160162
}
163+
164+
private boolean getCreateParam() {
165+
try {
166+
return provider.getProperty(CREATE_TEST_PROPERTY_NAME).equalsIgnoreCase(TRUE);
167+
} catch (Exception e) {
168+
return false;
169+
}
170+
}
161171
}

java-reporter-junit/src/main/java/io/testomat/junit/methodexporter/MethodExportManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ public void loadTestBodyIfRequired(final ExtensionContext extensionContext) {
192192

193193
private boolean isInitializeExportRequired() {
194194
try {
195-
String propertyValue = provider.getProperty(EXPORT_REQUIRED_PROPERTY_NAME);
196-
return propertyValue != null;
195+
return provider.getProperty(EXPORT_REQUIRED_PROPERTY_NAME).equalsIgnoreCase("true");
197196
} catch (Exception e) {
198197
return false;
199198
}

java-reporter-junit/src/test/java/io/testomat/junit/methodexporter/MethodExportManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ void shouldHandleCompleteSuccessfulFlow() {
568568
List<ExporterTestCase> testCases = createTestCases(5);
569569

570570
when(mockPropertyProvider.getProperty(MethodExportManager.EXPORT_REQUIRED_PROPERTY_NAME))
571-
.thenReturn("enabled");
571+
.thenReturn("true");
572572
when(mockFileFinder.getTestClassFilePath(TestClassA.class)).thenReturn(filepath);
573573
when(mockFileParser.parseFile(filepath)).thenReturn(mockCompilationUnit);
574574
when(mockMethodCaseExtractor.extractTestCases(mockCompilationUnit, filepath))

java-reporter-testng/src/main/java/io/testomat/testng/methodexporter/TestNgMethodExportManager.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ public void loadTestBodyForClass(Class<?> testClass) {
149149

150150
private boolean isInitializeExportRequired() {
151151
try {
152-
String propertyValue = provider.getProperty(EXPORT_REQUIRED_PROPERTY_NAME);
153-
log.debug("Property {} value: {}", EXPORT_REQUIRED_PROPERTY_NAME, propertyValue);
154-
return propertyValue != null;
152+
return provider.getProperty(EXPORT_REQUIRED_PROPERTY_NAME).equalsIgnoreCase("true");
155153
} catch (Exception e) {
156154
log.error("Error checking export required property: {}", e.getMessage(), e);
157155
return false;

0 commit comments

Comments
 (0)