Skip to content

Commit

Permalink
Merge pull request #747 from MeasureAuthoringTool/feature/MAT-7924-qd…
Browse files Browse the repository at this point in the history
…m-improvementnotation-mongock2

MAT-7924: missed an ac...combine description and improvement notation…
  • Loading branch information
nmorasb authored Nov 19, 2024
2 parents 94d9000 + 5529fd2 commit a256e58
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ public void standardizeQdmImprovementNotationField(MeasureRepository measureRepo
measure.getId(),
((QdmMeasure) measure).getImprovementNotation());
counter.incrementAndGet();
qdmMeasure.setImprovementNotationDescription(qdmMeasure.getImprovementNotation());
final String newDescription =
StringUtils.isNotBlank(qdmMeasure.getImprovementNotationDescription())
? qdmMeasure.getImprovementNotation()
+ " - "
+ qdmMeasure.getImprovementNotationDescription()
: qdmMeasure.getImprovementNotation();
qdmMeasure.setImprovementNotationDescription(newDescription);
qdmMeasure.setImprovementNotation("Other");
measureRepository.save(measure);
});
Expand All @@ -56,6 +62,7 @@ public void rollbackExecution(MongoTemplate mongoTemplate) {
// Not able to rollback - not able to differentiate between update
// measures and measures that already had Other + description
// Also, rolling back means these measures will be broken again
log.error("Error detected, but cannot roll back QdmImprovementNotationStandardizationChangeUnit!");
log.error(
"Error detected, but cannot roll back QdmImprovementNotationStandardizationChangeUnit!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class QdmImprovementNotationStandardizationChangeUnitTest {
private QdmMeasure qdmDraftMeasureWithNoImprovementNotation;
private QdmMeasure qdmDraftMeasureWithBlankImprovementNotation;
private QdmMeasure qdmDraftMeasureWithInvalidImprovementNotation;
private QdmMeasure qdmDraftMeasureWithInvalidImprovementNotationAndDescription;
private QdmMeasure qdmDraftMeasureWithOtherImprovementNotation;
private QdmMeasure qdmDraftMeasureWithValidIncreaseImprovementNotation;
private QdmMeasure qdmDraftMeasureWithValidDecreaseImprovementNotation;
Expand Down Expand Up @@ -71,6 +72,14 @@ void setup() {
.measureMetaData(MeasureMetaData.builder().draft(true).build())
.improvementNotation("This is definitely an invalid improvement notation!")
.build();
qdmDraftMeasureWithInvalidImprovementNotationAndDescription =
QdmMeasure.builder()
.model(ModelType.QDM_5_6.getValue())
.active(true)
.measureMetaData(MeasureMetaData.builder().draft(true).build())
.improvementNotation("Invalid ImprovementNotation")
.improvementNotationDescription("With a description")
.build();
qdmDraftMeasureWithOtherImprovementNotation =
QdmMeasure.builder()
.model(ModelType.QDM_5_6.getValue())
Expand Down Expand Up @@ -153,6 +162,7 @@ void standardizeQdmImprovementNotationField() {
qdmDraftMeasureWithBlankImprovementNotation,
qdmDraftMeasureWithOtherImprovementNotation,
qdmDraftMeasureWithInvalidImprovementNotation,
qdmDraftMeasureWithInvalidImprovementNotationAndDescription,
qdmDraftMeasureWithValidIncreaseImprovementNotation,
qdmDraftMeasureWithValidDecreaseImprovementNotation,
qdmVersionedMeasureWithInvalidImprovementNotation,
Expand All @@ -162,14 +172,25 @@ void standardizeQdmImprovementNotationField() {
changeUnit.standardizeQdmImprovementNotationField(measureRepository);

// then
verify(measureRepository, times(1)).save(measureArgumentCaptor.capture());
Measure updatedMeasure = measureArgumentCaptor.getValue();
assertThat(updatedMeasure, is(notNullValue()));
assertThat(updatedMeasure.getModel(), is(equalTo(ModelType.QDM_5_6.getValue())));
QdmMeasure qdmMeasure = (QdmMeasure) updatedMeasure;
assertThat(qdmMeasure.getImprovementNotation(), is(equalTo("Other")));
verify(measureRepository, times(2)).save(measureArgumentCaptor.capture());
List<Measure> allSavedMeasures = measureArgumentCaptor.getAllValues();

Measure updatedMeasureNoDesc = allSavedMeasures.get(0);
assertThat(updatedMeasureNoDesc, is(notNullValue()));
assertThat(updatedMeasureNoDesc.getModel(), is(equalTo(ModelType.QDM_5_6.getValue())));
QdmMeasure qdmMeasureNoDesc = (QdmMeasure) updatedMeasureNoDesc;
assertThat(qdmMeasureNoDesc.getImprovementNotation(), is(equalTo("Other")));
assertThat(
qdmMeasure.getImprovementNotationDescription(),
qdmMeasureNoDesc.getImprovementNotationDescription(),
is(equalTo("This is definitely an invalid improvement notation!")));

Measure updatedMeasureWithDesc = allSavedMeasures.get(1);
assertThat(updatedMeasureWithDesc, is(notNullValue()));
assertThat(updatedMeasureWithDesc.getModel(), is(equalTo(ModelType.QDM_5_6.getValue())));
QdmMeasure qdmMeasureWithDesc = (QdmMeasure) updatedMeasureWithDesc;
assertThat(qdmMeasureWithDesc.getImprovementNotation(), is(equalTo("Other")));
assertThat(
qdmMeasureWithDesc.getImprovementNotationDescription(),
is(equalTo("Invalid ImprovementNotation - With a description")));
}
}

0 comments on commit a256e58

Please sign in to comment.