Skip to content

Commit

Permalink
Merge pull request #69 from MeasureAuthoringTool/MAT-7035_allowQdmLib…
Browse files Browse the repository at this point in the history
…raryNameWithUnderscore

MAT-7035 qdm library name can have underscore
  • Loading branch information
sb-cecilialiu authored Apr 23, 2024
2 parents 6606ee2 + daf139b commit 6f3eaca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<dependency>
<groupId>gov.cms.madie</groupId>
<artifactId>madie-java-models</artifactId>
<version>0.6.30-SNAPSHOT</version>
<version>0.6.34-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ Map<String, Object> onMethodArgumentNotValidException(
.getAllErrors()
.forEach(
(error) -> {
String fieldName = ((FieldError) error).getField();
String errorMessage = error.getDefaultMessage();
validationErrors.put(fieldName, errorMessage);
if (error instanceof FieldError) {
String fieldName = ((FieldError) error).getField();
String errorMessage = error.getDefaultMessage();
validationErrors.put(fieldName, errorMessage);
} else {
validationErrors.put(error.getObjectName(), error.getDefaultMessage());
}
});
Map<String, Object> errorAttributes = getErrorAttributes(request, HttpStatus.BAD_REQUEST);
errorAttributes.put("validationErrors", validationErrors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ public void testCreateCqlLibraryReturnsValidationErrorForLowercaseStartCharacter
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isBadRequest())
.andExpect(
jsonPath("$.validationErrors.cqlLibraryName")
jsonPath("$.validationErrors.cqlLibrary")
.value(
"Library name must start with an upper case letter, "
+ "followed by alpha-numeric character(s) and must not contain "
+ "spaces or other special characters."));
+ "spaces or other special characters except of underscore for QDM."));
verifyNoInteractions(repository);
}

Expand All @@ -175,11 +175,11 @@ public void testCreateCqlLibraryReturnsValidationErrorForContainingSpaces() thro
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isBadRequest())
.andExpect(
jsonPath("$.validationErrors.cqlLibraryName")
jsonPath("$.validationErrors.cqlLibrary")
.value(
"Library name must start with an upper case letter, "
+ "followed by alpha-numeric character(s) and must not contain "
+ "spaces or other special characters."));
+ "spaces or other special characters except of underscore for QDM."));
verifyNoInteractions(repository);
}

Expand All @@ -202,11 +202,11 @@ public void testCreateCqlLibraryReturnsValidationErrorForContainingUnderscore()
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isBadRequest())
.andExpect(
jsonPath("$.validationErrors.cqlLibraryName")
jsonPath("$.validationErrors.cqlLibrary")
.value(
"Library name must start with an upper case letter, "
+ "followed by alpha-numeric character(s) and must not contain "
+ "spaces or other special characters."));
+ "spaces or other special characters except of underscore for QDM."));
verifyNoInteractions(repository);
}

Expand All @@ -230,11 +230,11 @@ public void testCreateCqlLibraryReturnsValidationErrorForContainingSpecialCharac
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isBadRequest())
.andExpect(
jsonPath("$.validationErrors.cqlLibraryName")
jsonPath("$.validationErrors.cqlLibrary")
.value(
"Library name must start with an upper case letter, "
+ "followed by alpha-numeric character(s) and must not contain "
+ "spaces or other special characters."));
+ "spaces or other special characters except of underscore for QDM."));
verifyNoInteractions(repository);
}

Expand Down

0 comments on commit 6f3eaca

Please sign in to comment.