DATACMNS-1201 - Support generated property accessors for types in default packages.
We now support generated property accessors for types that reside in the default package. Original pull request: #256.
This commit is contained in:
committed by
Oliver Gierke
parent
4bd8a3cfc3
commit
a13fc238d3
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.Assume.*;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
@@ -36,6 +36,7 @@ import org.springframework.data.mapping.context.SampleMappingContext;
|
||||
import org.springframework.data.mapping.context.SamplePersistentProperty;
|
||||
import org.springframework.data.mapping.model.subpackage.TypeInOtherPackage;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ClassGeneratingPropertyAccessorFactory}
|
||||
@@ -61,7 +62,8 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
}
|
||||
|
||||
@Parameters(name = "{3}")
|
||||
public static List<Object[]> parameters() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<Object[]> parameters() throws ReflectiveOperationException {
|
||||
|
||||
List<Object[]> parameters = new ArrayList<>();
|
||||
List<String> propertyNames = Arrays.asList("privateField", "packageDefaultField", "protectedField", "publicField",
|
||||
@@ -79,6 +81,11 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
ClassGeneratingPropertyAccessorPublicType.class));
|
||||
parameters.addAll(parameters(new SubtypeOfTypeInOtherPackage(), propertyNames, SubtypeOfTypeInOtherPackage.class));
|
||||
|
||||
Class<Object> defaultPackageClass = (Class) Class.forName("TypeInDefaultPackage");
|
||||
|
||||
parameters
|
||||
.add(new Object[] { defaultPackageClass.newInstance(), "", defaultPackageClass, "Class in default package" });
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@@ -94,9 +101,16 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1201
|
||||
public void shouldSupportGeneratedPropertyAccessors() {
|
||||
assertThat(factory.isSupported(mappingContext.getRequiredPersistentEntity(bean.getClass()))).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-809
|
||||
public void shouldSetAndGetProperty() throws Exception {
|
||||
|
||||
assumeTrue(StringUtils.hasText(propertyName));
|
||||
|
||||
assertThat(getProperty(bean, propertyName)).satisfies(property -> {
|
||||
|
||||
PersistentPropertyAccessor persistentPropertyAccessor = getPersistentPropertyAccessor(bean);
|
||||
|
||||
Reference in New Issue
Block a user