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 .hamcrest .CoreMatchers .instanceOf ;
20
19
import static org .hamcrest .CoreMatchers .is ;
21
20
import static org .hamcrest .Matchers .equalTo ;
22
21
import static org .junit .Assert .*;
22
+ import static org .junit .Assume .assumeTrue ;
23
23
24
24
import java .lang .reflect .Constructor ;
25
25
import java .util .ArrayList ;
38
38
import org .springframework .data .mapping .context .SamplePersistentProperty ;
39
39
import org .springframework .data .mapping .model .subpackage .TypeInOtherPackage ;
40
40
import org .springframework .test .util .ReflectionTestUtils ;
41
+ import org .springframework .util .StringUtils ;
41
42
42
43
/**
43
44
* Unit tests for {@link ClassGeneratingPropertyAccessorFactory}
@@ -63,7 +64,8 @@ public ClassGeneratingPropertyAccessorFactoryTests(Object bean, String propertyN
63
64
}
64
65
65
66
@ Parameters (name = "{3}" )
66
- public static List <Object []> parameters () {
67
+ @ SuppressWarnings ("unchecked" )
68
+ public static List <Object []> parameters () throws ReflectiveOperationException {
67
69
68
70
List <Object []> parameters = new ArrayList <Object []>();
69
71
List <String > propertyNames = Arrays .asList ("privateField" , "packageDefaultField" , "protectedField" , "publicField" ,
@@ -80,6 +82,11 @@ public static List<Object[]> parameters() {
80
82
ClassGeneratingPropertyAccessorPublicType .class ));
81
83
parameters .addAll (parameters (new SubtypeOfTypeInOtherPackage (), propertyNames , SubtypeOfTypeInOtherPackage .class ));
82
84
85
+ Class <Object > defaultPackageClass = (Class ) Class .forName ("TypeInDefaultPackage" );
86
+
87
+ parameters
88
+ .add (new Object [] { defaultPackageClass .newInstance (), "" , defaultPackageClass , "Class in default package" });
89
+
83
90
return parameters ;
84
91
}
85
92
@@ -95,9 +102,16 @@ private static List<Object[]> parameters(Object bean, List<String> propertyNames
95
102
return parameters ;
96
103
}
97
104
105
+ @ Test // DATACMNS-1201
106
+ public void shouldSupportGeneratedPropertyAccessors () {
107
+ assertThat (factory .isSupported (mappingContext .getPersistentEntity (bean .getClass ())), is (true ));
108
+ }
109
+
98
110
@ Test // DATACMNS-809
99
111
public void shouldSetAndGetProperty () throws Exception {
100
112
113
+ assumeTrue (StringUtils .hasText (propertyName ));
114
+
101
115
PersistentProperty <?> property = getProperty (bean , propertyName );
102
116
PersistentPropertyAccessor persistentPropertyAccessor = getPersistentPropertyAccessor (bean );
103
117
0 commit comments