HV-361 Adding test for @Range constraint
This commit is contained in:
parent
0cb3e66eef
commit
ff47006731
hibernate-core/src/test/java/org/hibernate/test/annotations/beanvalidation
|
@ -50,13 +50,13 @@ public class DDLWithoutCallbackTest extends TestCase {
|
||||||
|
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsColumnCheck.class)
|
@RequiresDialectFeature(DialectChecks.SupportsColumnCheck.class)
|
||||||
public void testMinAndMaxChecksGetApplied() {
|
public void testMinAndMaxChecksGetApplied() {
|
||||||
MinMax minMax = new MinMax(1);
|
MinMax minMax = new MinMax( 1 );
|
||||||
assertDatabaseConstraintViolationThrown( minMax );
|
assertDatabaseConstraintViolationThrown( minMax );
|
||||||
|
|
||||||
minMax = new MinMax(11);
|
minMax = new MinMax( 11 );
|
||||||
assertDatabaseConstraintViolationThrown( minMax );
|
assertDatabaseConstraintViolationThrown( minMax );
|
||||||
|
|
||||||
minMax = new MinMax(5);
|
minMax = new MinMax( 5 );
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction tx = s.beginTransaction();
|
Transaction tx = s.beginTransaction();
|
||||||
s.persist( minMax );
|
s.persist( minMax );
|
||||||
|
@ -65,6 +65,23 @@ public class DDLWithoutCallbackTest extends TestCase {
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresDialectFeature(DialectChecks.SupportsColumnCheck.class)
|
||||||
|
public void testRangeChecksGetApplied() {
|
||||||
|
Range range = new Range( 1 );
|
||||||
|
assertDatabaseConstraintViolationThrown( range );
|
||||||
|
|
||||||
|
range = new Range( 11 );
|
||||||
|
assertDatabaseConstraintViolationThrown( range );
|
||||||
|
|
||||||
|
range = new Range( 5 );
|
||||||
|
Session s = openSession();
|
||||||
|
Transaction tx = s.beginTransaction();
|
||||||
|
s.persist( range );
|
||||||
|
s.flush();
|
||||||
|
tx.rollback();
|
||||||
|
s.close();
|
||||||
|
}
|
||||||
|
|
||||||
public void testDDLEnabled() {
|
public void testDDLEnabled() {
|
||||||
PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
|
PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
|
||||||
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
|
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
|
||||||
|
@ -81,7 +98,8 @@ public class DDLWithoutCallbackTest extends TestCase {
|
||||||
return new Class<?>[] {
|
return new Class<?>[] {
|
||||||
Address.class,
|
Address.class,
|
||||||
CupHolder.class,
|
CupHolder.class,
|
||||||
MinMax.class
|
MinMax.class,
|
||||||
|
Range.class
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue