File tree Expand file tree Collapse file tree 4 files changed +22
-5
lines changed
main/java/com/github/nylle/javafixture/specimen
test/java/com/github/nylle/javafixture Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 77 <groupId >com.github.nylle</groupId >
88 <artifactId >javafixture</artifactId >
99 <packaging >jar</packaging >
10- <version >2.8.0 </version >
10+ <version >2.8.1 </version >
1111
1212 <name >JavaFixture</name >
1313 <url >https://github.com/Nylle/JavaFixture</url >
4242 <artifactId >jakarta.validation-api</artifactId >
4343 <version >2.0.2</version >
4444 </dependency >
45+ <dependency >
46+ <groupId >jakarta.persistence</groupId >
47+ <artifactId >jakarta.persistence-api</artifactId >
48+ <version >3.0.0</version >
49+ </dependency >
4550 <dependency >
4651 <groupId >org.junit.jupiter</groupId >
4752 <artifactId >junit-jupiter-engine</artifactId >
Original file line number Diff line number Diff line change 99import com .github .nylle .javafixture .SpecimenType ;
1010import com .github .nylle .javafixture .specimen .constraints .StringConstraints ;
1111
12+ import jakarta .persistence .Column ;
13+
1214import java .lang .annotation .Annotation ;
1315import javax .validation .constraints .Size ;
1416
@@ -93,6 +95,8 @@ private StringConstraints getStringConstraints(Annotation[] annotations) {
9395 for (var annotation : annotations ) {
9496 if (Size .class .isAssignableFrom (annotation .annotationType ())) {
9597 constraints = new StringConstraints (((Size )annotation ).min (), ((Size )annotation ).max ());
98+ } else if (Column .class .isAssignableFrom (annotation .annotationType ())) {
99+ constraints = new StringConstraints (0 , ((Column ) annotation ).length ());
96100 }
97101 }
98102 return constraints ;
Original file line number Diff line number Diff line change 88
99import static org .assertj .core .api .Assertions .assertThat ;
1010
11- public class FixtureWithValidationTest {
11+ class FixtureWithValidationTest {
1212
1313 @ Test
1414 void javaxSizeAnnotationIsSupported () {
@@ -17,17 +17,16 @@ void javaxSizeAnnotationIsSupported() {
1717 assertThat (sut .getWithMinAnnotation ().length ()).isGreaterThanOrEqualTo (5 );
1818 assertThat (sut .getWithMaxAnnotation ().length ()).isLessThanOrEqualTo (100 );
1919 assertThat (sut .getWithMinMaxAnnotation ().length ()).isBetween (3 , 6 );
20+ assertThat (sut .getWithColumnLengthAnnotation ().length ()).isBetween (0 , 5 );
2021 }
2122
2223 @ TestWithFixture
2324 void fixtureWillAlwaysCreateValidObject (TestObjectWithJavaxValidationAnnotations sut ) {
2425 var factory = Validation .buildDefaultValidatorFactory ();
2526 var validator = factory .getValidator ();
2627 var violations = validator .validate (sut );
27- assertThat ( violations ).isEmpty ();
28-
29-
3028
29+ assertThat (violations ).isEmpty ();
3130 }
3231
3332}
Original file line number Diff line number Diff line change 11package com .github .nylle .javafixture .testobjects ;
22
3+ import jakarta .persistence .Column ;
4+
35import javax .validation .constraints .Size ;
46
57public class TestObjectWithJavaxValidationAnnotations {
@@ -12,6 +14,9 @@ public class TestObjectWithJavaxValidationAnnotations {
1214 @ Size (max = 100 )
1315 private String withMaxAnnotation ;
1416
17+ @ Column (length = 5 )
18+ private String withColumnLengthAnnotation ;
19+
1520 public String getWithMinMaxAnnotation () {
1621 return withMinMaxAnnotation ;
1722 }
@@ -23,4 +28,8 @@ public String getWithMinAnnotation() {
2328 public String getWithMaxAnnotation () {
2429 return withMaxAnnotation ;
2530 }
31+
32+ public String getWithColumnLengthAnnotation () {
33+ return withColumnLengthAnnotation ;
34+ }
2635}
You can’t perform that action at this time.
0 commit comments