Skip to content

Commit

Permalink
RAP-131 Disabled SQL validation if no SQL assertion group is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
QuyenLy87 committed Jan 8, 2025
1 parent 4315a2f commit b0fb161
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Binary file added dependency.txt
Binary file not shown.
21 changes: 12 additions & 9 deletions src/main/java/org/ihtsdo/rvf/core/service/ValidationRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -146,31 +147,33 @@ private void doRunValidations(ValidationRunConfig validationConfig, ValidationSt
Map<String, Future<ValidationStatusReport>> taskMap = new HashMap<>();
ExecutorService executorService = Executors.newFixedThreadPool(5);
StringBuilder statusMessages = new StringBuilder();
statusMessages.append("RVF assertions validation started");
reportService.writeProgress(statusMessages.toString(), validationConfig.getStorageLocation());

ValidationStatusReport mysqlValidationStatusReport = new ValidationStatusReport(validationConfig);
mysqlValidationStatusReport.setResultReport(new ValidationReport());
taskMap.put("SQL Assertions", executorService.submit(() -> mysqlValidationService.runRF2MysqlValidations(validationConfig, mysqlValidationStatusReport)));
if (!CollectionUtils.isEmpty(validationConfig.getGroupsList())) {
statusMessages.append("RVF assertions validation started");
reportService.writeProgress(statusMessages.toString(), validationConfig.getStorageLocation());
ValidationStatusReport mysqlValidationStatusReport = new ValidationStatusReport(validationConfig);
mysqlValidationStatusReport.setResultReport(new ValidationReport());
taskMap.put("SQL Assertions", executorService.submit(() -> mysqlValidationService.runRF2MysqlValidations(validationConfig, mysqlValidationStatusReport)));
}

if (validationConfig.isEnableDrools()) {
statusMessages.append("\nDrools rules validation started");
statusMessages.append(statusMessages.isEmpty() ? "" : "\n").append("Drools rules validation started");
reportService.writeProgress(statusMessages.toString(), validationConfig.getStorageLocation());
ValidationStatusReport droolsValidationStatusReport = new ValidationStatusReport(validationConfig);
droolsValidationStatusReport.setResultReport(new ValidationReport());
taskMap.put("Drools Assertions", executorService.submit(() -> droolsValidationService.runDroolsAssertions(validationConfig, droolsValidationStatusReport)));
}

if (validationConfig.isEnableMRCMValidation()) {
statusMessages.append("\nMRCM validation started");
statusMessages.append(statusMessages.isEmpty() ? "" : "\n").append("MRCM validation started");
reportService.writeProgress(statusMessages.toString(), validationConfig.getStorageLocation());
ValidationStatusReport mrcmValidationStatusReport = new ValidationStatusReport(validationConfig);
mrcmValidationStatusReport.setResultReport(new ValidationReport());
taskMap.put("MRCM Validation", executorService.submit(() -> mrcmValidationService.runMRCMAssertionTests(mrcmValidationStatusReport, validationConfig)));
}

if (validationConfig.isEnableTraceabilityValidation()) {
statusMessages.append("\nTraceability comparison validation started");
statusMessages.append(statusMessages.isEmpty() ? "" : "\n").append("Traceability comparison validation started");
reportService.writeProgress(statusMessages.toString(), validationConfig.getStorageLocation());
ValidationStatusReport traceabilityComparisonReport = new ValidationStatusReport(validationConfig);
traceabilityComparisonReport.setResultReport(new ValidationReport());
Expand Down Expand Up @@ -247,7 +250,7 @@ private void updateExecutionSummary(ValidationStatusReport statusReport, Validat
List<TestRunItem> failures = statusReport.getResultReport().getAssertionsFailed();
Map<TestType, Integer> testTypeFailuresCount = new EnumMap<>(TestType.class);
testTypeFailuresCount.put(TestType.ARCHIVE_STRUCTURAL, 0);
testTypeFailuresCount.put(TestType.SQL, 0);
testTypeFailuresCount.put(TestType.SQL, !CollectionUtils.isEmpty(validationRunConfig.getGroupsList()) ? 0 : -1);
testTypeFailuresCount.put(TestType.DROOL_RULES, validationRunConfig.isEnableDrools() ? 0 : -1);
testTypeFailuresCount.put(TestType.MRCM, validationRunConfig.isEnableMRCMValidation() ? 0 : -1);
testTypeFailuresCount.put(TestType.TRACEABILITY, validationRunConfig.isEnableTraceabilityValidation() ? 0 : -1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand Down Expand Up @@ -191,7 +192,7 @@ public ResponseEntity<Map<String, String>> runPostTestPackage(
@Parameter(description = "True if the test file contains RF2 delta files only. Defaults to false.") @RequestParam(value = RF2_DELTA_ONLY, required = false, defaultValue = "false") final boolean isRf2DeltaOnly,
@Parameter(description = "Default to false to reduce the size of report file") @RequestParam(value = WRITE_SUCCESSES, required = false, defaultValue = "false") final boolean writeSucceses,
@Parameter(description = "manifest.xml file(optional)") @RequestParam(value = MANIFEST, required = false) final MultipartFile manifestFile,
@Parameter(description = "Assertion group names separated by a comma.") @RequestParam(value = GROUPS) final List<String> groupsList,
@Parameter(description = "Assertion group names separated by a comma.") @RequestParam(value = GROUPS, required = false) final List<String> groupsList,
@Parameter(description = "Assertion exclusion list separated by a comma.") @RequestParam(value = ASSERTION_EXCLUSION_LIST, required = false) final List<String> assertionExclusionList,
@Parameter(description = "Drools rules group names") @RequestParam(value = DROOLS_RULES_GROUPS, required = false) final List<String> droolsRulesGroupsList,
@Parameter(description = "Required for non-first time international release testing") @RequestParam(value = PREVIOUS_RELEASE, required = false) final String previousRelease,
Expand Down Expand Up @@ -274,7 +275,7 @@ public ResponseEntity<Map<String, String>> runPostTestPackageViaS3(
@Parameter(description = "True if the test file contains RF2 delta files only. Defaults to false.") @RequestParam(value = RF2_DELTA_ONLY, required = false, defaultValue = "false") final boolean isRf2DeltaOnly,
@Parameter(description = "Defaults to false to reduce the size of report file") @RequestParam(value = WRITE_SUCCESSES, required = false, defaultValue = "false") final boolean writeSucceses,
@Parameter(description = "manifest.xml file path in AWS S3") @RequestParam(name = "manifestFileS3Path", required = false) final String manifestFileS3Path,
@Parameter(description = "Assertion group names") @RequestParam(value = GROUPS) final List<String> groupsList,
@Parameter(description = "Assertion group names") @RequestParam(value = GROUPS, required = false) final List<String> groupsList,
@Parameter(description = "Assertion exclusion list separated by a comma.") @RequestParam(value = ASSERTION_EXCLUSION_LIST, required = false) final List<String> assertionExclusionList,
@Parameter(description = "Drools rules group names") @RequestParam(value = DROOLS_RULES_GROUPS, required = false) final List<String> droolsRulesGroupsList,
@Parameter(description = "Required for non-first time international release testing") @RequestParam(value = PREVIOUS_RELEASE, required = false) final String previousRelease,
Expand Down Expand Up @@ -357,7 +358,7 @@ private boolean isAssertionGroupsValid(List<String> validationGroups,
Map<String, String> responseMap) {
// check assertion groups

if (ValidationRunner.EMPTY_TEST_ASSERTION_GROUPS.equals(validationGroups)) {
if (CollectionUtils.isEmpty(validationGroups) || ValidationRunner.EMPTY_TEST_ASSERTION_GROUPS.equals(validationGroups)) {
return true;
}

Expand Down

0 comments on commit b0fb161

Please sign in to comment.