use of jakarta.validation.GroupDefinitionException in project resteasy by resteasy.
the class ResteasyViolationExceptionMapper method toResponse.
public Response toResponse(ValidationException exception) {
if (exception instanceof ConstraintDefinitionException) {
return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
}
if (exception instanceof ConstraintDeclarationException) {
return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
}
if (exception instanceof GroupDefinitionException) {
return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
}
if (exception instanceof ResteasyViolationException) {
ResteasyViolationException resteasyViolationException = ResteasyViolationException.class.cast(exception);
Exception e = resteasyViolationException.getException();
if (e != null) {
return buildResponse(unwrapException(e), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
} else if (resteasyViolationException.getReturnValueViolations().size() == 0) {
return buildViolationReportResponse(resteasyViolationException, Status.BAD_REQUEST);
} else {
return buildViolationReportResponse(resteasyViolationException, Status.INTERNAL_SERVER_ERROR);
}
}
return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
}
use of jakarta.validation.GroupDefinitionException in project hibernate-validator by hibernate.
the class GroupC method testAssertDefaultGroupSequenceIsExpandableWithDefaultAtBeginningOfSequence.
@Test
public void testAssertDefaultGroupSequenceIsExpandableWithDefaultAtBeginningOfSequence() {
// create a dummy sequence
Group a = new Group(GroupA.class);
Group b = new Group(GroupB.class);
Group c = new Group(GroupC.class);
Group defaultGroup = Group.DEFAULT_GROUP;
List<Group> sequence = new ArrayList<Group>();
sequence.add(defaultGroup);
sequence.add(a);
sequence.add(b);
sequence.add(c);
DefaultValidationOrder chain = new DefaultValidationOrder();
chain.insertSequence(new Sequence(TestSequence.class, sequence));
// create test default sequence
List<Class<?>> defaultSequence = new ArrayList<Class<?>>();
defaultSequence.add(Default.class);
defaultSequence.add(GroupA.class);
chain.assertDefaultGroupSequenceIsExpandable(defaultSequence);
defaultSequence.clear();
defaultSequence.add(GroupA.class);
defaultSequence.add(Default.class);
try {
chain.assertDefaultGroupSequenceIsExpandable(defaultSequence);
fail();
} catch (GroupDefinitionException e) {
// success
}
defaultSequence.clear();
defaultSequence.add(Default.class);
defaultSequence.add(GroupC.class);
try {
chain.assertDefaultGroupSequenceIsExpandable(defaultSequence);
fail();
} catch (GroupDefinitionException e) {
// success
}
defaultSequence.clear();
defaultSequence.add(GroupC.class);
defaultSequence.add(Default.class);
try {
chain.assertDefaultGroupSequenceIsExpandable(defaultSequence);
fail();
} catch (GroupDefinitionException e) {
// success
}
}
use of jakarta.validation.GroupDefinitionException in project hibernate-validator by hibernate.
the class GroupC method testAssertDefaultGroupSequenceIsExpandableWithDefaultAtEndOfSequence.
@Test
public void testAssertDefaultGroupSequenceIsExpandableWithDefaultAtEndOfSequence() {
// create a dummy sequence
Group a = new Group(GroupA.class);
Group b = new Group(GroupB.class);
Group c = new Group(GroupC.class);
Group defaultGroup = Group.DEFAULT_GROUP;
List<Group> sequence = new ArrayList<Group>();
sequence.add(a);
sequence.add(b);
sequence.add(c);
sequence.add(defaultGroup);
DefaultValidationOrder chain = new DefaultValidationOrder();
chain.insertSequence(new Sequence(TestSequence.class, sequence));
// create test default sequence
List<Class<?>> defaultSequence = new ArrayList<Class<?>>();
defaultSequence.add(Default.class);
defaultSequence.add(GroupA.class);
try {
chain.assertDefaultGroupSequenceIsExpandable(defaultSequence);
fail();
} catch (GroupDefinitionException e) {
// success
}
defaultSequence.clear();
defaultSequence.add(GroupA.class);
defaultSequence.add(Default.class);
try {
chain.assertDefaultGroupSequenceIsExpandable(defaultSequence);
fail();
} catch (GroupDefinitionException e) {
// success
}
defaultSequence.clear();
defaultSequence.add(Default.class);
defaultSequence.add(GroupC.class);
try {
chain.assertDefaultGroupSequenceIsExpandable(defaultSequence);
fail();
} catch (GroupDefinitionException e) {
// success
}
defaultSequence.clear();
defaultSequence.add(GroupC.class);
defaultSequence.add(Default.class);
chain.assertDefaultGroupSequenceIsExpandable(defaultSequence);
}
Aggregations