Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -137,15 +138,16 @@ private Map<String, Object> 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
Expand All @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ void shouldHandleCompleteSuccessfulFlow() {
List<ExporterTestCase> 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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down