Skip to content

Commit a7929fd

Browse files
committed
Fix finding setters and getter for fields matching [a-z][0-9]+, breaks support for fields [A-Z][0-9]+ for Issue #304
1 parent 2801ee6 commit a7929fd

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/main/java/uk/co/jemos/podam/api/AbstractClassInfoStrategy.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,14 @@ protected void findPojoAttributes(Class<?> clazz,
450450
*/
451451
protected String extractFieldNameFromMethod(String methodName, Pattern pattern) {
452452
String candidateField = pattern.matcher(methodName).replaceFirst("");
453-
if (!candidateField.isEmpty()
454-
&& !candidateField.equals(methodName)
455-
&& (candidateField.length() == 1 || !candidateField.toUpperCase().equals(candidateField))) {
456-
candidateField = Character.toLowerCase(candidateField.charAt(0))
457-
+ candidateField.substring(1);
453+
if (!candidateField.isEmpty() && !candidateField.equals(methodName)) {
454+
String candidateFieldEnding = candidateField.substring(1);
455+
if ((candidateFieldEnding.isEmpty()
456+
|| !candidateFieldEnding.toUpperCase().equals(candidateFieldEnding)
457+
|| candidateFieldEnding.toLowerCase().equals(candidateFieldEnding.toUpperCase()))) {
458+
candidateField = Character.toLowerCase(candidateField.charAt(0))
459+
+ candidateFieldEnding;
460+
}
458461
}
459462

460463
return candidateField;

src/test/java/uk/co/jemos/podam/test/unit/features/classInfo/ClassInfoTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void podamShouldReturnAClassInfoObjectWithSingleLetterAndNumberAtrributes
7070
podamValidationSteps.theTwoObjectsShouldBeEqual(ShortNamesPojo.class, actualClassInfo.getClassName());
7171
Set<String> attribs = new HashSet<String>();
7272
attribs.add("v1");
73-
// classInfoValidationSteps.theClassInfoAttributesShouldMatchthePojoOnes(attribs, actualClassInfo.getClassAttributes());
73+
classInfoValidationSteps.theClassInfoAttributesShouldMatchthePojoOnes(attribs, actualClassInfo.getClassAttributes());
7474

7575
}
7676

0 commit comments

Comments
 (0)