Skip to content

Instantly share code, notes, and snippets.

@cristianmiranda
Created March 4, 2015 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianmiranda/e347ba8b702309f6a35d to your computer and use it in GitHub Desktop.
Save cristianmiranda/e347ba8b702309f6a35d to your computer and use it in GitHub Desktop.
Validations order algorithm
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