Skip to content

Commit

Permalink
Merge pull request #767 from MeasureAuthoringTool/MAT-7939_removeFlags
Browse files Browse the repository at this point in the history
MAT-7939 remove unused feature flags
  • Loading branch information
sb-cecilialiu authored Dec 18, 2024
2 parents 352c0fa + 3568cdb commit 585c97d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
public enum MadieFeatureFlag {
QDM_EXPORT("qdmExport"),
QDM_TEST_CASES("qdmTestCases"),
IMPORT_TEST_CASES("importTestCases"),
TEST_CASE_ID("TestCaseID");
IMPORT_TEST_CASES("importTestCases");

private final String flag;

Expand Down
19 changes: 7 additions & 12 deletions src/main/java/cms/gov/madie/measure/services/TestCaseService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cms.gov.madie.measure.services;

import cms.gov.madie.measure.dto.JobStatus;
import cms.gov.madie.measure.dto.MadieFeatureFlag;
import cms.gov.madie.measure.dto.MeasureTestCaseValidationReport;
import cms.gov.madie.measure.dto.TestCaseValidationReport;
import gov.cms.madie.models.common.ActionType;
Expand Down Expand Up @@ -83,9 +82,8 @@ protected TestCase enrichNewTestCase(TestCase testCase, String username, String
enrichedTestCase.setHapiOperationOutcome(null);
enrichedTestCase.setValidResource(false);
enrichedTestCase.setPatientId(UUID.randomUUID());
if (appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)) {
enrichedTestCase.setCaseNumber(sequenceService.generateSequence(measureId));
}
enrichedTestCase.setCaseNumber(sequenceService.generateSequence(measureId));

return enrichedTestCase;
}

Expand Down Expand Up @@ -386,8 +384,7 @@ public String deleteTestCase(String measureId, String testCaseId, String usernam
testCaseId,
measureId);
measureRepository.save(measure);
if (isEmpty(remainingTestCases)
&& appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)) {
if (isEmpty(remainingTestCases)) {
sequenceService.resetSequence(measureId);
}
return "Test case deleted successfully: " + testCaseId;
Expand Down Expand Up @@ -415,9 +412,7 @@ public String deleteTestCases(String measureId, List<String> testCaseIds, String
measure.setTestCases(remainingTestCases);
measureRepository.save(measure);

if (appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)) {
sequenceService.resetSequence(measureId);
}
sequenceService.resetSequence(measureId);

List<String> notDeletedTestCases =
testCaseIds.stream()
Expand Down Expand Up @@ -540,9 +535,9 @@ private TestCaseImportOutcome validateTestCaseJsonAndCreateTestCase(
.series(getSeries(testCaseImportRequest, familyName))
.patientId(testCaseImportRequest.getPatientId())
.build();
if (appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)) {
newTestCase.setCaseNumber(sequenceService.generateSequence(measure.getId()));
}

newTestCase.setCaseNumber(sequenceService.generateSequence(measure.getId()));

List<TestCaseGroupPopulation> testCaseGroupPopulations =
getTestCaseGroupPopulationsFromImportRequest(
model, testCaseImportRequest.getJson(), measure);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package cms.gov.madie.measure.services;

import cms.gov.madie.measure.dto.MadieFeatureFlag;
import cms.gov.madie.measure.exceptions.BadVersionRequestException;
import cms.gov.madie.measure.exceptions.CqlElmTranslationErrorException;
import cms.gov.madie.measure.exceptions.MeasureNotDraftableException;
Expand Down Expand Up @@ -208,8 +207,7 @@ public Measure createDraft(
savedDraft.getId());

// need to generate sequence AFTER measure is created with the new measure id
if (!CollectionUtils.isEmpty(savedDraft.getTestCases())
&& appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)) {
if (!CollectionUtils.isEmpty(savedDraft.getTestCases())) {
if (!checkCaseNumberExists(measure.getTestCases())) {
savedDraft.setTestCases(
assignCaseNumbersWhenCaseNumbersNotExist(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cms.gov.madie.measure.services;

import cms.gov.madie.measure.dto.JobStatus;
import cms.gov.madie.measure.dto.MadieFeatureFlag;
import cms.gov.madie.measure.dto.MeasureTestCaseValidationReport;
import cms.gov.madie.measure.exceptions.DuplicateTestCaseNameException;
import cms.gov.madie.measure.exceptions.InvalidDraftStatusException;
Expand Down Expand Up @@ -221,12 +220,11 @@ public void testEnrichNewTestCase() {
assertThat(output.getResourceUri(), is(nullValue()));
assertThat(output.getHapiOperationOutcome(), is(nullValue()));
assertThat(output.isValidResource(), is(false));
assertThat(output.getCaseNumber(), is(nullValue()));
assertNotNull(output.getCaseNumber());
}

@Test
public void testEnrichNewTestCaseWithTestCaseSequence() {
when(appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)).thenReturn(true);
when(testCaseSequenceService.generateSequence(anyString())).thenReturn(1);
TestCase testCase = new TestCase();
final String username = "user01";
Expand All @@ -246,7 +244,6 @@ public void testEnrichNewTestCaseWithTestCaseSequence() {

@Test
void resetCaseNumberSequenceWhenLastTestCaseIsDeleted() {
when(appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)).thenReturn(true);
List<TestCase> testCases =
List.of(TestCase.builder().caseNumber(1).id("TC2_ID").title("TC2").build());

Expand Down Expand Up @@ -1513,7 +1510,6 @@ void testDeleteTestCasesAndReturnNotFoundTestIds() {

@Test
void resetCaseNumberSequenceWhenDeleteAllTestCases() {
when(appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)).thenReturn(true);
testDeleteTestCases();
verify(testCaseSequenceService, times(1)).resetSequence(anyString());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package cms.gov.madie.measure.services;

import cms.gov.madie.measure.dto.MadieFeatureFlag;
import cms.gov.madie.measure.dto.PackageDto;
import cms.gov.madie.measure.exceptions.BadVersionRequestException;
import cms.gov.madie.measure.exceptions.CqlElmTranslationErrorException;
Expand Down Expand Up @@ -652,7 +651,6 @@ public void testCreateDraftSuccessfullyForQiCore() {
.thenReturn(false);
when(measureRepository.save(any(Measure.class))).thenReturn(versionedCopy);
when(actionLogService.logAction(anyString(), any(), any(), anyString())).thenReturn(true);
when(appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)).thenReturn(false);
when(fhirServicesClient.validateBundle(anyString(), any(ModelType.class), anyString()))
.thenReturn(ResponseEntity.ok(validTestCaseHapiOperationOutcome));

Expand Down Expand Up @@ -710,7 +708,6 @@ public void testCreateDraftSuccessfullyForQdm() {
.thenReturn(false);
when(measureRepository.save(any(Measure.class))).thenReturn(versionedCopy);
when(actionLogService.logAction(anyString(), any(), any(), anyString())).thenReturn(true);
when(appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)).thenReturn(false);

Measure draft =
versionService.createDraft(
Expand Down Expand Up @@ -768,7 +765,6 @@ public void testCreateDraftWithUpdatedModelSuccessfully() {
.thenReturn(false);
when(measureRepository.save(any(Measure.class))).thenReturn(versionedCopy);
when(actionLogService.logAction(anyString(), any(), any(), anyString())).thenReturn(true);
when(appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)).thenReturn(false);
when(fhirServicesClient.validateBundle(anyString(), any(ModelType.class), anyString()))
.thenReturn(ResponseEntity.ok(validTestCaseHapiOperationOutcome));

Expand Down Expand Up @@ -952,7 +948,6 @@ public void testCreateDraftCopyCaseNumberFromExistingTestCase() {
.thenReturn(false);
when(measureRepository.save(any(Measure.class))).thenReturn(versionedCopy);
when(actionLogService.logAction(anyString(), any(), any(), anyString())).thenReturn(true);
when(appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)).thenReturn(true);
when(fhirServicesClient.validateBundle(anyString(), any(ModelType.class), anyString()))
.thenReturn(ResponseEntity.ok(invalidTestCaseHapiOperationOutcome));
Measure draft =
Expand Down Expand Up @@ -1024,7 +1019,6 @@ public void testCreateDraftCopyCaseNumberFromSequenceGenerator() {
.thenReturn(false);
when(measureRepository.save(any(Measure.class))).thenReturn(versionedCopy);
when(actionLogService.logAction(anyString(), any(), any(), anyString())).thenReturn(true);
when(appConfigService.isFlagEnabled(MadieFeatureFlag.TEST_CASE_ID)).thenReturn(true);
when(sequenceService.generateSequence(anyString())).thenReturn(1);
when(fhirServicesClient.validateBundle(anyString(), any(ModelType.class), anyString()))
.thenReturn(ResponseEntity.ok(validTestCaseHapiOperationOutcome));
Expand Down

0 comments on commit 585c97d

Please sign in to comment.