Skip to content

Commit a5a6ef8

Browse files
committed
use the Impl class
don't access fields directly
1 parent 033da3c commit a5a6ef8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

core/src/test/java/dev/morphia/test/lifecycle/TestLifecycles.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.mongodb.lang.Nullable;
1515

1616
import dev.morphia.Datastore;
17+
import dev.morphia.DatastoreImpl;
1718
import dev.morphia.EntityInterceptor;
1819
import dev.morphia.annotations.Entity;
1920
import dev.morphia.annotations.Id;
@@ -273,8 +274,9 @@ public boolean hasAnnotation(Class<? extends Annotation> type) {
273274

274275
@Override
275276
public void prePersist(@NotNull Object ent, @NotNull Document document, @NotNull Datastore datastore) {
276-
final List<PropertyModel> fieldsToTest = datastore.getMapper().getEntityModel(ent.getClass())
277-
.getProperties(NonNull.class);
277+
DatastoreImpl ds = (DatastoreImpl) datastore;
278+
final List<PropertyModel> fieldsToTest = ds.getMapper().getEntityModel(ent.getClass())
279+
.getProperties(NonNull.class);
278280
for (PropertyModel mf : fieldsToTest) {
279281
if (mf.getValue(ent) == null) {
280282
throw new NonNullValidationException(mf);

core/src/test/java/dev/morphia/test/mapping/TestMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private static void assertModelNotSame(EntityModel originalEntity, EntityModel c
3939
} else {
4040
assertNotSame(originalEntity.superClass, clonedEntity.superClass);
4141
}
42-
originalEntity.subtypes.forEach(subtype -> {
42+
originalEntity.getSubtypes().forEach(subtype -> {
4343
assertNotSame(subtype, findSubtype(clonedEntity, subtype));
4444
});
4545
originalEntity.getProperties().forEach(propertyModel -> {
@@ -49,7 +49,7 @@ private static void assertModelNotSame(EntityModel originalEntity, EntityModel c
4949
}
5050

5151
private static EntityModel findSubtype(EntityModel clonedEntity, EntityModel subtype) {
52-
return clonedEntity.subtypes.stream()
52+
return clonedEntity.getSubtypes().stream()
5353
.filter(clone -> clone.getType().equals(subtype.getType()))
5454
.findFirst()
5555
.orElseThrow(() -> new MappingException(

0 commit comments

Comments
 (0)