DATAMONGO-1718 - Polishing.
Add test and hand over Object.class as placeholder for required domain type. Original Pull Request: #469
This commit is contained in:
@@ -1652,7 +1652,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public <T> List<T> findAllAndRemove(Query query, String collectionName) {
|
public <T> List<T> findAllAndRemove(Query query, String collectionName) {
|
||||||
return findAllAndRemove(query, null, collectionName);
|
return (List<T>) findAllAndRemove(query, Object.class, collectionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|||||||
@@ -3239,6 +3239,25 @@ public class MongoTemplateTests {
|
|||||||
assertThat(loaded.getValue(), instanceOf(decimal128Type));
|
assertThat(loaded.getValue(), instanceOf(decimal128Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // DATAMONGO-1718
|
||||||
|
public void findAndRemoveAllWithoutExplicitDomainTypeShouldRemoveAndReturnEntitiesCorrectly() {
|
||||||
|
|
||||||
|
Sample jon = new Sample("1", "jon snow");
|
||||||
|
Sample bran = new Sample("2", "bran stark");
|
||||||
|
Sample rickon = new Sample("3", "rickon stark");
|
||||||
|
|
||||||
|
template.save(jon);
|
||||||
|
template.save(bran);
|
||||||
|
template.save(rickon);
|
||||||
|
|
||||||
|
List<Sample> result = template.findAllAndRemove(query(where("field").regex(".*stark$")),
|
||||||
|
template.determineCollectionName(Sample.class));
|
||||||
|
|
||||||
|
assertThat(result, hasSize(2));
|
||||||
|
assertThat(result, containsInAnyOrder(bran, rickon));
|
||||||
|
assertThat(template.count(new BasicQuery("{}"), template.determineCollectionName(Sample.class)), is(equalTo(1L)));
|
||||||
|
}
|
||||||
|
|
||||||
static class TypeWithNumbers {
|
static class TypeWithNumbers {
|
||||||
|
|
||||||
@Id String id;
|
@Id String id;
|
||||||
|
|||||||
Reference in New Issue
Block a user