Skip to content

Commit

Permalink
fix: fix wrong behavir with right enum name (#541) (#545)
Browse files Browse the repository at this point in the history
Co-authored-by: Matheus Cruz <56329339+mcruzdev@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and mcruzdev authored Oct 30, 2023
1 parent 8563e87 commit 64ece5d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public String toEnumVarName(String value, String datatype) {

// remove _ at start and end
enumVarName = enumVarName.replaceAll("^_+|_+$", "");
enumVarName = enumVarName.replaceFirst("\\d.*", "_".concat(enumVarName));
enumVarName = enumVarName.replaceFirst("^(\\d).*", "_".concat(enumVarName));

return enumVarName.toUpperCase(Locale.ROOT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class QuarkusJavaClientCodegenTest {
"123456,String,_123456",
"quarkus_resources,String,QUARKUS_RESOURCES",
"123456,Integer,NUMBER_123456", // old behavior
"123+123,Long,NUMBER_123PLUS_123" // old behavior
"123+123,Long,NUMBER_123PLUS_123", // old behavior,
"M123,String,M123",
"MA456,String,MA456",
"P1,String,P1",
})
void toEnumVarName(String value, String dataType, String expectedVarName) {

Expand Down

0 comments on commit 64ece5d

Please sign in to comment.