From 03ae37f2cc422d5bdcd8548743f144a3418a4c4f Mon Sep 17 00:00:00 2001 From: Hardy Ferentschik Date: Wed, 10 Nov 2010 17:41:20 +0100 Subject: [PATCH] HV-361 Formatting and adding/updating copyrights --- .../cfg/beanvalidation/TypeSafeActivator.java | 2 +- .../annotations/beanvalidation/Address.java | 40 +++++++++++++---- .../BeanValidationAutoTest.java | 28 +++++++++++- .../BeanValidationDisabledTest.java | 40 +++++++++++++---- .../BeanValidationGroupsTest.java | 26 ++++++++++- .../BeanValidationProvidedFactoryTest.java | 30 +++++++++++-- .../annotations/beanvalidation/Button.java | 28 +++++++++++- .../annotations/beanvalidation/Color.java | 29 +++++++++++- .../annotations/beanvalidation/CupHolder.java | 26 ++++++++++- .../annotations/beanvalidation/DDLTest.java | 38 +++++++++++++--- .../DDLWithoutCallbackTest.java | 40 +++++++++++++---- .../annotations/beanvalidation/Display.java | 26 ++++++++++- .../beanvalidation/DisplayConnector.java | 27 ++++++++++- .../HibernateTraversableResolverTest.java | 26 ++++++++++- .../annotations/beanvalidation/Music.java | 24 ++++++++++ .../beanvalidation/PowerSupply.java | 38 +++++++++++++--- .../test/annotations/beanvalidation/Rock.java | 24 ++++++++++ .../annotations/beanvalidation/Screen.java | 45 ++++++++++++++----- .../annotations/beanvalidation/Strict.java | 24 ++++++++++ .../test/annotations/beanvalidation/Tv.java | 26 ++++++++++- .../annotations/beanvalidation/TvOwner.java | 28 +++++++++++- 21 files changed, 551 insertions(+), 64 deletions(-) diff --git a/core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java b/core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java index 00dc6f782b..753ab3ce81 100644 --- a/core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java +++ b/core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java @@ -139,7 +139,7 @@ class TypeSafeActivator { for ( PropertyDescriptor propertyDesc : descriptor.getConstrainedProperties() ) { Property property = findPropertyByName( persistentClass, prefix + propertyDesc.getPropertyName() ); - boolean hasNotNull = false; + boolean hasNotNull; if ( property != null ) { hasNotNull = applyConstraints( propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull ); if ( property.isComposite() && propertyDesc.isCascaded() ) { diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Address.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Address.java index d9102304f4..65c4b9e30b 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Address.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Address.java @@ -1,14 +1,38 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import javax.persistence.Entity; -import javax.persistence.Transient; import javax.persistence.Id; -import javax.validation.constraints.Size; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Min; -import javax.validation.constraints.Max; -import javax.validation.constraints.Pattern; +import javax.persistence.Transient; import javax.validation.constraints.AssertTrue; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; @Entity public class Address { @@ -24,7 +48,8 @@ public class Address { private String country; private long id; private boolean internalValid = true; - @Min(-2) @Max(value=50) + @Min(-2) + @Max(value = 50) public int floor; public String getCountry() { @@ -99,5 +124,4 @@ public class Address { public void setId(long id) { this.id = id; } - } diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationAutoTest.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationAutoTest.java index fc62178bdc..7eecb8a3ed 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationAutoTest.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationAutoTest.java @@ -1,3 +1,27 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import java.math.BigDecimal; @@ -14,12 +38,12 @@ public class BeanValidationAutoTest extends TestCase { public void testListeners() { CupHolder ch = new CupHolder(); ch.setRadius( new BigDecimal( "12" ) ); - Session s = openSession( ); + Session s = openSession(); Transaction tx = s.beginTransaction(); try { s.persist( ch ); s.flush(); - fail("invalid object should not be persisted"); + fail( "invalid object should not be persisted" ); } catch ( ConstraintViolationException e ) { assertEquals( 1, e.getConstraintViolations().size() ); diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationDisabledTest.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationDisabledTest.java index 5dad514744..ad21ecb4d9 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationDisabledTest.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationDisabledTest.java @@ -1,13 +1,37 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import java.math.BigDecimal; import javax.validation.ConstraintViolationException; -import org.hibernate.mapping.PersistentClass; import org.hibernate.Session; import org.hibernate.Transaction; -import org.hibernate.mapping.Column; import org.hibernate.cfg.Configuration; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.PersistentClass; import org.hibernate.test.annotations.TestCase; /** @@ -17,23 +41,23 @@ public class BeanValidationDisabledTest extends TestCase { public void testListeners() { CupHolder ch = new CupHolder(); ch.setRadius( new BigDecimal( "12" ) ); - Session s = openSession( ); + Session s = openSession(); Transaction tx = s.beginTransaction(); try { s.persist( ch ); s.flush(); } catch ( ConstraintViolationException e ) { - fail("invalid object should not be validated"); + fail( "invalid object should not be validated" ); } tx.rollback(); s.close(); } - + public void testDDLDisabled() { - PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() ); - Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next(); - assertTrue("DDL constraints are applied", countryColumn.isNullable() ); + PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() ); + Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next(); + assertTrue( "DDL constraints are applied", countryColumn.isNullable() ); } @Override diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java index 4ab00365b6..505faff7c4 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationGroupsTest.java @@ -1,3 +1,27 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import java.lang.annotation.Annotation; @@ -42,7 +66,7 @@ public class BeanValidationGroupsTest extends TestCase { catch ( ConstraintViolationException e ) { assertEquals( 1, e.getConstraintViolations().size() ); // TODO - seems this explicit case is necessary with JDK 5 (at least on Mac). With Java 6 there is no problem - Annotation annotation = ( Annotation ) e.getConstraintViolations() + Annotation annotation = (Annotation) e.getConstraintViolations() .iterator() .next() .getConstraintDescriptor() diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationProvidedFactoryTest.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationProvidedFactoryTest.java index ef95bc6a3e..d22f38fca5 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationProvidedFactoryTest.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationProvidedFactoryTest.java @@ -1,3 +1,27 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import java.math.BigDecimal; @@ -19,12 +43,12 @@ public class BeanValidationProvidedFactoryTest extends TestCase { public void testListeners() { CupHolder ch = new CupHolder(); ch.setRadius( new BigDecimal( "12" ) ); - Session s = openSession( ); + Session s = openSession(); Transaction tx = s.beginTransaction(); try { s.persist( ch ); s.flush(); - fail("invalid object should not be persisted"); + fail( "invalid object should not be persisted" ); } catch ( ConstraintViolationException e ) { assertEquals( 1, e.getConstraintViolations().size() ); @@ -56,6 +80,6 @@ public class BeanValidationProvidedFactoryTest extends TestCase { final javax.validation.Configuration configuration = Validation.byDefaultProvider().configure(); configuration.messageInterpolator( messageInterpolator ); ValidatorFactory vf = configuration.buildValidatorFactory(); - cfg.getProperties().put( "javax.persistence.validation.factory", vf); + cfg.getProperties().put( "javax.persistence.validation.factory", vf ); } } \ No newline at end of file diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Button.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Button.java index 34546f39c3..1da209b333 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Button.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Button.java @@ -1,8 +1,32 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import javax.persistence.Embeddable; -import javax.validation.constraints.NotNull; import javax.validation.constraints.Max; +import javax.validation.constraints.NotNull; /** * @author Emmanuel Bernard @@ -23,7 +47,7 @@ public class Button { this.name = name; } - @Max( 10 ) + @Max(10) public Integer getSize() { return size; } diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Color.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Color.java index b2236ca2cd..36adaa1497 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Color.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Color.java @@ -1,8 +1,32 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import javax.persistence.Entity; -import javax.persistence.Id; import javax.persistence.GeneratedValue; +import javax.persistence.Id; import javax.validation.constraints.NotNull; /** @@ -13,7 +37,8 @@ public class Color { private Integer id; private String name; - @Id @GeneratedValue + @Id + @GeneratedValue public Integer getId() { return id; } diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/CupHolder.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/CupHolder.java index 0cce754fd2..ec782c35c3 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/CupHolder.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/CupHolder.java @@ -1,3 +1,27 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import java.math.BigDecimal; @@ -25,7 +49,7 @@ public class CupHolder { this.id = id; } - @Max( value = 10, message = "Radius way out") + @Max(value = 10, message = "Radius way out") @NotNull(groups = Strict.class) public BigDecimal getRadius() { return radius; diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLTest.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLTest.java index 194126b7db..2e2084126e 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLTest.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLTest.java @@ -1,7 +1,31 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; -import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Column; +import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; import org.hibernate.test.annotations.TestCase; @@ -37,7 +61,7 @@ public class DDLTest extends TestCase { PersistentClass classMapping = getCfg().getClassMapping( Tv.class.getName() ); Column modelColumn = (Column) classMapping.getProperty( "model" ).getColumnIterator().next(); assertEquals( modelColumn.getLength(), 5 ); - } + } public void testApplyOnManyToOne() throws Exception { PersistentClass classMapping = getCfg().getClassMapping( TvOwner.class.getName() ); @@ -48,18 +72,22 @@ public class DDLTest extends TestCase { public void testSingleTableAvoidNotNull() throws Exception { PersistentClass classMapping = getCfg().getClassMapping( Rock.class.getName() ); Column serialColumn = (Column) classMapping.getProperty( "bit" ).getColumnIterator().next(); - assertTrue( "Notnull should not be applised on single tables", serialColumn.isNullable() ); + assertTrue( "Notnull should not be applied on single tables", serialColumn.isNullable() ); } public void testNotNullOnlyAppliedIfEmbeddedIsNotNullItself() throws Exception { PersistentClass classMapping = getCfg().getClassMapping( Tv.class.getName() ); Property property = classMapping.getProperty( "tuner.frequency" ); Column serialColumn = (Column) property.getColumnIterator().next(); - assertEquals( "Validator annotations are applied on tunner as it is @NotNull", false, serialColumn.isNullable() ); + assertEquals( + "Validator annotations are applied on tuner as it is @NotNull", false, serialColumn.isNullable() + ); property = classMapping.getProperty( "recorder.time" ); serialColumn = (Column) property.getColumnIterator().next(); - assertEquals( "Validator annotations are applied on tunner as it is @NotNull", true, serialColumn.isNullable() ); + assertEquals( + "Validator annotations are applied on tuner as it is @NotNull", true, serialColumn.isNullable() + ); } protected Class[] getAnnotatedClasses() { diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java index 36c3e4d320..f771fc8c27 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java @@ -1,13 +1,37 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import java.math.BigDecimal; import javax.validation.ConstraintViolationException; -import org.hibernate.mapping.PersistentClass; import org.hibernate.Session; import org.hibernate.Transaction; -import org.hibernate.mapping.Column; import org.hibernate.cfg.Configuration; +import org.hibernate.mapping.Column; +import org.hibernate.mapping.PersistentClass; import org.hibernate.test.annotations.TestCase; /** @@ -17,7 +41,7 @@ public class DDLWithoutCallbackTest extends TestCase { public void testListeners() { CupHolder ch = new CupHolder(); ch.setRadius( new BigDecimal( "12" ) ); - Session s = openSession( ); + Session s = openSession(); Transaction tx = s.beginTransaction(); try { s.persist( ch ); @@ -27,7 +51,7 @@ public class DDLWithoutCallbackTest extends TestCase { } } catch ( ConstraintViolationException e ) { - fail("invalid object should not be validated"); + fail( "invalid object should not be validated" ); } catch ( org.hibernate.exception.ConstraintViolationException e ) { if ( getDialect().supportsColumnCheck() ) { @@ -40,11 +64,11 @@ public class DDLWithoutCallbackTest extends TestCase { tx.rollback(); s.close(); } - + public void testDDLEnabled() { - PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() ); - Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next(); - assertFalse("DDL constraints are not applied", countryColumn.isNullable() ); + PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() ); + Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next(); + assertFalse( "DDL constraints are not applied", countryColumn.isNullable() ); } @Override diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Display.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Display.java index 823610edea..6635b82024 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Display.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Display.java @@ -1,8 +1,32 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import javax.persistence.Entity; -import javax.persistence.Id; import javax.persistence.GeneratedValue; +import javax.persistence.Id; import javax.validation.constraints.NotNull; /** diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DisplayConnector.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DisplayConnector.java index 5fb02f7d05..5e4274b513 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DisplayConnector.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/DisplayConnector.java @@ -1,8 +1,31 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; -import javax.persistence.Embeddable; -import javax.persistence.OneToOne; import javax.persistence.CascadeType; +import javax.persistence.Embeddable; import javax.persistence.ManyToOne; import javax.validation.Valid; import javax.validation.constraints.Min; diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/HibernateTraversableResolverTest.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/HibernateTraversableResolverTest.java index f044129f95..0b871f845a 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/HibernateTraversableResolverTest.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/HibernateTraversableResolverTest.java @@ -1,3 +1,27 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import java.math.BigDecimal; @@ -46,7 +70,7 @@ public class HibernateTraversableResolverTest extends TestCase { try { s.persist( screen ); s.flush(); - fail( "@NotNull on empedded property is not evaluated" ); + fail( "@NotNull on embedded property is not evaluated" ); } catch ( ConstraintViolationException e ) { assertEquals( 1, e.getConstraintViolations().size() ); diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Music.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Music.java index 4bc84d94d8..6e6c7d6184 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Music.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Music.java @@ -1,3 +1,27 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import javax.persistence.Entity; diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/PowerSupply.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/PowerSupply.java index 589ebeee33..eee8e4ceb9 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/PowerSupply.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/PowerSupply.java @@ -1,10 +1,34 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import java.math.BigDecimal; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.GeneratedValue; import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; import javax.validation.constraints.Max; import javax.validation.constraints.Min; @@ -17,7 +41,8 @@ public class PowerSupply { private BigDecimal power; private String position; - @Id @GeneratedValue + @Id + @GeneratedValue public Integer getId() { return id; } @@ -26,7 +51,8 @@ public class PowerSupply { this.id = id; } - @Min(100) @Max(250) + @Min(100) + @Max(250) public BigDecimal getPower() { return power; } @@ -35,7 +61,7 @@ public class PowerSupply { this.power = power; } - @Column(name="fld_pos") + @Column(name = "fld_pos") public String getPosition() { return position; } diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Rock.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Rock.java index c7186f8a6e..e29f82bc7a 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Rock.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Rock.java @@ -1,3 +1,27 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import javax.persistence.Entity; diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Screen.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Screen.java index 4347b9e263..f217575548 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Screen.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Screen.java @@ -1,16 +1,40 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; -import java.util.Set; import java.util.HashSet; -import javax.persistence.Entity; -import javax.persistence.ManyToOne; -import javax.persistence.ManyToMany; -import javax.persistence.Id; -import javax.persistence.GeneratedValue; +import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.ElementCollection; -import javax.validation.constraints.NotNull; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; import javax.validation.Valid; +import javax.validation.constraints.NotNull; /** * @author Emmanuel Bernard @@ -23,7 +47,8 @@ public class Screen { private Set connectors = new HashSet(); private Set displayColors = new HashSet(); - @Id @GeneratedValue + @Id + @GeneratedValue public Integer getId() { return id; } @@ -32,7 +57,6 @@ public class Screen { this.id = id; } - //@NotNull @Valid public Button getStopButton() { return stopButton; @@ -42,7 +66,8 @@ public class Screen { this.stopButton = stopButton; } - @ManyToOne(cascade = CascadeType.PERSIST) @Valid + @ManyToOne(cascade = CascadeType.PERSIST) + @Valid @NotNull public PowerSupply getPowerSupply() { return powerSupply; diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Strict.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Strict.java index 2704c4d277..843ae72012 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Strict.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Strict.java @@ -1,3 +1,27 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; /** diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Tv.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Tv.java index 73c4502010..9091eef1b6 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Tv.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/Tv.java @@ -1,3 +1,27 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import java.math.BigDecimal; @@ -25,7 +49,7 @@ public class Tv { @Size(max = 2) public String serial; - @Length(max=5) + @Length(max = 5) public String model; public int size; diff --git a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/TvOwner.java b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/TvOwner.java index c221193bf7..397627aebe 100644 --- a/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/TvOwner.java +++ b/testsuite/src/test/java/org/hibernate/test/annotations/beanvalidation/TvOwner.java @@ -1,8 +1,32 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by + * third-party contributors as indicated by either @author tags or express + * copyright attribution statements applied by the authors. All + * third-party contributions are distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ + package org.hibernate.test.annotations.beanvalidation; import javax.persistence.Entity; -import javax.persistence.Id; import javax.persistence.GeneratedValue; +import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; @@ -14,7 +38,7 @@ public class TvOwner { @Id @GeneratedValue public Integer id; - + @ManyToOne @NotNull public Tv tv;