DATAMONGO-2488 - Polishing.

Simplify conditional entity check. Reduce test method visibility for JUnit 5.

Original pull request: #841.
This commit is contained in:
Mark Paluch
2020-03-11 14:31:24 +01:00
parent 7f7be5e47d
commit b0b905ddb7
2 changed files with 13 additions and 14 deletions

View File

@@ -1252,14 +1252,13 @@ public class QueryMapper {
String partial = iterator.next();
if (depth > 0 && property.isCollectionLike()) {
if (depth > 0 && property.isCollectionLike() && property.isEntity() && property.getComponentType() != null) {
MongoPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(property.getComponentType());
if (persistentEntity != null) {
MongoPersistentProperty persistentProperty = persistentEntity.getPersistentProperty(partial);
if(persistentProperty != null) {
partial = mapPropertyName(persistentProperty);
}
MongoPersistentEntity<?> persistentEntity = mappingContext
.getRequiredPersistentEntity(property.getComponentType());
MongoPersistentProperty persistentProperty = persistentEntity.getPersistentProperty(partial);
if (persistentProperty != null) {
partial = mapPropertyName(persistentProperty);
}
}

View File

@@ -73,9 +73,9 @@ import com.mongodb.client.model.Filters;
@ExtendWith(MockitoExtension.class)
public class QueryMapperUnitTests {
QueryMapper mapper;
MongoMappingContext context;
MappingMongoConverter converter;
private QueryMapper mapper;
private MongoMappingContext context;
private MappingMongoConverter converter;
@Mock MongoDatabaseFactory factory;
@@ -927,7 +927,7 @@ public class QueryMapperUnitTests {
}
@Test // DATAMONGO-2488
public void mapsNestedArrayPathCorrectlyForNonMatchingPath() {
void mapsNestedArrayPathCorrectlyForNonMatchingPath() {
org.bson.Document target = mapper.getMappedObject(
query(where("array.$[some_item].nested.$[other_item]").is("value")).getQueryObject(),
@@ -937,7 +937,7 @@ public class QueryMapperUnitTests {
}
@Test // DATAMONGO-2488
public void mapsNestedArrayPathCorrectlyForObjectTargetArray() {
void mapsNestedArrayPathCorrectlyForObjectTargetArray() {
org.bson.Document target = mapper.getMappedObject(
query(where("arrayObj.$[some_item].nested.$[other_item]").is("value")).getQueryObject(),
@@ -947,7 +947,7 @@ public class QueryMapperUnitTests {
}
@Test // DATAMONGO-2488
public void mapsNestedArrayPathCorrectlyForStringTargetArray() {
void mapsNestedArrayPathCorrectlyForStringTargetArray() {
org.bson.Document target = mapper.getMappedObject(
query(where("arrayString.$[some_item].nested.$[other_item]").is("value")).getQueryObject(),
@@ -957,7 +957,7 @@ public class QueryMapperUnitTests {
}
@Test // DATAMONGO-2488
public void mapsCustomFieldNamesForNestedArrayPathCorrectly() {
void mapsCustomFieldNamesForNestedArrayPathCorrectly() {
org.bson.Document target = mapper.getMappedObject(
query(where("arrayCustomName.$[some_item].nested.$[other_item]").is("value")).getQueryObject(),