Can anyone tell me how to use assertThrows with several exceptions?
for ex, here is a class:
protected void checkViolation(Set<ConstraintViolation<EcritureComptable>> vViolations) throws FunctionalException {
if (!vViolations.isEmpty()) {
throw new FunctionalException("L'écriture comptable ne respecte pas les règles de gestion.",
new ConstraintViolationException(
"L'écriture comptable ne respecte pas les contraintes de validation",
vViolations));
}
}
and my testing method:
@Test
void checkViolation(){
comptabiliteManager = spy(ComptabiliteManagerImpl.class);
when(vViolations.isEmpty()).thenReturn(false);
assertThrows( ConstraintViolationException.class, () ->comptabiliteManager.checkViolation(vViolations), "a string should be provided!");
}
I would like to match the method and throw ConstraintViolationException and FunctionalException altogether
Any idea?
Thanks