use of reactor.test.StepVerifier in project spring-data-mongodb by spring-projects.
the class ReactiveMongoRepositoryTests method findsPeopleByLocationWithinCircle.
// DATAMONGO-1444
@Test
void findsPeopleByLocationWithinCircle() {
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
repository.save(dave).as(StepVerifier::create).expectNextCount(1).verifyComplete();
//
repository.findByLocationWithin(new Circle(-78.99171, 45.738868, 170)).as(StepVerifier::create).expectNext(//
dave).verifyComplete();
}
use of reactor.test.StepVerifier in project spring-data-mongodb by spring-projects.
the class ReactiveMongoRepositoryTests method findsPeopleGeoresultByLocationWithinBox.
// DATAMONGO-1444
@Test
void findsPeopleGeoresultByLocationWithinBox() {
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
repository.save(dave).as(StepVerifier::create).expectNextCount(1).verifyComplete();
//
repository.findByLocationNear(//
new Point(-73.99, 40.73), new Distance(2000, Metrics.KILOMETERS)).as(StepVerifier::create).consumeNextWith(actual -> {
assertThat(actual.getDistance().getValue()).isCloseTo(1, offset(1d));
assertThat(actual.getContent()).isEqualTo(dave);
}).verifyComplete();
}
use of reactor.test.StepVerifier in project spring-data-mongodb by spring-projects.
the class ReactiveMongoRepositoryTests method findsPeopleByLocationWithinBox.
// DATAMONGO-1444
@Test
void findsPeopleByLocationWithinBox() throws InterruptedException {
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
repository.save(dave).as(StepVerifier::create).expectNextCount(1).verifyComplete();
// Allow for index creation
Thread.sleep(500);
//
repository.findPersonByLocationNear(//
new Point(-73.99, 40.73), new Distance(2000, Metrics.KILOMETERS)).as(//
StepVerifier::create).expectNext(//
dave).verifyComplete();
}
use of reactor.test.StepVerifier in project spring-data-mongodb by spring-projects.
the class ReactiveMongoRepositoryTests method shouldUseTailableCursor.
// DATAMONGO-1444
@Test
void shouldUseTailableCursor() throws Exception {
//
template.dropCollection(Capped.class).then(//
template.createCollection(//
Capped.class, CollectionOptions.empty().size(1000).maxDocuments(100).capped())).as(//
StepVerifier::create).expectNextCount(//
1).verifyComplete();
template.insert(new Capped("value", Math.random())).as(StepVerifier::create).expectNextCount(1).verifyComplete();
BlockingQueue<Capped> documents = new LinkedBlockingDeque<>(100);
Disposable disposable = cappedRepository.findByKey("value").doOnNext(documents::add).subscribe();
assertThat(documents.poll(5, TimeUnit.SECONDS)).isNotNull();
template.insert(new Capped("value", Math.random())).as(StepVerifier::create).expectNextCount(1).verifyComplete();
assertThat(documents.poll(5, TimeUnit.SECONDS)).isNotNull();
assertThat(documents).isEmpty();
disposable.dispose();
}
use of reactor.test.StepVerifier in project spring-data-mongodb by spring-projects.
the class SimpleReactiveMongoRepositoryTests method setUp.
@BeforeEach
void setUp() {
factory = new ReactiveMongoRepositoryFactory(template);
factory.setRepositoryBaseClass(SimpleReactiveMongoRepository.class);
factory.setBeanClassLoader(classLoader);
factory.setBeanFactory(beanFactory);
factory.setEvaluationContextProvider(ReactiveQueryMethodEvaluationContextProvider.DEFAULT);
repository = factory.getRepository(ReactivePersonRepository.class);
immutableRepository = factory.getRepository(ReactiveImmutablePersonRepository.class);
repository.deleteAll().as(StepVerifier::create).verifyComplete();
immutableRepository.deleteAll().as(StepVerifier::create).verifyComplete();
dave = new ReactivePerson("Dave", "Matthews", 42);
oliver = new ReactivePerson("Oliver August", "Matthews", 4);
carter = new ReactivePerson("Carter", "Beauford", 49);
boyd = new ReactivePerson("Boyd", "Tinsley", 45);
stefan = new ReactivePerson("Stefan", "Lessard", 34);
leroi = new ReactivePerson("Leroi", "Moore", 41);
alicia = new ReactivePerson("Alicia", "Keys", 30);
keith = new ImmutableReactivePerson(null, "Keith", "Urban", 53);
james = new ImmutableReactivePerson(null, "James", "Arthur", 33);
mariah = new ImmutableReactivePerson(null, "Mariah", "Carey", 51);
//
repository.saveAll(Arrays.asList(oliver, dave, carter, boyd, stefan, leroi, alicia)).as(StepVerifier::create).expectNextCount(//
7).verifyComplete();
}
Aggregations