@Override public String getLocalizedMessage() { return localizedMessage(); }
for( ConstraintViolation constraintViolation : e.constraintViolations() ) response.setEntity( new StringRepresentation( e.getMessage() ) ); response.setStatus( Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY );
@Test public void givenInvalidCacheNameWhenFetchingCacheExpectNullArgumentException() { try { cache = cachePool.fetchCache( "", String.class ); fail( "Expected " + NullArgumentException.class.getSimpleName() ); } catch( NullArgumentException e ) { // expected } try { cache = cachePool.fetchCache( null, String.class ); fail( "Expected " + NullArgumentException.class.getSimpleName() ); } catch( ConstraintViolationException e ) { // expected Collection<ConstraintViolation> violations = e.constraintViolations(); assertEquals( 1, violations.size() ); ConstraintViolation violation = violations.iterator().next(); assertEquals( "not optional", violation.constraint().toString() ); assertEquals( "param1", violation.name() ); } }
public String localizedMessage() { String[] messages = localizedMessagesFrom( null ); StringBuilder result = new StringBuilder(); boolean first = true; for( String message : messages ) { if( !first ) { result.append( ',' ); } first = false; result.append( message ); } return result.toString(); }
@Override public String getMessage() { return localizedMessage(); }