@@ -36,24 +36,24 @@ class ValidateCustomization {
3636 @ DisplayName ("with existing fields, nothing happens" )
3737 void validCustomization () {
3838
39- var sut = new Reflector <>(new GenericChild <String >());
39+ var sut = new Reflector <>(new GenericChild <String >(), new SpecimenType <>(){} );
4040
4141 var validCustomisation = new CustomizationContext (List .of (), Map .of ("baseField.subField" , "foo" ), false );
4242
43- assertThatCode (() -> sut .validateCustomization (validCustomisation , new SpecimenType <>() {} ))
43+ assertThatCode (() -> sut .validateCustomization (validCustomisation ))
4444 .doesNotThrowAnyException ();
4545 }
4646
4747 @ Test
4848 @ DisplayName ("with any missing fields, an exception is thrown" )
4949 void invalidCustomization () {
5050
51- var sut = new Reflector <>(new GenericChild <String >());
51+ var sut = new Reflector <>(new GenericChild <String >(), new SpecimenType <>() {} );
5252
5353 var invalidCustomisation = new CustomizationContext (List .of (), Map .of ("nonExistingField.subField" , "foo" ), false );
5454
5555 assertThatExceptionOfType (SpecimenException .class )
56- .isThrownBy (() -> sut .validateCustomization (invalidCustomisation , new SpecimenType <>() {} ))
56+ .isThrownBy (() -> sut .validateCustomization (invalidCustomisation ))
5757 .withMessage ("Cannot customize field 'nonExistingField': Field not found in class 'com.github.nylle.javafixture.testobjects.inheritance.GenericChild<java.lang.String>'." )
5858 .withNoCause ();
5959 }
@@ -62,14 +62,14 @@ void invalidCustomization() {
6262 @ DisplayName ("to set duplicate fields, an exception is thrown" )
6363 void customizingDuplicateFields () {
6464
65- var sut = new Reflector <>(new GenericChild <String >());
65+ var sut = new Reflector <>(new GenericChild <String >(), new SpecimenType <>(){} );
6666
6767 Map <String , Object > customization = Map .of ("fieldIn2Classes.subField" , 100.0 );
6868
6969 var invalidCustomisation = new CustomizationContext (List .of (), customization , false );
7070
7171 assertThatExceptionOfType (SpecimenException .class )
72- .isThrownBy (() -> sut .validateCustomization (invalidCustomisation , new SpecimenType <>() {} ))
72+ .isThrownBy (() -> sut .validateCustomization (invalidCustomisation ))
7373 .withMessageContaining ("Cannot customize field 'fieldIn2Classes'. Duplicate field names found:" )
7474 .withMessageContaining ("private java.lang.Double com.github.nylle.javafixture.testobjects.inheritance.GenericParent.fieldIn2Classes" )
7575 .withMessageContaining ("private java.lang.Integer com.github.nylle.javafixture.testobjects.inheritance.GenericBase.fieldIn2Classes" )
@@ -80,14 +80,14 @@ void customizingDuplicateFields() {
8080 @ DisplayName ("to omit duplicate fields, an exception is thrown" )
8181 void omittingDuplicateFields () {
8282
83- var sut = new Reflector <>(new GenericChild <String >());
83+ var sut = new Reflector <>(new GenericChild <String >(), new SpecimenType <>(){} );
8484
8585 var omitting = List .of ("fieldIn2Classes.subField" );
8686
8787 var invalidCustomisation = new CustomizationContext (omitting , Map .of (), false );
8888
8989 assertThatExceptionOfType (SpecimenException .class )
90- .isThrownBy (() -> sut .validateCustomization (invalidCustomisation , new SpecimenType <>() {} ))
90+ .isThrownBy (() -> sut .validateCustomization (invalidCustomisation ))
9191 .withMessageContaining ("Cannot customize field 'fieldIn2Classes'. Duplicate field names found:" )
9292 .withMessageContaining ("private java.lang.Double com.github.nylle.javafixture.testobjects.inheritance.GenericParent.fieldIn2Classes" )
9393 .withMessageContaining ("private java.lang.Integer com.github.nylle.javafixture.testobjects.inheritance.GenericBase.fieldIn2Classes" )
@@ -103,7 +103,7 @@ class SetField {
103103 @ Test
104104 void catchIllegalAccessException () throws Exception {
105105 var mockedField = Mockito .mock (Field .class );
106- var sut = new Reflector <>("" );
106+ var sut = new Reflector <>("" , new SpecimenType <>(){} );
107107 doThrow (new IllegalAccessException ("expected" )).when (mockedField ).set (any (), any ());
108108
109109 assertThatExceptionOfType (SpecimenException .class )
@@ -114,7 +114,7 @@ void catchIllegalAccessException() throws Exception {
114114 @ Test
115115 void catchSecurityException () {
116116 var mockedField = Mockito .mock (Field .class );
117- var sut = new Reflector <>("" );
117+ var sut = new Reflector <>("" , new SpecimenType <>(){} );
118118 doThrow (new SecurityException ("expected" )).when (mockedField ).setAccessible (true );
119119 assertThatExceptionOfType (SpecimenException .class )
120120 .isThrownBy (() -> sut .setField (mockedField , "" ));
@@ -124,7 +124,7 @@ void catchSecurityException() {
124124 @ Test
125125 void catchInaccessibleObjectException () {
126126 var mockedField = Mockito .mock (Field .class );
127- var sut = new Reflector <>("" );
127+ var sut = new Reflector <>("" , new SpecimenType <>(){} );
128128 doThrow (new InaccessibleObjectException ("expected" )).when (mockedField ).setAccessible (true );
129129 assertThatExceptionOfType (SpecimenException .class )
130130 .isThrownBy (() -> sut .setField (mockedField , "" ));
@@ -136,7 +136,7 @@ class GetFieldAnnotations {
136136
137137 @ Test
138138 void returnsSizeAnnotationOnPrivateField () {
139- var sut = new Reflector <>(new TestObjectWithJakartaValidationAnnotations ());
139+ var sut = new Reflector <>(new TestObjectWithJakartaValidationAnnotations (), new SpecimenType <>(){} );
140140
141141 var field = sut .getDeclaredFields ().filter (x -> x .getName ().equals ("withMinMaxAnnotation" )).findFirst ().get ();
142142
@@ -148,7 +148,7 @@ void returnsSizeAnnotationOnPrivateField() {
148148
149149 @ Test
150150 void returnsSizeAnnotationOnGetter () {
151- var sut = new Reflector <>(new TestObjectWithJakartaValidationAnnotationsOnMethod ());
151+ var sut = new Reflector <>(new TestObjectWithJakartaValidationAnnotationsOnMethod (), new SpecimenType <>(){} );
152152
153153 var field = sut .getDeclaredFields ().filter (x -> x .getName ().equals ("withMinMaxAnnotation" )).findFirst ().get ();
154154
@@ -160,7 +160,7 @@ void returnsSizeAnnotationOnGetter() {
160160
161161 @ Test
162162 void returnsSizeAnnotationOnFieldIfGetterThrowsIntrospectionException () {
163- var sut = new Reflector <>(new TestObjectWithJakartaValidationAnnotations ());
163+ var sut = new Reflector <>(new TestObjectWithJakartaValidationAnnotations (), new SpecimenType <>(){} );
164164 var expected = sut .getDeclaredFields ().filter (x -> x .getName ().equals ("withMinMaxAnnotation" )).findFirst ().get ().getAnnotations ();
165165
166166 var throwingField = mock (Field .class );
0 commit comments