/** * @see ConstraintViolation#getExecutableParameters */ public Object[] getExecutableParameters() { return constraintViolation.getExecutableParameters(); }
@Override public void invoke(int index, ConstraintViolation error, int length) throws ExitLoop, ContinueLoop, LoopException { infos.add(error.getMessage()); errors.add(NutMap.NEW().addv("msg", error.getMessage()).addv("obj", error.getConstraintDescriptor()).addv("arguments", error.getExecutableParameters())); } });
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" ); 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 { 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 { 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() ); }
assertNull( violation.getLeafBean() ); assertEquals( violation.getInvalidValue(), arg0 ); assertEquals( violation.getExecutableParameters(), parameterValues ); assertNull( violation.getExecutableReturnValue() );
assertEquals( violation.getLeafBean(), returnValue ); assertEquals( violation.getInvalidValue(), returnValue ); assertNull( violation.getExecutableParameters() ); assertEquals( violation.getExecutableReturnValue(), returnValue );
assertEquals( violation.getLeafBean(), engine ); assertEquals( violation.getInvalidValue(), "ABCDEFGH1234", "Wrong validated value" ); assertNull( violation.getExecutableParameters() ); assertNull( violation.getExecutableReturnValue() ); assertNotNull( violation.getConstraintDescriptor(), "Constraint descriptor should not be null" );
assertEquals( violation.getLeafBean(), object ); assertEquals( violation.getInvalidValue(), returnValue ); assertNull( violation.getExecutableParameters() ); assertEquals( violation.getExecutableReturnValue(), returnValue );
assertEquals( violation.getLeafBean(), object ); assertEquals( violation.getInvalidValue(), arg0 ); assertEquals( violation.getExecutableParameters(), parameterValues ); assertNull( violation.getExecutableReturnValue() );
assertNull( constraintViolation.getRootBean() ); assertNull( constraintViolation.getLeafBean() ); assertNull( constraintViolation.getExecutableParameters() ); assertNull( constraintViolation.getExecutableReturnValue() );
assertEquals( violation.getLeafBean(), address ); assertEquals( violation.getInvalidValue(), townInNorthWales ); assertNull( violation.getExecutableParameters() ); assertNull( violation.getExecutableReturnValue() ); assertCorrectConstraintViolationMessages(