13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
-
17
16
package org .springframework .data .mapping .model ;
18
17
19
18
import static org .assertj .core .api .Assertions .*;
19
+ import static org .junit .Assume .*;
20
20
21
21
import java .lang .reflect .Constructor ;
22
22
import java .util .ArrayList ;
36
36
import org .springframework .data .mapping .context .SamplePersistentProperty ;
37
37
import org .springframework .data .mapping .model .subpackage .TypeInOtherPackage ;
38
38
import org .springframework .test .util .ReflectionTestUtils ;
39
+ import org .springframework .util .StringUtils ;
39
40
40
41
/**
41
42
* Unit tests for {@link ClassGeneratingPropertyAccessorFactory}
@@ -61,7 +62,8 @@ public ClassGeneratingPropertyAccessorFactoryTests(Object bean, String propertyN
61
62
}
62
63
63
64
@ Parameters (name = "{3}" )
64
- public static List <Object []> parameters () {
65
+ @ SuppressWarnings ("unchecked" )
66
+ public static List <Object []> parameters () throws ReflectiveOperationException {
65
67
66
68
List <Object []> parameters = new ArrayList <>();
67
69
List <String > propertyNames = Arrays .asList ("privateField" , "packageDefaultField" , "protectedField" , "publicField" ,
@@ -79,6 +81,11 @@ public static List<Object[]> parameters() {
79
81
ClassGeneratingPropertyAccessorPublicType .class ));
80
82
parameters .addAll (parameters (new SubtypeOfTypeInOtherPackage (), propertyNames , SubtypeOfTypeInOtherPackage .class ));
81
83
84
+ Class <Object > defaultPackageClass = (Class ) Class .forName ("TypeInDefaultPackage" );
85
+
86
+ parameters
87
+ .add (new Object [] { defaultPackageClass .newInstance (), "" , defaultPackageClass , "Class in default package" });
88
+
82
89
return parameters ;
83
90
}
84
91
@@ -94,9 +101,16 @@ private static List<Object[]> parameters(Object bean, List<String> propertyNames
94
101
return parameters ;
95
102
}
96
103
104
+ @ Test // DATACMNS-1201
105
+ public void shouldSupportGeneratedPropertyAccessors () {
106
+ assertThat (factory .isSupported (mappingContext .getRequiredPersistentEntity (bean .getClass ()))).isTrue ();
107
+ }
108
+
97
109
@ Test // DATACMNS-809
98
110
public void shouldSetAndGetProperty () throws Exception {
99
111
112
+ assumeTrue (StringUtils .hasText (propertyName ));
113
+
100
114
assertThat (getProperty (bean , propertyName )).satisfies (property -> {
101
115
102
116
PersistentPropertyAccessor persistentPropertyAccessor = getPersistentPropertyAccessor (bean );
0 commit comments