Package javax.validation

Examples of javax.validation.ConstraintViolationException


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


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

    Reply<?> postPerson(@As(Json.class) Person person, Request<String> request) {
      try {
          request.validate(person);
      }
      catch (ValidationException ve) {
          ConstraintViolationException cve = (ConstraintViolationException) ve.getCause();
          Set<? extends ConstraintViolation<?>> scv = (Set<? extends ConstraintViolation<?>>) cve.getConstraintViolations();
          return Reply.with(validationConverter.to(scv)).badRequest();
      }
      return Reply.with(person);
    }
View Full Code Here

    try {
        // call the appropriate handler.
        response = fireEvent(request, page, instance);
    }
    catch (ValidationException ve) {
        ConstraintViolationException cve = (ConstraintViolationException) ve.getCause();
        Set<? extends ConstraintViolation<?>> scv = (Set<? extends ConstraintViolation<?>>) cve.getConstraintViolations();
        List<String> errors = validationConvertor.to(scv);
        response =  Reply.with(errors).as(Json.class).badRequest();
    }
    return response;
  }
View Full Code Here

    try {
        redirect = fireEvent(request, page, instance);
    }
    catch (ValidationException ve) {
        ve.getCause().printStackTrace();
        ConstraintViolationException cve = (ConstraintViolationException) ve.getCause();
        Set<? extends ConstraintViolation<?>> scv = (Set<? extends ConstraintViolation<?>>) cve.getConstraintViolations();
        errors = validationConvertor.to(scv);
    }
       
    //render to respond
    Respond respond = new StringBuilderRespond(instance);
View Full Code Here

      @Override
      public void validate(Object object) {
          Set<? extends ConstraintViolation<?>> cvs = validator.validate(object);
          if ((cvs != null) && (! cvs.isEmpty())) {
              throw new ValidationException(new ConstraintViolationException((Set<ConstraintViolation<?>>) cvs));
          }
      }

    private void readParams() {
        ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder();
View Full Code Here

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

        try {
            gamesManager.addSportMan("ILoseTwo", "TOO-LONG");
            fail("country should be between 2 and 4 characters");
        } catch (final 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 (final EJBException wrappingException) {
            assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
            ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
            assertEquals(1, exception.getConstraintViolations().size());
        }
    }
View Full Code Here

    @Override
    public void validate(Object object) {
        Set<? extends ConstraintViolation<?>> cvs = validator.validate(object);
        if ((cvs != null) && (! cvs.isEmpty())) {
            throw new ValidationException(new ConstraintViolationException((Set<ConstraintViolation<?>>) cvs));
        }
    }
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.