JSR-349:Bean Validation TCK Coverage

1.1.0

Contents

Chapter Summary
Section Summary
Coverage Detail
Unmatched Tests
Unversioned Tests
Test Group Summary

Coverage Distribution

 
 
 
 
 
 
 
 
 
 

Chapter Summary

Chapter Assertions Testable Total Tested Total Tests Tested
(problematic)
Tested
(working)
Coverage %
2 Constraint Definition51444470044100.00%
3 Constraint declaration and validation process69585885058100.00%
4 Validation APIs877171130071100.00%
5 Constraint metadata request APIs25252550025100.00%
6 Built-in Constraint definitions1515150015100.00%
7 XML deployment descriptor42424271042100.00%
8 Exception model5441204100.00%
Total2942592594180259100.00%

Section Summary

SectionAssertionsTestableTotal TestedTested
(problematic)
Tested
(working)
Coverage %
2 Constraint Definition00000
2.1 Constraint Annotation42202100.00%
2.1.1 Constraint definition properties101010010100.00%
2.2 Applying multiple constraints of the same type11101100.00%
2.3 Constraint composition161616016100.00%
2.4 Constraint validation implementation171212012100.00%
2.5 The ConstraintValidatorFactory33303100.00%
3 Constraint declaration and validation process00000
3.1 Requirements on classes to be validated43303100.00%
3.1.1 Object validation11101100.00%
3.1.2 Field and property validation65505100.00%
3.1.3 Graph validation111111011100.00%
3.3 Inheritance22202100.00%
3.4 Group and group sequence44404100.00%
3.4.1 Group inheritance22202100.00%
3.4.2 Group sequence 107707100.00%
3.4.3 Redefining the Default group for a class43303100.00%
3.4.4 Implicit grouping11101100.00%
3.4.5 Formal group definitions22202100.00%
3.5 Validation routine31101100.00%
3.5.1 Object graph validation 55505100.00%
3.5.2 Traversable property85505100.00%
3.5.3 ConstraintValidator resolution algorithm66606100.00%
4 Validation APIs00000
4.1 Validator API 10000
4.1.1 Validation methods111111011100.00%
4.1.2 groups32202100.00%
4.2 ConstraintViolation141313013100.00%
4.3.1 Default message interpolation88808100.00%
4.3.1.1 Default message interpolation algorithm86606100.00%
4.3.2 Custom message interpolation21101100.00%
4.4 Bootstrapping11101100.00%
4.4.1 Examples10000
4.4.2 ValidatorFactory22202100.00%
4.4.3 Configuration31101100.00%
4.4.4.1 ValidationProviderResolver32202100.00%
4.4.4.2 ValidationProvider55505100.00%
4.4.5 Validation66606100.00%
4.4.6 XML Configuration171313013100.00%
4.4.7 Usage20000
5 Constraint metadata request APIs00000
5.1 Validator33303100.00%
5.2 PropertyDescriptor66606100.00%
5.3 BeanDescriptor33303100.00%
5.4 PropertyDescriptor22202100.00%
5.5 ConstraintDescriptor111111011100.00%
6 Built-in Constraint definitions151515015100.00%
7 XML deployment descriptor11101100.00%
7.1 Constraint definition and declaration55505100.00%
7.1.1 Constraint declaration in XML66606100.00%
7.1.1.1 Class-level overriding55505100.00%
7.1.1.2 Field-level overriding66606100.00%
7.1.1.3 Property-level overriding66606100.00%
7.1.1.4 Constraint declaration88808100.00%
7.1.2 Overriding constraint definitions in XML55505100.00%
8 Exception model11101100.00%
8.2 ConstraintDefinitionException11101100.00%
8.3 ConstraintDeclarationException and UnexpectedTypeException21101100.00%
8.4 GroupDefinitionException11101100.00%

Coverage Detail

Colour Key
Assertion is covered
Assertion is not covered
Assertion test is unimplemented
Assertion is untestable

Section 2.1 - Constraint Annotation

a)

An annotation is considered a constraint definition if its retention policy contains RUNTIME and if the annotation itself is annotated with javax.validation.Constraint

b)

Constraint annotations can target any of the following ElementTypes: FIELD, METHOD, TYPE, ANNOTATION_TYPE

c)

If a constraint definition is not valid, a ConstraintDefinitionException is raised either at validation time or when the metadata is requested

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithoutMessageParameter()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithoutGroupParameter()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithoutPayloadParameter()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongDefaultGroupValue()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongDefaultPayloadValue()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongPayloadClass()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongMessageType()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongGroupType()
d)

Applying a constraint annotation to an incompatible type will raise a UnexpectedTypeException

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithParameterStartingWithValid()
org.hibernate.beanvalidation.tck.tests.constraints.validatorresolution
ValidatorResolutionTest.testUnexpectedTypeInValidatorResolution()

Section 2.1.1 - Constraint definition properties

a)

A constraint definition may have attributes that are specified at the time the constraint is applied to a JavaBean.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintdefinition
ConstraintDefinitionsTest.testConstraintWithCustomAttributes()
b)

Annotation elements starting with valid are not allowed

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithParameterStartingWithValid()
c)

Every constraint annotation must define a message element of type String

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithoutMessageParameter()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongMessageType()
d)

Every constraint annotation must define a groups element that specifies which processing groups the constraint definition is associated with.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithoutGroupParameter()
e)

The default value for the groups element must be an empty array.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongDefaultGroupValue()
f)

If no group is specified when declaring the constraint on an element, the Default group is considered declared.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintdefinition
ConstraintDefinitionsTest.testDefaultGroupAssumedWhenNoGroupsSpecified()
The following assertion is not made explicitly by the spec, however it is implied g)

The type of the groups parameter is Class<?>[].

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongGroupType()
h)

Every constraint annotation must define a payload element that specifies which payload the constraint declaration is associated with.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithoutPayloadParameter()
i)

The default value for the payload parameter must be an empty array.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongDefaultPayloadValue()
j)

Each attachable payload extends Payload.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongPayloadClass()

Section 2.2 - Applying multiple constraints of the same type

a)

The bean validation provider treats regular annotations (annotations not annotated by @Constraint) whose value element has a return type of an array of constraint annotations in a special way. Each element in the value array are processed by the Bean Validation implementation as regular constraint annotations.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintdefinition
ConstraintDefinitionsTest.testConstraintWithCustomAttributes()

Section 2.3 - Constraint composition

a)

Each constraint annotation hosted on a constraint annotation is applied to the target element and this recursively

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testComposedConstraints()
ConstraintCompositionTest.testComposedConstraintsAreRecursive()
b)

Note that the main annotation and its constraint validation implementation is also applied

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testValidationOfMainAnnotationIsAlsoApplied()
c)

By default, each failing constraint generates an error report

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testEachFailingConstraintCreatesConstraintViolation()
d)

Groups from the main constraint annotation are inherited by the composing annotations

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testGroupsDefinedOnMainAnnotationAreInherited()
e)

Any groups definition on a composing annotation is ignored

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testGroupsDefinedOnMainAnnotationAreInherited()
f)

The property type a composed constraint is placed on must be compatible with all constraints (composing and composed)

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testAllComposingConstraintsMustBeApplicableToAnnotatedType()
g)

If a composed constraint is marked as @ReportAsSingleViolation, and if any of its composing constraint reports one or more violations, all reports from composing constraints are ignored and the error report corresponding to the composed constraint is generated

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testOnlySingleConstraintViolation()
org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition.nestedconstraintcomposition
NestedConstraintCompositionTest.testCompositeConstraint1WithNestedConstraintSingleViolation()
NestedConstraintCompositionTest.testCompositeConstraint2WithNestedConstraintSingleViolation()
NestedConstraintCompositionTest.testCompositeConstraint3WithNestedConstraint()
NestedConstraintCompositionTest.testCompositeConstraint4WithNestedConstraintSingleViolation()
h)

Composing annotations can define the value of message and custom attributes (excluding groups) but these are fixed in the composed constraint definition

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testAttributesDefinedOnComposingConstraints()
i)

It is possible to override attributes and messages defined on a composing annotation. An attribute from the main annotation is used to override one or more attributes of the composing annotations. Such an attribute is annotated with the @OverridesAttribute annotation or its multivalued equivalent @OverridesAttribute.List

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testEachFailingConstraintCreatesConstraintViolation()
j)

The types of the overridden and overriding attributes must be identical

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testOverriddenAttributesMustMatchInType()
k)

A composing constraint can itself be a composed constraint. In this case, attribute values are overridden recursively according to the described rules

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testComposedConstraints()
ConstraintCompositionTest.testComposedConstraintsAreRecursive()
l)

If a constraint is used more than once as a composing constraint, the multi value constraints model as described in Section 2.2 is used

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testEachFailingConstraintCreatesConstraintViolation()
m)

To select the appropriate composing constraint targeted, OverridesAttrib- ute.constraintIndex is used. It represents the constraint index in the value array

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testEachFailingConstraintCreatesConstraintViolation()
n)

If index is undefined, the single constraint declaration is targeted

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testEachFailingConstraintCreatesConstraintViolation()
o)

If the composition is invalid (infinite composition, wrong attribute overriding, a single attribute mapped to more than one source attribute etc), a ConstraintDefinitionException is raised either at validation time or when the metadata is requested

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testOverriddenAttributesMustMatchInType()
p)

Any payload definition on a composing annotation is ignored

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testPayloadPropagationInComposedConstraints()

Section 2.4 - Constraint validation implementation

a)

A constraint validation implementation performs the validation of a given constraint annotation for a given type

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.customconstraint
CustomConstraintValidatorTest.testRightValidatorIsSelectedAndInitializedCalled()
CustomConstraintValidatorTest.testIsValidIsCalledForEachValidation()
b)

The implementation classes are specified by the validatedBy element of the @Constraint annotation that decorates the constraint definition

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.customconstraint
CustomConstraintValidatorTest.testRightValidatorIsSelectedAndInitializedCalled()
CustomConstraintValidatorTest.testIsValidIsCalledForEachValidation()
c)

The constraint validation implementation implements the ConstraintValidator interface

d)

T must resolve in a non parameterized type or generic parameters of T must be unbounded wildcard types

e)

The initialize method is called by the Bean validation provider prior to any use of the constraint implementation.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.customconstraint
CustomConstraintValidatorTest.testRightValidatorIsSelectedAndInitializedCalled()
f)

The isValid method is evaluated by the Bean Validation provider each time a given value is validated

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.customconstraint
CustomConstraintValidatorTest.testIsValidIsCalledForEachValidation()
g)

It returns false if the value is not valid, true otherwise

h)

isValid implementations must be thread-safe

i)

If the property is of an unanticipated type, an UnexpectedTypeException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.validatorresolution
ValidatorResolutionTest.testUnexpectedTypeInValidatorResolution()
org.hibernate.beanvalidation.tck.tests.constraints.customconstraint
CustomConstraintValidatorTest.testUnexpectedTypeExceptionIsRaisedForInvalidType()
j)

If an exception occurs either in the initialize or isValid method, the runtime exception is wrapped into a ValidationException by the Bean Validation engine

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.customconstraint
CustomConstraintValidatorTest.testRuntimeExceptionFromIsValidIsWrapped()
CustomConstraintValidatorTest.testRuntimeExceptionFromInitializeIsWrapped()
k)

The constraint validation implementation is not allowed to change the state of the value passed to isValid.

l)

By default, each invalid constraint leads to the generation of one error object represented by a ConstraintViolation object. This object is build from the default error message as defined by the constraint declaration and the context in which the constraint declaration is placed on (bean, property, attribute)

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.customconstraint
CustomConstraintValidatorTest.testOneConstraintViolationPerFailingConstraint()
org.hibernate.beanvalidation.tck.tests.validation.validatorcontext
ConstraintValidatorContextTest.testDefaultError()
m)

The ConstraintValidatorContext methods let the constraint implementation disable the default error object generation and create one or more custom ones

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.constraintcomposition
ConstraintCompositionTest.testValidationOfMainAnnotationIsAlsoApplied()
org.hibernate.beanvalidation.tck.tests.validation.validatorcontext
ConstraintValidatorContextTest.testDisableDefaultErrorWithCustomErrorNoSubNode()
ConstraintValidatorContextTest.testDisableDefaultErrorWithCustomErrorWithSubNode()
ConstraintValidatorContextTest.propertyPathInIterable()
n)

The non-interpolated message passed as a parameter is used to build the ConstraintViolation object (the message interpolation operation is applied to it)

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.customconstraint
CustomConstraintValidatorTest.testNonInterpolatedMessageParameterIsUsed()
o)

By default, the propertyPath exposed on the ConstraintViolation represents the path to the bean or property hosting the constraint

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testGraphValidationWithList()
ValidateTest.testGraphValidationWithArray()
org.hibernate.beanvalidation.tck.tests.constraints.customconstraint
CustomConstraintValidatorTest.testDefaultPropertyPath()
q)

You can point an error to a subpath of this default path by using the error builder fluent API.

Coverage

org.hibernate.beanvalidation.tck.tests.validation.validatorcontext
ConstraintValidatorContextTest.testDisableDefaultErrorWithCustomErrorWithSubNode()
ConstraintValidatorContextTest.propertyPathInIterable()
r)

If disableDefaultError is called, no custom error is added (using the error builder) and if the constraint is not valid, a ValidationException is raised.

Coverage

org.hibernate.beanvalidation.tck.tests.validation.validatorcontext
ConstraintValidatorContextTest.testDisableDefaultErrorWithoutAddingCustomError()

Section 2.5 - The ConstraintValidatorFactory

a)

The default ConstraintValidatorFactory provided by the Bean Validation provider implementation uses the public constraint no-arg constructor

Coverage

org.hibernate.beanvalidation.tck.tests.validatorfactory
CustomConstraintValidatorTest.testDefaultConstructorInValidatorCalled()
b)

If an exception occurs in the factory while retrieving the ConstraintValidator instance, the runtime exception is wrapped in a ValidationException

Coverage

org.hibernate.beanvalidation.tck.tests.validatorfactory
CustomConstraintValidatorTest.testRuntimeExceptionInValidatorCreationIsWrapped()
c)

If the instance returned by the factory is null, a ValidationException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.validatorfactory
CustomConstraintValidatorTest.testValidationExceptionIsThrownInCaseFactoryReturnsNull()

Section 3.1 - Requirements on classes to be validated

a)

Properties to be validated must follow the method signature conventions for JavaBeans read properties, as defined by the JavaBeans specification

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testUnexpectedTypeException()
ValidateTest.testConstraintViolation()
b)

Static fields and static methods are excluded from validation

c)

Constraints can be applied to interfaces and superclasses

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.application
ValidationRequirementTest.testClassLevelConstraints()
d)

The target of an annotation definition can be a field, property, or type, provided that the constraint definition supports the specified target and the constraint supports the declared type of the target.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.application
ValidationRequirementTest.testClassLevelConstraints()
ValidationRequirementTest.testFieldAccess()
ValidationRequirementTest.testPropertyAccess()

Section 3.1.1 - Object validation

a)

Constraint declarations can be applied to a class or an interface

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.application
ValidationRequirementTest.testClassLevelConstraints()

Section 3.1.2 - Field and property validation

a)

Constraint declarations can be applied on both fields and properties for the same object type

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.application
ValidationRequirementTest.testFieldAccess()
ValidationRequirementTest.testPropertyAccess()
ValidationRequirementTest.testConstraintAppliedOnFieldAndProperty()
b)

The same constraint should however not be duplicated between a field and its associated property (the constraint validation would be applied twice)

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.application
ValidationRequirementTest.testConstraintAppliedOnFieldAndProperty()
c)

When a field is annotated with a constraint declaration, field access strategy is used to access the state validated by such constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.application
ValidationRequirementTest.testFieldAccess()
d)

When a property is annotated with a constraint declaration, property access strategy is used to access the state validated by such constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.application
ValidationRequirementTest.testPropertyAccess()
e)

The fields or methods visibility are not constrained

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.application
ValidationRequirementTest.testFieldAndPropertyVisibilityIsNotConstrained()
f)

Constraints on non getter methods are not supported

Section 3.1.3 - Graph validation

a)

Consider the situation where bean X contains a field of type Y. By annotating field Y with the @Valid annotation, the Validator will validate Y (and its properties) when X is validated.

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testGraphNavigationDeterminism()
b)

The exact type Z of the value contained in the field declared of type Y (subclass, implementation) is determined at runtime. The constraint definitions of Z are used

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testTypeOfContainedValueIsDeterminedAtRuntime()
c)

Array of objects is supported by @Valid. The content of the array is validated.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testGraphValidationWithArray()
d)

java.util.Collection is supported by @Valid. The content of the collection is validated.

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testTypeOfContainedValuesIsDeterminedAtRuntime()
e)

java.util.Set is supported by @Valid. The content of the Set is validated.

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testContainedSet()
f)

java.util.List is supported by @Valid. The content of the list is validated.

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testNoEndlessLoop()
g)

java.util.Map is supported by @Valid

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testContainedMap()
h)

java.lang.Iterable is supported by @Valid. The elements of the iterable are validated

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testContainedIterable()
i)

For Map, the value of each entry is validated (the key is not validated)

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testContainedMap()
j)

Like regular references, the type of the collection, array or Iterable element is determined at runtime and the constraint definitions for this particular type are used

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testTypeOfContainedValuesIsDeterminedAtRuntime()
k)

The @Valid annotation is applied recursively

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testGraphNavigationDeterminism()

Section 3.3 - Inheritance

a)

A constraint declaration can be placed on an interface

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.inheritance
ConstraintInheritanceTest.testConstraintsOnInterfaceAreInherited()
b)

For a given class, constraint declarations held on superclasses as well as interfaces are evaluated by the Bean Validation provider

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.inheritance
ConstraintInheritanceTest.testConstraintsOnInterfaceAreInherited()
ConstraintInheritanceTest.testConstraintsOnSuperClassAreInherited()

Section 3.4 - Group and group sequence

a)

If no group is explicitly declared, a constraint belongs to the Default group

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testConstraintWithNoExplicitlySpecifiedGroupBelongsToDefault()
b)

Groups are represented by interfaces

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testValidateAgainstDifferentGroups()
c)

A constraint can belong to one or more groups

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testValidationFailureInMultipleGroups()
GroupTest.testConstraintCanBelongToMoreThanOneGroup()
d)

During the validation call, one or more groups are validated. All the constraints belonging to this set of group is evaluated on the object graph

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testValidateAgainstDifferentGroups()
GroupTest.testGroups()
GroupTest.testGroupSequenceFollowedByGroup()

Section 3.4.1 - Group inheritance

a)

A group can inherit one or more groups by using interface inheritance

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.inheritance
GroupInheritanceTest.testGroupCanInheritGroupsViaInterfaceInheritance()
b)

For a given interface Z, constraints marked as belonging to the group Z (ie where the annotation groups property contains the interface Z) or any of the super interfaces of Z (inherited groups) are considered part of the group Z

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.inheritance
GroupInheritanceTest.testGroupMembership()

Section 3.4.2 - Group sequence

a)

By default, constraints are evaluated in no particular order and this regardless of which groups they belong to

b)

Each group in a group sequence must be processed sequentially in the order defined by @GroupSequence.value when the group defined as a sequence is requested

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testGroupSequence()
org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testFullGraphValidationBeforeNextGroupInSequence()
c)

Note that a group member of a sequence can itself be composed of several groups via inheritance or sequence definition. In this case, each composed group must respect the sequence order as well.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.groupsequence
SequenceResolutionTest.testGroupSequenceContainerOtherGroupSequences()
d)

If one of the groups processed in the sequence generates one or more constraint violation, the groups following in the sequence must not be processed

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testGroupSequence()
org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testFullGraphValidationBeforeNextGroupInSequence()
e)

Groups defining a sequence and groups composing a sequence must not be involved in a cyclic dependency either directly or indirectly, either through cascaded sequence definition or group inheritance

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.groupsequence
SequenceResolutionTest.testInvalidDefinitionOfDefaultSequenceInEntity()
org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testCyclicGroupSequence()
f)

If a group containing such a circularity is evaluated, a GroupDefinitionException is raised.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.groupsequence
SequenceResolutionTest.testInvalidDefinitionOfDefaultSequenceInEntity()
org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testCyclicGroupSequence()
g)

Groups defining a sequence should not directly inherit other groups. In other words, the interface hosting the group sequence should not have any super interface.

h)

Groups defining a sequence should not be used directly in constraint declarations

i)

To define a group as a sequence, the interface must be annotated with the @GroupSequence annotation

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.groupsequence
SequenceResolutionTest.testInvalidDefinitionOfDefaultSequenceInEntity()
org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testCyclicGroupSequence()
j)

A given constraint can belong to two groups ordered by a sequence. In this case, the constraint is evaluated as part of the first group and ignored in the subsequent group(s)

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.groupsequence
SequenceResolutionTest.testOnlyFirstGroupInSequenceGetEvaluated()

Section 3.4.3 - Redefining the Default group for a class

a)

To redefine Default for a class, place a @GroupSequence annotation on the class. this sequence expresses the sequence of groups that does substitute Default for this class.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.groupsequenceisolation
GroupSequenceIsolationTest.testCorrectDefaultSequenceInheritance()
GroupSequenceIsolationTest.testCorrectDefaultSequenceInheritance2()
org.hibernate.beanvalidation.tck.tests.constraints.groups
DefaultGroupRedefinitionTest.testRedefiningDefaultGroup()
DefaultGroupRedefinitionTest.testValidatingAgainstRedefinedDefaultGroup()
b)

Constraints hosted on a class A and belonging to the Default group (by default or explicitly) implicitly belong to the group A

c)

A sequence defined on a class A (ie. redefining the Default groups for the class) must contain the group A

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups
DefaultGroupRedefinitionTest.testGroupSequenceContainingDefault()
DefaultGroupRedefinitionTest.testGroupSequenceWithNoImplicitDefaultGroup()
org.hibernate.beanvalidation.tck.tests.constraints.groups.groupsequenceisolation
GroupSequenceIsolationTest.testCorrectDefaultSequenceInheritance()
GroupSequenceIsolationTest.testCorrectDefaultSequenceInheritance2()
d)

If a @GroupSequence redefining the Default group for a class A does not contain the group A, a GroupDefinitionException is raised when the class is validated or when its metadata is requested

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups
DefaultGroupRedefinitionTest.testGroupSequenceContainingDefault()
DefaultGroupRedefinitionTest.testGroupSequenceWithNoImplicitDefaultGroup()

Section 3.4.4 - Implicit grouping

a)

Every constraint hosted on an interface Z and part of the Default group (implicitly or explicitly) belongs to the group Z

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testImplicitGrouping()

Section 3.4.5 - Formal group definitions

a)

If a class does have a @GroupSequence annotation, the group Default contains every constraint belonging to every group declared by the @GroupSequence annotation.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.groupsequenceisolation
GroupSequenceIsolationTest.testCorrectDefaultSequenceInheritance()
GroupSequenceIsolationTest.testCorrectDefaultSequenceInheritance2()
b)

If class X has no @GroupSequence annotation, the group Default contains every constraint in the group X and if X has a direct superclass Y, every constraint in the group Default of Y this rule

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.groupsequenceisolation
GroupSequenceIsolationTest.testCorrectDefaultSequenceInheritance3()

Section 3.5 - Validation routine

a)

For a given group to validate, the validation routine applied on a given bean instance is expected to execute the constraint validations in no particular order

b)

Note that this implies that a given validation constraint will not be processed more than once per validation

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testValidationFailureInMultipleGroups()
org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testOnlyFirstGroupInSequenceGetEvaluated()
c)

Unless ordered by group sequences, groups can be validated in no particular order

Section 3.5.1 - Object graph validation

a)

The @Valid annotation on a given association (i.e. object reference or collection, array, Iterable of objects), dictates the Bean Validator implementation to apply recursively the bean validation routine on (each of) the associated object(s)

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testGraphNavigationDeterminism()
b)

This mechanism is recursive

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testGraphNavigationDeterminism()
c)

Null references are ignored

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testNullReferencesGetIgnored()
d)

To prevent infinite loops, the Bean Validation implementation must ignore the cascading operation if the associated object instance has already been validated in the current navigation path (starting from the root object)

Coverage

org.hibernate.beanvalidation.tck.tests.validation.graphnavigation
GraphNavigationTest.testNoEndlessLoop()
e)

@Valid is an orthogonal concept to the notion of group. If two groups are in sequence, the first group must pass for all associated objects before the second group is evaluated.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.groupsequenceisolation
GroupSequenceIsolationTest.testCorrectDefaultSequenceContainedCaseWithoutGroupRedefinitionOnContainedEntity()
GroupSequenceIsolationTest.testCorrectDefaultSequenceContainedCaseWithGroupRedefinitionOnContainedEntity()

Section 3.5.2 - Traversable property

a)

isReachable is called for every property about to be accessed either for validation or for cascading

Coverage

org.hibernate.beanvalidation.tck.tests.traversableresolver
TraversableResolverTest.testCorrectNumberOfCallsToIsReachableAndIsCascadable()
b)

isCascadable is called for every property about to be cascaded (ie. marked as @Valid)

Coverage

org.hibernate.beanvalidation.tck.tests.traversableresolver
TraversableResolverTest.testCorrectNumberOfCallsToIsReachableAndIsCascadable()
c)

isCascadable for a given property is only called if isReachable returns true. In other words, isReachable is always called before isCascadable for a given property

Coverage

org.hibernate.beanvalidation.tck.tests.traversableresolver
TraversableResolverTest.testCorrectNumberOfCallsToIsReachableAndIsCascadable()
d)

The Bean Validation provider must not access the state of a property, nor validate its constraints if the property is not traversable. A property is traversable if TraversableResolver returns true for this property

Coverage

org.hibernate.beanvalidation.tck.tests.traversableresolver
TraversableResolverTest.testCustomTraversableResolverViaConfiguration()
e)

If an exception occurs when the TraversableResolver is called, the exception is wrapped into a ValidationException

Coverage

org.hibernate.beanvalidation.tck.tests.traversableresolver
TraversableResolverTest.testResolverExceptionsGetWrappedInValidationException()
f)

If Java Persistence is available in the runtime environment, a property is considered reachable if Java Persistence considers the property as loaded

g)

If Java Persistence is not available in the runtime environment, all properties are considered reachable

h)

If Java Persistence is not available in the runtime environment, all properties are considered cascadable

Section 3.5.3 - ConstraintValidator resolution algorithm

a)

If the constraint declaration is hosted on a class or an interface, the targeted type is the class or the interface

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.validatorresolution
ValidatorResolutionTest.testTargetTypeIsInterface()
ValidatorResolutionTest.testTargetTypeIsClass()
b)

If the constraint is hosted on a class attribute, the type of the attribute is the targeted type

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.validatorresolution
ValidatorResolutionTest.testTargetedTypeIsField()
c)

If the constraint is hosted on a getter, the return type of the getter is the targeted type

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.validatorresolution
ValidatorResolutionTest.testTargetedTypeIsGetter()
d)

the ConstraintValidator chosen to validate a declared type T is the one where the type supported by the ConstraintValidator is a supertype of T and where there is no other ConstraintValidator whose supported type is a supertype of T and not a supertype of the chosen ConstraintValidator supported type

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.validatorresolution
ValidatorResolutionTest.testResolutionOfMultipleSizeValidators()
ValidatorResolutionTest.testResolutionOfMinMaxForDifferentTypes()
e)

If no ConstraintValidator compliant with T is found amongst the ConstraintValidators listed by the constraint A, a UnexpectedTypeException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.validatorresolution
ValidatorResolutionTest.testUnexpectedTypeInValidatorResolution()
org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testUnexpectedTypeException()
f)

If more than one maximally specific ConstraintValidator is found, a UnexpectedTypeException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.validatorresolution
ValidatorResolutionTest.testAmbiguousValidatorResolution()

Section 4.1 - Validator API

a)

Validator implementations are thread-safe

Section 4.1.1 - Validation methods

a)

validate(T object, Class... groups) is used to validate a given object

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testMultipleViolationOfTheSameType()
b)

An IllegalArgumentException is thrown when validateProperty is called and object is null or null is passed to the varargs groups.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testValidateWithNullValue()
ValidateTest.testValidateWithNullGroup()
ValidateTest.testPassingNullAsGroup()
c)

A Set containing all ConstraintViolation objects representing the failing constraints is returned, an empty Set is returned otherwise

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidatePropertyTest.testValidateProperty()
ValidateTest.testMultipleViolationOfTheSameType()
ValidateTest.testMultipleConstraintViolationOfDifferentTypes()
d)

validateProperty(T object, String propertyName, Class... groups) validates a given field or property of an object

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidatePropertyTest.testValidateProperty()
e)

An IllegalArgumentException is thrown when validateProperty is called and object is null or propertyName is null empty or invalid or null is passed to the varargs groups.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidatePropertyTest.testValidatePropertyWithInvalidPropertyPath()
ValidatePropertyTest.testPassingNullAsGroup()
ValidatePropertyTest.testIllegalArgumentExceptionIsThrownForNullValue()
ValidatePropertyTest.testValidatePropertyWithNullProperty()
ValidatePropertyTest.testValidatePropertyWithEmptyProperty()
f)

The property name in validateProperty is the JavaBeans property name (as defined by the JavaBeans Introspector class)

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidatePropertyTest.testValidatePropertyWithInvalidPropertyPath()
ValidatePropertyTest.testValidateProperty()
g)

@Valid is not honored by a call to validateProperty.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidatePropertyTest.testValidIsNotHonoredValidateProperty()
h)

validateValue(Class beanType, String propertyName, Object value, Class... groups) validates the property referenced by propertyName present on beanType or any of its superclasses, if the property value were value.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateValueTest.testValidateValueSuccess()
ValidateValueTest.testValidateValueFailure()
ValidateValueTest.testValidateValue()
i)

An IllegalArgumentException is thrown when validateValue is called and object is null or propertyName is null empty or invalid or null is passed to the varargs groups.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateValueTest.testValidateValueWithInvalidPropertyPath()
ValidateValueTest.testExistingPropertyWoConstraintsNorCascaded()
ValidateValueTest.testValidateValuePassingNullAsGroup()
ValidateValueTest.testValidateValueWithEmptyPropertyPath()
ValidateValueTest.testValidateValueWithNullObject()
ValidateValueTest.testValidateValueWithNullPropertyName()
j)

@Valid is not honored by validateValue.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateValueTest.testValidIsNotHonoredValidateValue()
k)

If some unrecoverable failure happens during validation, a ValidationException is raised.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidatePropertyTest.testUnexpectedExceptionsInValidatePropertyGetWrappedInValidationExceptions()
ValidateTest.testUnexpectedExceptionsInValidateGetWrappedInValidationExceptions()

Section 4.1.2 - groups

a)

All constraints belonging to the targeted group are applied during the validation routine.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateWithGroupsTest.testCorrectGroupsAreAppliedForValidate()
ValidateWithGroupsTest.testCorrectGroupsAreAppliedForValidateProperty()
ValidateWithGroupsTest.testCorrectGroupsAreAppliedForValidateValue()
b)

If no group is passed, the Default group is assumed

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateWithGroupsTest.testCorrectGroupsAreAppliedForValidate()
ValidateWithGroupsTest.testCorrectGroupsAreAppliedForValidateProperty()
ValidateWithGroupsTest.testCorrectGroupsAreAppliedForValidateValue()
c)

When more than one group is evaluated and passed to the various validate methods, order is not constrained

Section 4.2 - ConstraintViolation

a)

The getMessage method returns the interpolated (localized) message for the failing constraint

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testConstraintViolation()
b)

The getMessageTemplate method returns the non-interpolated error message

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testConstraintViolation()
c)

The getRootBean method returns the root object being validated that led to the failing constraint

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testConstraintViolation()
d)

The getInvalidValue method returns the value (field, property or validated object) being passed to isValid

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testConstraintViolation()
e)

getConstraintDescriptor provides access to the failing constraint metadata

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testConstraintViolation()
f)

getPropertyPath returns the Path object representing the navigation path from the root object to the failing object

Coverage

org.hibernate.beanvalidation.tck.tests.validation
PropertyPathTest.testPropertyPathWithConstraintViolationForRootObject()
PropertyPathTest.testPropertyPathTraversedObject()
PropertyPathTest.testPropertyPathWithList()
PropertyPathTest.testPropertyPathWithArray()
PropertyPathTest.testPropertyPathWithMap()
PropertyPathTest.testPropertyPathSet()
g)

If the failing object is the root object, the property path consists of a single Node with name set to null.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
PropertyPathTest.testPropertyPathWithConstraintViolationForRootObject()
h)

If failing object is traversed, a Node object whose name equals the name of the association property (field name or Java Bean property name) is added to Path.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
PropertyPathTest.testPropertyPathTraversedObject()
i)

If the traversed association is a List or an array, the added Node object contains the index value in getIndex.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
PropertyPathTest.testPropertyPathWithList()
PropertyPathTest.testPropertyPathWithArray()
j)

If the association is a Map, the added Node object (representing a given map entry) contains the key value in getKey

Coverage

org.hibernate.beanvalidation.tck.tests.validation
PropertyPathTest.testPropertyPathWithMap()
k)

For all Iterable or Map, the added Node object added is marked as inIterable (isInIterable)

Coverage

org.hibernate.beanvalidation.tck.tests.validation
PropertyPathTest.testPropertyPathWithList()
PropertyPathTest.testPropertyPathWithArray()
PropertyPathTest.testPropertyPathWithMap()
PropertyPathTest.testPropertyPathSet()
l)

For a property level constraint (field and getter) a Node object is added to Path whose name equals the name of the property.

Coverage

org.hibernate.beanvalidation.tck.tests.validation
PropertyPathTest.testPropertyPathTraversedObject()
m)

For a class level constraint a Node object is added to Path whose name is null

Coverage

org.hibernate.beanvalidation.tck.tests.validation
PropertyPathTest.testPropertyPathWithConstraintViolationForRootObject()
n)

Bean Validation implementations should ensure that a ConstraintViolation implementation is Serializable provided that the root bean, the leaf bean, the invalid value and keys in the Path object are Serializable objects.

Section 4.3.1 - Default message interpolation

a)

A conforming implementation includes a default message interpolator

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testDefaultMessageInterpolatorIsNotNull()
b)

Each constraint defines a message descriptor via its message property

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithoutMessageParameter()
c)

Every constraint definition shall define a default message descriptor for that constraint.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithoutMessageParameter()
d)

Messages can be overridden at declaration time in constraints by setting the property on the constraint.

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testMessagesCanBeOverriddenAtConstraintLevel()
e)

The message descriptor is a string literal and may contain one or more message parameters. Message parameters are string literals enclosed in braces

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testSuccessfulInterpolationOfValidationMessagesValue()
f)

\{ is considered as the literal { instead of being considered as the beginning of a message parameter

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testLiteralCurlyBraces()
g)

\} is considered as the literal } instead of being considered as the end of a message parameter

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testLiteralCurlyBraces()
h)

\\ is considered as the literal \ instead of being considered as the escaping character

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testLiteralCurlyBraces()

Section 4.3.1.1 - Default message interpolation algorithm

a)

Message parameters are extracted from the message string and used as keys to search the ResourceBundle named ValidationMessages (step1)

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testSuccessfulInterpolationOfValidationMessagesValue()
MessageInterpolationTest.testUnSuccessfulInterpolation()
MessageInterpolationTest.testUnknownTokenInterpolation()
b)

Step 1 is applied recursively until no replacement is performed

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testRecursiveMessageInterpolation()
c)

Message parameters are extracted from the message string and used as keys to search the Bean Validation provider's built-in ResourceBundle using the defined locale. If a property is found, the message parameter is replaced with the property value in the message string (step 2)

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testParametersAreExtractedFromBeanValidationProviderBundle()
e)

Contrary to step 1, step 2 is not processed recursively

f)

If step 2 triggers a replacement, then step 1 is applied again

g)

As last step message parameters are extracted from the message string. Those matching the name of an attribute of the constraint declaration are replaced by the value of that attribute.

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testConstraintAttributeValuesAreInterpolated()
h)

If the locale is passed to the interpolator method interpolate(String, CosntraintDescriptor, Object, Locale), this Locale instance is used

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testMessageInterpolationWithLocale()
i)

If the locale is not specified, the default Locale as provided by Locale.getDefault() is used.

Coverage

org.hibernate.beanvalidation.tck.tests.messageinterpolation
MessageInterpolationTest.testIfNoLocaleIsSpecifiedTheDefaultLocaleIsAssumed()

Section 4.3.2 - Custom message interpolation

a)

A message interpolator implementation shall be thread-safe

b)

It is possible to override the MessageInterpolator implementation for a given Validator instance by invoking ValidatorFactory.usingContext().messageInterpolator(messageInterpolator).getValidator()

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap
CustomMessageInterpolatorTest.testCustomMessageInterpolatorViaValidatorContext()
CustomMessageInterpolatorTest.testCustomMessageInterpolatorViaConfiguration()

Section 4.4 - Bootstrapping

a)

A bootstrap implementation must be able to bootstrap any Bean Validation provider implementation

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap.customprovider
BootstrapCustomProviderDefinedInServiceFileTest.testGetFactoryByProviderSpecifiedProgrammatically()
BootstrapCustomProviderDefinedInValidationXmlTest.testGetFactoryByProviderSpecifiedInValidationXml()

Section 4.4.1 - Examples

a)

The ValidatorFactory object is thread-safe

Section 4.4.2 - ValidatorFactory

a)

The MessageInterpolator or the TraversableResolver passed to the ValidatorContext are used instead of the ValidatorFactory's MessageInterpolator or TraversableResolver instances

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap
CustomMessageInterpolatorTest.testCustomMessageInterpolatorViaValidatorContext()
b)

getMessageInterpolator() returns the MessageInterpolator instance configured during the initialization of the ValidatorFactory

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap
CustomMessageInterpolatorTest.testCustomMessageInterpolatorViaValidatorContext()

Section 4.4.3 - Configuration

a)

A Bean Validation provider must define a sub interface of Configuration uniquely identifying the provider.

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap
ConfigurationTest.testProviderUnderTestDefinesSubInterfaceOfConfiguration()
b)

Streams represented in the XML configuration and opened by the Configuration implementation must be closed by the Configuration implementation after the ValidatorFactory creation (or if an exception occurs)

c)

If no ValidationProviderResolver instance has been specified, the default ValidationProviderResolver is used

Section 4.4.4.1 - ValidationProviderResolver

a)

ValidationProviderResolver returns the list of Bean Validation providers available at runtime and more specifically a ValidationProvider instance for each provider available in the context

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap.customprovider
BootstrapCustomProviderDefinedInServiceFileTest.testProviderResolverReturnsListOfAvailableProviders()
b)

Implementations must be thread-safe

c)

Bean Validation providers must supply a service provider configuration file by creating a text file javax.validation.spi.ValidationProvider and placing it in the META-INF/services directory of one of its jar files

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap
ValidationProviderResolverTest.testServiceFileExists()

Section 4.4.4.2 - ValidationProvider

a)

A client can request a specific Bean Validation provider by using Validation.byProvider() or by defining the provider in the XML configuration file

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap.customprovider
BootstrapCustomProviderDefinedInServiceFileTest.testGetFactoryByProviderSpecifiedProgrammatically()
BootstrapCustomProviderDefinedInValidationXmlTest.testGetFactoryByProviderSpecifiedInValidationXml()
b)

The provider discovery mechanism retrieve all available providers using ValidationProviderResolver.getValidationProviders() and returns the first ValidationProvider matching the requested provider

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap
ValidationProviderTest.testFirstMatchingValidationProviderResolverIsReturned()
c)

When the default Bean Validation provider is requested, the first ValidationProvider returned by the ValidationProviderResolver strategy is returned

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap
ValidationProviderTest.testByDefaultProviderUsesTheFirstProviderReturnedByValidationProviderResolver()
d)

Every Bean Validation provider must provide a ValidationProvider implementation containing a public no-arg constructor

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap
ValidationProviderTest.testValidationProviderContainsNoArgConstructor()
e)

If a problem occurs while building the ValidatorFactory, a ValidationException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap
ValidationProviderTest.testValidationExceptionIsThrownInCaseValidatorFactoryCreationFails()

Section 4.4.5 - Validation

a)

Validation.buildDefaultValidatorFactory(), is considered to be the default ValidatorFactory and is equivalent to the ValidatorFactory returned by Validation.byDefaultProvider().configure().buildValidatorFactory()

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidationTest.testBuildDefaultValidatorFactory()
b)

ValidationProvider.createGenericConfiguration(BootstrapState state) is the second bootstrapping entry point and let the client provide a custom ValidationProviderResolution instance

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidationTest.testCustomValidationProviderResolution()
c)

ValidationProvider.createGenericConfiguration(BootstrapState state) is the third bootstrapping entry point and let the client define the specific Bean Validation provider requested as well as a custom ValidationProviderResolver implementation if needed

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidationTest.testSpecificValidationProvider()
d)

The Validation implementation provided by the Bean Validation provider must not contain any non private attribute or method aside from the three public static bootstrap methods

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidationTest.testVerifyMethodsOfValidationObjects()
e)

The bootstrap implementation must ensure it can bootstrap third party providers

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidationTest.testCustomValidationProviderResolution()
ValidationTest.testSpecificValidationProvider()
f)

When building the Configuration object, if the ValidationProviderResolver fails or if the expected provider is not found, a ValidationException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap
ValidationProviderTest.testValidationExceptionIsThrownInCaseValidatorFactoryCreationFails()
org.hibernate.beanvalidation.tck.tests.validation
UnknownProviderBootstrapTest.testUnknownProviderThrowsValidationException()

Section 4.4.6 - XML Configuration

a)

Unless explicitly ignored Configuration takes into account the configuration available in META-INF/validation.xml

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testClassConstraintDefinedInXml()
XmlConfigurationTest.testPropertyConstraintDefinedInXml()
XmlConfigurationTest.testFieldConstraintDefinedInXml()
XmlConfigurationTest.testAnnotationDefinedConstraintApplies()
XmlConfigurationTest.testCascadingConfiguredInXml()
The following assertion is not made explicitly by the spec, however it is implied b)

META-INF/validation.xml will be ignored if Configuration.ignoreXMLConfiguration() is called.

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testIgnoreValidationXml()
c)

This configuration file is optional.

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
OptionalValidationXmlTest.testIgnoreValidationXml()
d)

If more than one META-INF/validation.xml file is found in the classpath, a ValidationException is raised.

e)

Unless stated otherwise, XML based configuration settings are overridden by values explicitly set via the Configuration API

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
MessageInterpolatorSpecifiedInValidationXmlTest.testMessageInterpolatorSpecifiedInValidationXmlCanBeOverridden()
TraversableResolverSpecifiedInValidationXmlTest.testTraversableResolverSpecifiedInValidationXmlCanBeOverridden()
f)

default-provider represents the class name of the provider specific Configuration sub-interface. If defined, the provider suitable for this interface is used

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
DefaultProviderSpecifiedInValidationXmlTest.testProviderSpecifiedInValidationXml()
g)

message-interpolator represents the fully qualified class name of the MessageInterpolator implementation. When defined in XML, the implementation must have a public no-arg constructor.

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
MessageInterpolatorSpecifiedInValidationXmlNoDefaultConstructorTest.testMessageInterpolatorSpecifiedInValidationXmlHasNoDefaultConstructor()
MessageInterpolatorSpecifiedInValidationXmlTest.testMessageInterpolatorSpecifiedInValidationXmlCanBeOverridden()
MessageInterpolatorSpecifiedInValidationXmlTest.testMessageInterpolatorSpecifiedInValidationXml()
h)

traversable-resolver represents the fully qualified class name of the TraversableResolver implementation. When defined in XML, the implementation must have a public no-arg constructor.

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
ConstraintValidatorFactorySpecifiedInValidationXmlTest.testConstraintValidatorFactorySpecifiedInValidationXmlCanBeOverridden()
TraversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest.testTraversableResolverSpecifiedInValidationXmlHasNoDefaultConstructor()
TraversableResolverSpecifiedInValidationXmlTest.testTraversableResolverSpecifiedInValidationXmlCanBeOverridden()
TraversableResolverSpecifiedInValidationXmlTest.testTraversableResolverSpecifiedInValidationXml()
i)

constraint-validator-factory represents the fully qualified class name of the ConstraintValidatorFactory implementation. When defined in XML, the implementation must have a public no-arg constructor.

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
ConstraintValidatorFactorySpecifiedInValidationXmlTest.testConstraintValidatorFactorySpecifiedInValidationXmlCanBeOverridden()
ConstraintValidatorFactorySpecifiedInValidationXmlTest.testConstraintValidatorFactorySpecifiedInValidationXml()
j)

message-interpolator, traversable-resolver and constraint-validator-factory are optional.

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
DefaultProviderSpecifiedInValidationXmlTest.testProviderSpecifiedInValidationXml()
k)

constraint-mapping represents the resource path of an XML mapping file

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testClassConstraintDefinedInXml()
XmlConfigurationTest.testIgnoreValidationXml()
XmlConfigurationTest.testPropertyConstraintDefinedInXml()
XmlConfigurationTest.testFieldConstraintDefinedInXml()
XmlConfigurationTest.testAnnotationDefinedConstraintApplies()
XmlConfigurationTest.testCascadingConfiguredInXml()
l)

More than one constraint-mapping element can be present

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testClassConstraintDefinedInXml()
XmlConfigurationTest.testIgnoreValidationXml()
XmlConfigurationTest.testPropertyConstraintDefinedInXml()
XmlConfigurationTest.testFieldConstraintDefinedInXml()
XmlConfigurationTest.testAnnotationDefinedConstraintApplies()
XmlConfigurationTest.testCascadingConfiguredInXml()
m)

Mappings provided via Configuration.addMapping(InputStream) are added to the list of mappings described via constraint-mapping

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testMappingFilesAddedViaConfigurationGetAddedToXmlConfiguredMappings()
n)

The namespace javax.validation for properties is reserved for use by this specification

o)

Properties defined via Configuration.addProperty(String, String) are added to the properties defined via property

p)

If a property with the same name are defined in both XML and via the programmatic API, the value provided via programmatic API has priority

q)

If a public no-arg constructor is missing, a ValidationException is raised during the Configuration.buildValidatorFactory() call

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
MessageInterpolatorSpecifiedInValidationXmlNoDefaultConstructorTest.testMessageInterpolatorSpecifiedInValidationXmlHasNoDefaultConstructor()
TraversableResolverSpecifiedInValidationXmlNoDefaultConstructorTest.testTraversableResolverSpecifiedInValidationXmlHasNoDefaultConstructor()

Section 4.4.7 - Usage

a)

ValidatorFactory is a thread-safe object that should be built once per deployment unit

b)

Validator is thread-safe too and should be considered a lightweight object

Section 5.1 - Validator

a)

If a constraint definition or declaration hosted by the requested class (or any of it's superclasses and interfaces according to the constraint propagation rules) is invalid, a ValidationException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testUnexpectedTypeException()
b)

Validator.getConstraintsForClass returns a BeanDescriptor object describing the bean level constraints and providing access to the property level constraints metadata.

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
BeanDescriptorTest.testIsBeanConstrainedDueToValidAnnotation()
BeanDescriptorTest.testIsBeanConstrainedDueToConstraintOnEntity()
BeanDescriptorTest.testIsBeanConstrainedDueToConstraintProperty()
BeanDescriptorTest.testIsBeanConstrainedDueToConstraintOnInterface()
BeanDescriptorTest.testUnconstrainedClass()
BeanDescriptorTest.testGetConstraintForConstrainedProperty()
BeanDescriptorTest.testGetConstraintsForNonExistingProperty()
BeanDescriptorTest.testGetConstrainedProperties()
BeanDescriptorTest.testGetConstrainedPropertiesForUnconstrainedEntity()
org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testConstraintDescriptorWithoutExplicitGroup()
c)

Validator.getConstraintsForClass throws an IllegalArgumentException if the clazz parameter is null

Coverage

org.hibernate.beanvalidation.tck.tests.validation
ValidateTest.testNullParameterToGetConstraintsForClass()

Section 5.2 - PropertyDescriptor

a)

getElementClass returns either the object type for a class, or the returned type for a property

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ElementDescriptorTest.testGetElementClass()
b)

getConstraintDescriptors returns all the ConstraintDescriptors hosted on the given element in the class hierarchy, each ConstraintDescriptor describing one of the constraints declared on the given element.

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ElementDescriptorTest.testGetConstraintDescriptors()
c)

hasConstraints returns true if the given element (class, field or property) in the class hierarchy holds at least one constraint declaration.

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ElementDescriptorTest.testHasConstraints()
d)

unorderedAndMatchingGroups restricts to the ConstraintDescriptors matching the set of groups passed as parameters and present on the element. Order is not respected but group inheritance and inheritance via sequence (including the Default group overriding at the class level) are honored.

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ElementDescriptorTest.testUnorderedAndMatchingGroups()
ElementDescriptorTest.testUnorderedAndMatchingGroupsWithInheritance()
ElementDescriptorTest.testUnorderedAndMatchingGroupsWithDefaultGroupOverriding()
e)

declaredOn lets you restrict the list of element types constraints are hosted on.

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ElementDescriptorTest.testDeclaredOn()
f)

lookingAt lets you restrict which constraints are considered. Either constraints belonging to the element but hosted on the class represented by BeanDescritptor (Scope.LOCAL_ELEMENT), or constraints belonging to the element but hosted anywhere in the class hierarchy (Scope.HIERARCHY).

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ElementDescriptorTest.testLookingAt()

Section 5.3 - BeanDescriptor

a)

isBeanConstrained returns true if the given class (and superclasses and interfaces) host at least one validation declaration (either constraint or @Valid annotation)

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
BeanDescriptorTest.testIsBeanConstrainedDueToValidAnnotation()
BeanDescriptorTest.testIsBeanConstrainedDueToConstraintOnEntity()
BeanDescriptorTest.testIsBeanConstrainedDueToConstraintProperty()
BeanDescriptorTest.testIsBeanConstrainedDueToConstraintOnInterface()
BeanDescriptorTest.testUnconstrainedClass()
b)

getConstraintsForProperty returns a PropertyDescriptor object describing the property level constraints (See Section 3.1.2). The property is uniquely identified by its name as per the JavaBeans convention: field level and getter level constraints of the given name are all returned

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
BeanDescriptorTest.testGetConstraintForConstrainedProperty()
BeanDescriptorTest.testGetConstraintForUnConstrainedProperty()
BeanDescriptorTest.testGetConstraintForUnConstrainedProperty()
BeanDescriptorTest.testGetConstraintsForNonExistingProperty()
BeanDescriptorTest.testGetConstrainedProperties()
BeanDescriptorTest.testGetConstrainedPropertiesForUnconstrainedEntity()
c)

getConstraintsForProperty throws an IllegalArgumentException if the propertyName parameter is null

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
BeanDescriptorTest.testGetConstraintsForNullProperty()

Section 5.4 - PropertyDescriptor

a)

The isCascaded method returns true if the property is marked with @Valid

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
BeanDescriptorTest.testGetConstraintForUnConstrainedProperty()
PropertyDescriptorTest.testIsNotCascaded()
PropertyDescriptorTest.testIsCascaded()
b)

getPropertyName returns the property name

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
PropertyDescriptorTest.testPropertyName()

Section 5.5 - ConstraintDescriptor

a)

If ConstraintDescriptor represents a composing annotation (see Section 2.3), the returned annotation must reflect parameter overriding

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ConstraintDescriptorTest.testAnnotationAndMapParametersReflectParameterOverriding()
b)

getAttributes returns a map containing the annotation attribute names as a key, and the annotation attribute values as a value

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ConstraintDescriptorTest.testGetAttributesFromConstraintDescriptor()
c)

If ConstraintDescriptor represents a composing annotation (see Section 2.3), the returned Map must reflect attribute overriding

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ConstraintDescriptorTest.testAnnotationAndMapParametersReflectParameterOverriding()
d)

getGroups returns the groups the constraint is supposed to be applied upon

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ConstraintDescriptorTest.testGetGroups()
ConstraintDescriptorTest.testGetGroupsOnInterface()
ConstraintDescriptorTest.testGetGroupsWithImplicitGroup()
e)

If no group is set on the constraint declaration, the Default group is returned

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ConstraintDescriptorTest.testDefaultGroupIsReturnedIfNoGroupSpecifiedInDeclaration()
f)

The groups of a composing constraint are the groups of the composed constraint

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ConstraintDescriptorTest.testComposingConstraints()
g)

getPayload returns the payloads the constraint hosts or an empty set if none

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ConstraintDescriptorTest.testPayload()
h)

Likewise, payload from the main constraint annotation is inherited by the composing annotations.

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ConstraintDescriptorTest.testComposingConstraintsPayload()
i)

Any payload definition on a composing annotation is ignored

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ConstraintDescriptorTest.testComposingConstraintsPayload()
k)

isReportAsSingleViolation() returns true if the constraint is annotated with @ReportAsSingleViolation

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ConstraintDescriptorTest.testReportAsSingleViolation()
l)

getComposingConstraints return a set of composing ConstraintDescriptors where each descriptor describes a composing constraint.

Coverage

org.hibernate.beanvalidation.tck.tests.metadata
ConstraintDescriptorTest.testComposingConstraints()
ConstraintDescriptorTest.testEmptyComposingConstraints()

Section 6 - Built-in Constraint definitions

a)

Each Bean Validation provider must recognize built-in constraint annotations as valid constraint definitions and provide compliant constraint implementations for each

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testNullConstraint()
BuiltinConstraintsTest.testNotNullConstraint()
BuiltinConstraintsTest.testAssertTrueConstraint()
BuiltinConstraintsTest.testAssertFalseConstraint()
BuiltinConstraintsTest.testMinConstraint()
BuiltinConstraintsTest.testMaxConstraint()
BuiltinConstraintsTest.testDecimalMinConstraint()
BuiltinConstraintsTest.testDecimalMaxConstraint()
BuiltinConstraintsTest.testSizeConstraint()
BuiltinConstraintsTest.testDigitsConstraint()
BuiltinConstraintsTest.testPastConstraint()
BuiltinConstraintsTest.testFutureConstraint()
BuiltinConstraintsTest.testPatternConstraint()
b)

The built-in constraint validation implementation is having a lower priority than an XML mapping definition

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinValidatorOverrideTest.testXmlConfiguredValidatorConfigurationHasPrecedence()
c)

@Null constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testNullConstraint()
d)

@NotNull constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testNotNullConstraint()
e)

@AssertTrue constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testAssertTrueConstraint()
f)

@AssertFalse constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testAssertFalseConstraint()
g)

@Min constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testMinConstraint()
h)

@Max constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testMaxConstraint()
i)

@DecimalMin constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testDecimalMinConstraint()
j)

@DecimalMax constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testDecimalMaxConstraint()
k)

@Size constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testSizeConstraint()
l)

@Digits constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testDigitsConstraint()
m)

@Past constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testPastConstraint()
n)

@Future constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testFutureConstraint()
o)

@Pattern constraint

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.builtinconstraints
BuiltinConstraintsTest.testPatternConstraint()

Section 7 - XML deployment descriptor

a)

If the xml configuration file does not validate against the given xsd files a ValidationException is raised.

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
InvalidXmlConfigurationTest.testInvalidValidationXml()

Section 7.1 - Constraint definition and declaration

a)

Specifically when exploring metadata, the Bean Validation provider must ensure that an annotation instance corresponding to the XML declaration is provided via ConstraintDescriptor.getAnnnotation()

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
DuplicateConfigurationTest.testXmlConfiguredConstraintExposesCorrespondingAnnotationViaMetadata()
b)

A given class must not be described more than once amongst all the XML mapping descriptors

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
DuplicateConfigurationTest.testBeanCannotBeDescribedMoreThanOnce()
c)

A given field or getter must not be described more than once on a given class description

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
DuplicateConfigurationTest.testFieldMappingCannotOccurMoreThanOnce()
d)

A given constraint definition must not be overridden more than once amongst all the XML mapping descriptors

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
DuplicateConfigurationTest.testGetterMappingCannotOccurMoreThanOnce()
e)

If any of these rule is violated in a given validation deployment, a ValidationException is raised during the creation of the ValidatorFactory

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
DuplicateConfigurationTest.testBeanCannotBeDescribedMoreThanOnce()
DuplicateConfigurationTest.testFieldMappingCannotOccurMoreThanOnce()
DuplicateConfigurationTest.testGetterMappingCannotOccurMoreThanOnce()

Section 7.1.1 - Constraint declaration in XML

a)

If default-package is set, all unqualified class names (including annotations) are considered part of the package described by default-package.

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration
ConfigurationViaXmlAndAnnotationsTest.testEntityConfiguredViaAnnotationsAndXml()
org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testClassConstraintDefinedInXml()
XmlConfigurationTest.testIgnoreValidationXml()
XmlConfigurationTest.testPropertyConstraintDefinedInXml()
XmlConfigurationTest.testFieldConstraintDefinedInXml()
XmlConfigurationTest.testAnnotationDefinedConstraintApplies()
XmlConfigurationTest.testCascadingConfiguredInXml()
b)

A given JavaBean is described by the bean element.

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testClassConstraintDefinedInXml()
XmlConfigurationTest.testIgnoreValidationXml()
XmlConfigurationTest.testPropertyConstraintDefinedInXml()
XmlConfigurationTest.testFieldConstraintDefinedInXml()
XmlConfigurationTest.testAnnotationDefinedConstraintApplies()
XmlConfigurationTest.testCascadingConfiguredInXml()
c)

The name of the class in the bean node is mandatory

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
MissingClassNameOnBeanNodeTest.testClassNameIsMandatory()
d)

By default, all constraint declarations expressed via annotation are ignored for classes described in XML

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration
ConstraintDeclarationTest.testConstraintAnnotationsArePerDefaultIgnoredForXmlConfiguredEntities()
e)

You can force Bean Validation to consider both annotations and XML constraint declarations by using ignore-annotation="false" on bean

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration
ConfigurationViaXmlAndAnnotationsTest.testEntityConfiguredViaAnnotationsAndXml()
f)

If the name of the class does refer to a class not present in in the classpath, a ValidationException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration
ConfiguredBeanNotInClassPathTest.testExceptionIsThrownForUnknownBeanNameInXml()

Section 7.1.1.1 - Class-level overriding

a)

If ignore-annotations is declared, Bean Validation must honor the explicit value for this element

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.clazzlevel
ClassLevelOverridingTest.testIgnoreClassLevelAnnotations()
ClassLevelOverridingTest.testClassLevelAnnotationsApplied()
b)

If not declared, the default value defined in the encapsulating bean element is considered

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.clazzlevel
ClassLevelOverridingTest.testIgnoreAnnotationsFromEnclosingBeanIsApplied()
c)

When ignore-annotations is true, class-level Bean Validation annotations are ignored for this class

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.clazzlevel
ClassLevelOverridingTest.testIgnoreClassLevelAnnotations()
d)

When ignore-annotations is false, constraints declared in XML and constraints declared in annotations are added and form the list of class-level declared constraints

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.clazzlevel
ClassLevelOverridingTest.testClassLevelAnnotationsApplied()
e)

@GroupSequence is considered unless group-sequence element is explicitly used

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration
ConfigurationViaXmlAndAnnotationsTest.testDefaultGroupDefinitionDefinedInEntityApplies()
DefaultSequenceDefinedInXmlTest.testDefaultGroupDefinitionDefinedInEntityApplies()

Section 7.1.1.2 - Field-level overriding

a)

If ignore-annotations is declared, Bean Validation must honor the explicit value for this element

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel
FieldLevelOverridingTest.testIgnoreAnnotations()
FieldLevelOverridingTest.testIncludeAnnotations()
b)

If not declared, the default value defined in the encapsulating bean element is considered

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel
ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.testIgnoreAnnotations()
IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.testAnnotationsIncluded()
c)

When ignore-annotations is true, field-level Bean Validation annotations on the targeted field are ignored

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel
ExcludeFieldLevelAnnotationsDueToBeanDefaultsTest.testIgnoreAnnotations()
FieldLevelOverridingTest.testIgnoreAnnotations()
d)

When ignore-annotations is false, constraints declared in XML and constraints declared in annotations are added and form the list of field-level declared constraints

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel
FieldLevelOverridingTest.testIncludeAnnotations()
IncludeFieldLevelAnnotationsDueToBeanDefaultsTest.testAnnotationsIncluded()
e)

The only way to disable cascading on a field marked as @Valid is to use ignore-annotations=true

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel
FieldLevelOverridingTest.testCascadedConfiguration()
f)

If the name of the field does not correspond to a field in the given bean a ValidationException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.fieldlevel
WrongFieldNameTest.testWrongFieldNameThrowsException()

Section 7.1.1.3 - Property-level overriding

a)

The name attribute correspond to the name of the property considered as defined in Section 3.1.2. If ignore-annotations is declared, Bean Validation must honor the explicit value for this element

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.propertylevel
PropertyLevelOverridingTest.testIgnoreAnnotations()
PropertyLevelOverridingTest.testIncludeAnnotations()
b)

If not declared, the default value defined in the encapsulating bean element is considered

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.propertylevel
ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.testIgnoreAnnotations()
IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.testAnnotationsIncluded()
c)

When ignore-annotations is true, property-level Bean Validation annotations on the targeted property are ignored (including the @Valid)

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.propertylevel
ExcludePropertyLevelAnnotationsDueToBeanDefaultsTest.testIgnoreAnnotations()
PropertyLevelOverridingTest.testIgnoreAnnotations()
d)

When ignore-annotations is false, constraints declared in XML and constraints declared in annotations are added and form the list of property-level declared constraints.

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.propertylevel
IncludePropertyLevelAnnotationsDueToBeanDefaultsTest.testAnnotationsIncluded()
PropertyLevelOverridingTest.testIncludeAnnotations()
e)

The only way to disable cascading on a property marked as @Valid is to use ignore-annotations=true

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.propertylevel
PropertyLevelOverridingTest.testCascadedConfiguration()
f)

If the name of the property does not correspond to a property in the given bean a ValidationException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration.propertylevel
WrongPropertyNameTest.testWrongPropertyNameThrowsException()

Section 7.1.1.4 - Constraint declaration

a)

The name attribute is mandatory and represents the name of the element in the constraint declaration

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration
MandatoryNameAttributeTest.testNameAttributeIsMandatory()
b)

"message" or "groups" are not permitted names, use the message or groups elements instead. Otherwise a ValidationException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration
ReservedElementNameTest.testGroupIsNotAllowedAsElementName()
ReservedElementNameTest.testMessageIsNotAllowedAsElementName()
c)

If the element represents a primitive type, a class or an enum, the string representation of its value is placed in the element itself

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testElementConversionInXmlConfiguredConstraint()
d)

If the element represents a primitive type array, a class array or an enum array, the string representation of each value is placed in a element placed under the element itself

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testElementConversionInXmlConfiguredConstraint()
e)

If the element represents an annotation, the annotation element is used to represent the annotation and placed under element

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testElementConversionInXmlConfiguredConstraint()
f)

If the element represents an array of annotations, one or more annotation elements are placed under element

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testElementConversionInXmlConfiguredConstraint()
g)

Elements with default values in the annotation definition do not have to be represented in XML: the default value will be used in this case

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testElementConversionInXmlConfiguredConstraint()
h)

If an XML constraint declaration is missing mandatory elements, or if it contains elements not part of the constraint definition, a ValidationException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdeclaration
MissingMandatoryElementTest.testMissingMandatoryElementInConstraintDeclaration()

Section 7.1.2 - Overriding constraint definitions in XML

a)

A constraint definition is represented by a constraint-definition element

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration
XmlConfigurationTest.testClassConstraintDefinedInXml()
XmlConfigurationTest.testIgnoreValidationXml()
XmlConfigurationTest.testPropertyConstraintDefinedInXml()
XmlConfigurationTest.testFieldConstraintDefinedInXml()
XmlConfigurationTest.testAnnotationDefinedConstraintApplies()
XmlConfigurationTest.testCascadingConfiguredInXml()
b)

If include-existing-validator is set to false, ConstraintValidator defined on the constraint annotation are ignored

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdefinition
XmlConfiguredConstraintValidatorTest.testExcludeExistingValidators()
c)

If set to true, the list of ConstraintValidators described in XML are concatenated to the list of ConstraintValidator described on the annotation to form a new array of ConstraintValidator evaluated

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdefinition
XmlConfiguredConstraintValidatorTest.testIncludeExistingValidators()
d)

Annotation based ConstraintValidator come before XML based ConstraintValidator in the array

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdefinition
XmlConfiguredConstraintValidatorTest.testIncludeExistingValidators()
e)

The validator list is returned by ConstraintDescriptor.getConstraintValidatorClasses()

Coverage

org.hibernate.beanvalidation.tck.tests.xmlconfiguration.constraintdefinition
XmlConfiguredConstraintValidatorTest.testExcludeExistingValidators()
XmlConfiguredConstraintValidatorTest.testIncludeExistingValidators()

Section 8 - Exception model

a)

Every (runtime) exception raised either at initialization time or execution time by any of the extension interfaces (ConstraintValidator, ConstraintValidatorFactory, MessageInterpolator, TraversableResolver, ValidationProviderResolver) is wrapped in a ValidationException

Coverage

org.hibernate.beanvalidation.tck.tests.bootstrap.customprovider
BootstrapUnknownCustomProviderTest.testWrongProviderConfiguredInValidationXml()

Section 8.2 - ConstraintDefinitionException

a)

If a constraint definition does not respect the Bean Validation rules or is inconsistent, a ConstraintDefinitionException is raised.

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.invalidconstraintdefinitions
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithParameterStartingWithValid()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithoutMessageParameter()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithoutGroupParameter()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithoutPayloadParameter()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongDefaultGroupValue()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongDefaultPayloadValue()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongPayloadClass()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongMessageType()
InvalidConstraintDefinitionsTest.testConstraintDefinitionWithWrongGroupType()

Section 8.3 - ConstraintDeclarationException and UnexpectedTypeException

a)

When a constraint declaration is illegal, ConstraintDeclarationException is raised

b)

When the return type of a property cannot be processed for a given constraint, an UnexpectedTypeException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.validatorresolution
ValidatorResolutionTest.testAmbiguousValidatorResolution()

Section 8.4 - GroupDefinitionException

a)

When a group definition is illegal, GroupDefinitionException is raised

Coverage

org.hibernate.beanvalidation.tck.tests.constraints.groups.groupsequence
SequenceResolutionTest.testInvalidDefinitionOfDefaultSequenceInEntity()
org.hibernate.beanvalidation.tck.tests.constraints.groups
GroupTest.testCyclicGroupSequence()