/** * @see ConstraintViolation#getExecutableReturnValue */ public Object getExecutableReturnValue() { return constraintViolation.getExecutableReturnValue(); }
public ServiceMethodConstraintViolation(Class serviceInterface, ConstraintViolation violation) { this.message = violation.getMessage(); this.messageTemplate = violation.getMessageTemplate(); this.invalidValue = violation.getInvalidValue(); this.constraintDescriptor = violation.getConstraintDescriptor(); this.executableParameters = violation.getExecutableParameters(); this.executableReturnValue = violation.getExecutableReturnValue(); this.rootBeanClass = serviceInterface; this.propertyPath = violation.getPropertyPath(); }
@Test @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "f") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "g") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "h") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "i") public void testOneViolationForCascadedValidation() throws Exception { Item leaf = new Item( "foo" ); Object createdObject = new OrderLine( leaf ); Constructor<OrderLine> constructor = OrderLine.class.getConstructor( Item.class ); Set<ConstraintViolation<Object>> violations = getExecutableValidator().validateConstructorReturnValue( constructor, createdObject ); assertNumberOfViolations( violations, 1 ); ConstraintViolation<Object> violation = violations.iterator().next(); assertEquals( violation.getLeafBean(), leaf ); assertEquals( violation.getInvalidValue(), "foo" ); assertNull( violation.getExecutableParameters() ); assertEquals( violation.getExecutableReturnValue(), createdObject ); } }
@Test @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "f") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "g") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "h") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "i") public void testOneViolationForCascadedValidation() throws Exception { Item leaf = new Item( "foo" ); Constructor<OrderLine> constructor = OrderLine.class.getConstructor( Item.class ); Object[] parameterValues = new Object[] { leaf }; Set<ConstraintViolation<OrderLine>> violations = getExecutableValidator().validateConstructorParameters( constructor, parameterValues ); assertNumberOfViolations( violations, 1 ); ConstraintViolation<OrderLine> violation = violations.iterator().next(); assertEquals( violation.getLeafBean(), leaf ); assertEquals( violation.getInvalidValue(), "foo" ); assertEquals( violation.getExecutableParameters(), parameterValues ); assertNull( violation.getExecutableReturnValue() ); }
@Test @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "f") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "g") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "h") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "i") public void testOneViolationForCascadedValidation() throws Exception { String methodName = "getItem"; Object object = new OrderLine( null ); Item returnValue = new Item( "foo" ); Method method = OrderLine.class.getMethod( methodName ); Set<ConstraintViolation<Object>> violations = getExecutableValidator().validateReturnValue( object, method, returnValue ); assertNumberOfViolations( violations, 1 ); ConstraintViolation<Object> violation = violations.iterator().next(); assertEquals( violation.getLeafBean(), returnValue ); assertEquals( violation.getInvalidValue(), "foo" ); assertNull( violation.getExecutableParameters() ); assertEquals( violation.getExecutableReturnValue(), returnValue ); }
@Test @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "f") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "g") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "h") @SpecAssertion(section = Sections.VALIDATIONAPI_CONSTRAINTVIOLATION, id = "i") public void testOneViolationForCascadedValidation() throws Exception { String methodName = "setItem"; Object object = new OrderLine( null ); Item leaf = new Item( "foo" ); Method method = OrderLine.class.getMethod( methodName, Item.class ); Object[] parameterValues = new Object[] { leaf }; Set<ConstraintViolation<Object>> violations = getExecutableValidator().validateParameters( object, method, parameterValues ); assertNumberOfViolations( violations, 1 ); ConstraintViolation<Object> violation = violations.iterator().next(); assertEquals( violation.getLeafBean(), leaf ); assertEquals( violation.getInvalidValue(), "foo" ); assertEquals( violation.getExecutableParameters(), parameterValues ); assertNull( violation.getExecutableReturnValue() ); }
assertEquals( violation.getInvalidValue(), arg0 ); assertEquals( violation.getExecutableParameters(), parameterValues ); assertNull( violation.getExecutableReturnValue() );
assertEquals( violation.getInvalidValue(), "ABCDEFGH1234", "Wrong validated value" ); assertNull( violation.getExecutableParameters() ); assertNull( violation.getExecutableReturnValue() ); assertNotNull( violation.getConstraintDescriptor(), "Constraint descriptor should not be null" ); Annotation ann = violation.getConstraintDescriptor().getAnnotation();
assertEquals( violation.getInvalidValue(), returnValue ); assertNull( violation.getExecutableParameters() ); assertEquals( violation.getExecutableReturnValue(), returnValue );
assertEquals( violation.getInvalidValue(), returnValue ); assertNull( violation.getExecutableParameters() ); assertEquals( violation.getExecutableReturnValue(), returnValue );
assertEquals( violation.getInvalidValue(), arg0 ); assertEquals( violation.getExecutableParameters(), parameterValues ); assertNull( violation.getExecutableReturnValue() );
assertNull( constraintViolation.getLeafBean() ); assertNull( constraintViolation.getExecutableParameters() ); assertNull( constraintViolation.getExecutableReturnValue() );
assertEquals( violation.getInvalidValue(), townInNorthWales ); assertNull( violation.getExecutableParameters() ); assertNull( violation.getExecutableReturnValue() ); assertCorrectConstraintViolationMessages( constraintViolations, "City name cannot be longer than 30 characters."