Created
March 4, 2015 10:50
-
-
Save cristianmiranda/e347ba8b702309f6a35d to your computer and use it in GitHub Desktop.
Validations order algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int order = 0; | |
for (ConstraintViolation<MedicalProvider> violation : violations) { | |
for (int i = order; i < violations.size(); i++) { | |
// If constraint isn't in the expected order, maybe it's after some not excluded property | |
if (!medicalProvider.getValidationsOrder().get(i).equals(violation.getPropertyPath().toString())) { | |
boolean found = false; | |
for (int j = 0; j <= order; j++) { | |
if (medicalProvider.getValidationsOrder().get(j).equals(violation.getPropertyPath().toString())) { | |
found = true; | |
break; | |
} else { | |
order++; | |
} | |
} | |
if (!found) { | |
Assert.fail(); | |
} else { | |
break; | |
} | |
} else { | |
order = i + 1; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment