use of org.springframework.data.mongodb.core.query.NearQuery in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method geoNearShouldHonorReadPreferenceWhenSet.
// DATAMONGO-1166
@Test
public void geoNearShouldHonorReadPreferenceWhenSet() {
when(db.runCommand(Mockito.any(org.bson.Document.class), Mockito.any(ReadPreference.class), eq(Document.class))).thenReturn(mock(Document.class));
template.setReadPreference(ReadPreference.secondary());
NearQuery query = NearQuery.near(new Point(1, 1));
template.geoNear(query, Wrapper.class);
verify(this.db, times(1)).runCommand(Mockito.any(org.bson.Document.class), eq(ReadPreference.secondary()), eq(Document.class));
}
use of org.springframework.data.mongodb.core.query.NearQuery in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method geoNearShouldIgnoreReadPreferenceWhenNotSet.
// DATAMONGO-1166
@Test
public void geoNearShouldIgnoreReadPreferenceWhenNotSet() {
when(db.runCommand(Mockito.any(Document.class), eq(Document.class))).thenReturn(mock(Document.class));
NearQuery query = NearQuery.near(new Point(1, 1));
template.geoNear(query, Wrapper.class);
verify(this.db, times(1)).runCommand(Mockito.any(Document.class), eq(Document.class));
}
use of org.springframework.data.mongodb.core.query.NearQuery in project spring-data-mongodb by spring-projects.
the class MongoTemplateUnitTests method geoNearShouldUseCollationWhenPresent.
// DATAMONGO-1518
@Test
public void geoNearShouldUseCollationWhenPresent() {
NearQuery query = NearQuery.near(0D, 0D).query(new BasicQuery("{}").collation(Collation.of("fr")));
template.geoNear(query, AutogenerateableId.class);
ArgumentCaptor<Document> cmd = ArgumentCaptor.forClass(Document.class);
verify(db).runCommand(cmd.capture(), Mockito.any(Class.class));
assertThat(cmd.getValue().get("collation", Document.class), equalTo(new Document("locale", "fr")));
}
use of org.springframework.data.mongodb.core.query.NearQuery in project spring-data-mongodb by spring-projects.
the class ReactiveMongoTemplateUnitTests method geoNearShouldUseCollationWhenPresent.
// DATAMONGO-1518
@Test
public void geoNearShouldUseCollationWhenPresent() {
NearQuery query = NearQuery.near(0D, 0D).query(new BasicQuery("{}").collation(Collation.of("fr")));
template.geoNear(query, AutogenerateableId.class).subscribe();
ArgumentCaptor<Document> cmd = ArgumentCaptor.forClass(Document.class);
verify(db).runCommand(cmd.capture(), Mockito.any(Class.class));
assertThat(cmd.getValue().get("collation", Document.class), equalTo(new Document("locale", "fr")));
}
Aggregations