Package javax.validation

Examples of javax.validation.ConstraintViolationException


    private void validateMember(Member member) throws ConstraintViolationException, ValidationException {
        //Create a bean validator and check for issues.
        Set<ConstraintViolation<Member>> violations = validator.validate(member);

        if (!violations.isEmpty()) {
            throw new ConstraintViolationException(new HashSet<ConstraintViolation<?>>(violations));
        }

        //Check the uniqueness of the email address
        if (emailAlreadyExists(member.getEmail())) {
            throw new ValidationException("Unique Email Violation");
View Full Code Here


        builder.append( classNames );
        builder.append( " during " );
        builder.append( operation.getName() );
        builder.append( " time for groups " );
        builder.append( toString( groups ) );
        throw new ConstraintViolationException(
            builder.toString(), propagatedViolations
        );
      }
    }
  }
View Full Code Here

        for (ConstraintViolation<?> violation : constraintViolations) {
          builder.append( "\t" ).append( violation.toString() ).append("\n");
        }
        builder.append( "]" );

        throw new ConstraintViolationException(
            builder.toString(), propagatedViolations
        );
      }
    }
  }
View Full Code Here

        ctx.getMethod(),
        ctx.getParameters()
    );

    if ( !violations.isEmpty() ) {
      throw new ConstraintViolationException(
          getMessage( ctx.getMethod(), ctx.getParameters(), violations ),
          violations
      );
    }

    Object result = ctx.proceed();

    violations = validator.forExecutables().validateReturnValue(
        ctx.getTarget(),
        ctx.getMethod(),
        result
    );

    if ( !violations.isEmpty() ) {
      throw new ConstraintViolationException(
          getMessage( ctx.getMethod(), ctx.getParameters(), violations ),
          violations
      );
    }
View Full Code Here

    private void validateEvent(Event event) throws ConstraintViolationException, ValidationException {
        Set<ConstraintViolation<Event>> violations = validator.validate(event);

        if (!violations.isEmpty()) {
            throw new ConstraintViolationException(new HashSet<ConstraintViolation<?>>(violations));
        }

        if (nameAlreadyExists(event.getName())) {
            throw new ValidationException("Unique Name Violation");
        }
View Full Code Here

        try {
            gamesManager.addSportMan("I lose", "EN");
            fail("no space should be in names");
        } catch (EJBException wrappingException) {
            assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
            ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
            assertEquals(1, exception.getConstraintViolations().size());
        }
    }
View Full Code Here

        try {
            poleVaultingManager.points(119);
            fail("the jump is too short");
        } catch (EJBException wrappingException) {
            assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
            ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
            assertEquals(1, exception.getConstraintViolations().size());
        }
    }
View Full Code Here

        try {
            persistManager.persistNotValid();
            fail();
        } catch (EJBException ejbException) {
            assertTrue(ejbException.getCause() instanceof ConstraintViolationException);
            ConstraintViolationException constraintViolationException = (ConstraintViolationException) ejbException.getCause();
            assertEquals(1, constraintViolationException.getConstraintViolations().size());
        }
    }
View Full Code Here

        try {
            p = mgr.create(null);
            fail();
        } catch (Exception e) {
            assertTrue(e.getCause() instanceof ConstraintViolationException);
            ConstraintViolationException cvs = (ConstraintViolationException) e.getCause();
            assertEquals(1, cvs.getConstraintViolations().size());
        }
        try {
            mgr.drive(p, 17);
            fail();
        } catch (Exception e) {
            assertTrue(e.getCause() instanceof ConstraintViolationException);
            ConstraintViolationException cvs = (ConstraintViolationException) e.getCause();
            assertEquals(1, cvs.getConstraintViolations().size());
        }
    }
View Full Code Here

        try {
            mgrRemote.drive(p, 15);
            fail();
        } catch (Exception e) {
            assertTrue(e.getCause() instanceof ConstraintViolationException);
            ConstraintViolationException cvs = (ConstraintViolationException) e.getCause();
            assertEquals(1, cvs.getConstraintViolations().size());
        }
    }
View Full Code Here

TOP

Related Classes of javax.validation.ConstraintViolationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.