@@ -0,0 +1,2916 @@
+package fi.vincit.jmobster.processor.defaults.validator.hibernate;%0A%0A/*%0A * Copyright 2012 Juha Siponen%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Aimport fi.vincit.jmobster.util.TestUtil;%0Aimport fi.vincit.jmobster.util.collection.AnnotationBag;%0Aimport org.hibernate.validator.constraints.Length;%0Aimport org.junit.Test;%0A%0Aimport java.lang.annotation.Annotation;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0A%0Apublic class HibernateValidatorTest %7B%0A    @Test%0A    public void testLengthValidator_MinAndMax() %7B%0A        class LengthClass %7B @Length(min=1,max=3) public String s; %7D%0A%0A        Annotation lengthAnnotation = TestUtil.getAnnotationFromClass(LengthClass.class, 0, 0);%0A        AnnotationBag annotationBag = TestUtil.generateAnnotationBag( lengthAnnotation );%0A%0A        LengthValidator lengthValidator = new LengthValidator();%0A        lengthValidator.init(annotationBag);%0A%0A        assertThat(lengthValidator.hasMin(), is(true));%0A        assertThat(lengthValidator.hasMax(), is(true));%0A        assertThat(lengthValidator.getMin(), is(1));%0A        assertThat(lengthValidator.getMax(), is(3));%0A    %7D%0A%0A    @Test%0A    public void testLengthValidator_Min() %7B%0A        class LengthClass %7B @Length(min=1) public String s; %7D%0A%0A        Annotation lengthAnnotation = TestUtil.getAnnotationFromClass(LengthClass.class, 0, 0);%0A        AnnotationBag annotationBag = TestUtil.generateAnnotationBag( lengthAnnotation );%0A%0A        LengthValidator lengthValidator = new LengthValidator();%0A        lengthValidator.init(annotationBag);%0A%0A        assertThat(lengthValidator.hasMin(), is(true));%0A        assertThat(lengthValidator.hasMax(), is(false));%0A        assertThat(lengthValidator.getMin(), is(1));%0A    %7D%0A%0A    @Test%0A    public void testLengthValidator_Max() %7B%0A        class LengthClass %7B @Length(max=3) public String s; %7D%0A%0A        Annotation lengthAnnotation = TestUtil.getAnnotationFromClass(LengthClass.class, 0, 0);%0A        AnnotationBag annotationBag = TestUtil.generateAnnotationBag( lengthAnnotation );%0A%0A        LengthValidator lengthValidator = new LengthValidator();%0A        lengthValidator.init(annotationBag);%0A%0A        assertThat(lengthValidator.hasMin(), is(true));%0A        assertThat(lengthValidator.hasMax(), is(true));%0A        assertThat(lengthValidator.getMin(), is(0)); // Hibernate default min is 0%0A        assertThat(lengthValidator.getMax(), is(3));%0A    %7D%0A%7D%0A

Add tests for Hibernate LengthValidator