Polishing.
Replace usage of StepVerifier.create with StepVerifier::create. Original pull request: #672 See #671
This commit is contained in:
committed by
Mark Paluch
parent
f98c7b9c93
commit
e66d317d47
@@ -48,7 +48,9 @@ class ReactiveCassandraTemplateIntegrationTest {
|
||||
new Person("Jesse", "Pinkman", 27))) //
|
||||
.flatMap(template::insert);
|
||||
|
||||
StepVerifier.create(truncateAndInsert).expectNextCount(4).verifyComplete();
|
||||
truncateAndInsert.as(StepVerifier::create) //
|
||||
.expectNextCount(4) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,6 +69,8 @@ class ReactiveCassandraTemplateIntegrationTest {
|
||||
.flatMap(v -> template.count(Person.class)) //
|
||||
.doOnNext(System.out::println);
|
||||
|
||||
StepVerifier.create(saveAndCount).expectNext(6L).verifyComplete();
|
||||
saveAndCount.as(StepVerifier::create) //
|
||||
.expectNext(6L) //
|
||||
.verifyComplete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,9 @@ class ReactivePersonRepositoryIntegrationTest {
|
||||
new Person("Saul", "Goodman", 42), //
|
||||
new Person("Jesse", "Pinkman", 27))));
|
||||
|
||||
StepVerifier.create(deleteAndInsert).expectNextCount(4).verifyComplete();
|
||||
deleteAndInsert.as(StepVerifier::create) //
|
||||
.expectNextCount(4) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +69,9 @@ class ReactivePersonRepositoryIntegrationTest {
|
||||
.flatMap(v -> repository.count()) //
|
||||
.doOnNext(System.out::println);
|
||||
|
||||
StepVerifier.create(saveAndCount).expectNext(6L).verifyComplete();
|
||||
saveAndCount.as(StepVerifier::create) //
|
||||
.expectNext(6L) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +81,7 @@ class ReactivePersonRepositoryIntegrationTest {
|
||||
@Test
|
||||
void shouldPerformConversionBeforeResultProcessing() {
|
||||
|
||||
StepVerifier.create(repository.findAll().doOnNext(System.out::println)) //
|
||||
repository.findAll().doOnNext(System.out::println).as(StepVerifier::create) //
|
||||
.expectNextCount(4) //
|
||||
.verifyComplete();
|
||||
}
|
||||
@@ -87,7 +91,10 @@ class ReactivePersonRepositoryIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void shouldQueryDataWithQueryDerivation() {
|
||||
StepVerifier.create(repository.findByLastname("White")).expectNextCount(2).verifyComplete();
|
||||
|
||||
repository.findByLastname("White").as(StepVerifier::create) //
|
||||
.expectNextCount(2) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +102,10 @@ class ReactivePersonRepositoryIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void limitResultSize() {
|
||||
StepVerifier.create(repository.findByLastname("White", Limit.of(1))).expectNextCount(1).verifyComplete();
|
||||
|
||||
repository.findByLastname("White", Limit.of(1)).as(StepVerifier::create) //
|
||||
.expectNextCount(1) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +113,10 @@ class ReactivePersonRepositoryIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void shouldQueryDataWithStringQuery() {
|
||||
StepVerifier.create(repository.findByFirstnameInAndLastname("Walter", "White")).expectNextCount(1).verifyComplete();
|
||||
|
||||
repository.findByFirstnameInAndLastname("Walter", "White").as(StepVerifier::create) //
|
||||
.expectNextCount(1) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +124,10 @@ class ReactivePersonRepositoryIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void shouldQueryDataWithDeferredQueryDerivation() {
|
||||
StepVerifier.create(repository.findByLastname(Mono.just("White"))).expectNextCount(2).verifyComplete();
|
||||
|
||||
repository.findByLastname(Mono.just("White")).as(StepVerifier::create) //
|
||||
.expectNextCount(2) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +136,7 @@ class ReactivePersonRepositoryIntegrationTest {
|
||||
@Test
|
||||
void shouldQueryDataWithMixedDeferredQueryDerivation() {
|
||||
|
||||
StepVerifier.create(repository.findByFirstnameAndLastname(Mono.just("Walter"), "White")) //
|
||||
repository.findByFirstnameAndLastname(Mono.just("Walter"), "White").as(StepVerifier::create) //
|
||||
.expectNextCount(1) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@@ -200,28 +200,31 @@ public class ChangeStreamsTests {
|
||||
ChangeStreamOptions.builder().filter(newAggregation(match(where("operationType").is("insert")))).build(),
|
||||
Person.class);
|
||||
|
||||
StepVerifier.create(changeStream) //
|
||||
changeStream.as(StepVerifier::create) //
|
||||
.expectSubscription() //
|
||||
.expectNoEvent(Duration.ofMillis(200)) // wait till change streams becomes active
|
||||
|
||||
// Save documents and await their change events
|
||||
.then(() -> {
|
||||
StepVerifier.create(reactiveTemplate.save(gabriel)).expectNextCount(1).verifyComplete();
|
||||
StepVerifier.create(reactiveTemplate.save(ash)).expectNextCount(1).verifyComplete();
|
||||
reactiveTemplate.save(gabriel).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
reactiveTemplate.save(ash).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
}).expectNextCount(2) //
|
||||
|
||||
// Update a document
|
||||
.then(() -> {
|
||||
|
||||
StepVerifier.create(reactiveTemplate.update(Person.class) //
|
||||
reactiveTemplate.update(Person.class) //
|
||||
.matching(query(where("id").is(ash.id()))) //
|
||||
.apply(update("age", 40)) //
|
||||
.first()).expectNextCount(1).verifyComplete();
|
||||
.first() //
|
||||
.as(StepVerifier::create) //
|
||||
.expectNextCount(1) //
|
||||
.verifyComplete();
|
||||
}).expectNoEvent(Duration.ofMillis(200)) // updates are skipped
|
||||
|
||||
// Save another document and await its change event
|
||||
.then(() -> {
|
||||
StepVerifier.create(reactiveTemplate.save(michael)).expectNextCount(1).verifyComplete();
|
||||
reactiveTemplate.save(michael).as(StepVerifier::create).expectNextCount(1).verifyComplete();
|
||||
}).expectNextCount(1) // there we go, all events received.
|
||||
|
||||
.thenCancel() // change streams are infinite streams, at some point we need to unsubscribe
|
||||
|
||||
@@ -60,7 +60,8 @@ class ReactiveMongoTemplateIntegrationTest {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
StepVerifier.create(template.dropCollection(Person.class)).verifyComplete();
|
||||
template.dropCollection(Person.class).as(StepVerifier::create) //
|
||||
.verifyComplete();
|
||||
|
||||
var insertAll = template
|
||||
.insertAll(Flux.just(new Person("Walter", "White", 50), //
|
||||
|
||||
@@ -77,7 +77,7 @@ class KeyCommandsTests {
|
||||
.count() //
|
||||
.doOnSuccess(count -> System.out.println(String.format("Total No. found: %s", count)));
|
||||
|
||||
StepVerifier.create(keyCount).expectNext(50L).verifyComplete();
|
||||
keyCount.as(StepVerifier::create).expectNext(50L).verifyComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ class KeyCommandsTests {
|
||||
.flatMap(result -> llen) //
|
||||
.doOnNext(count -> System.out.println(String.format("Total items in list left: %s", count)));//
|
||||
|
||||
StepVerifier.create(popAndLlen).expectNext(0L).verifyComplete();
|
||||
popAndLlen.as(StepVerifier::create).expectNext(0L).verifyComplete();
|
||||
}
|
||||
|
||||
private void generateRandomKeys(int nrKeys) {
|
||||
@@ -109,7 +109,9 @@ class KeyCommandsTests {
|
||||
.map(key -> SetCommand.set(key) //
|
||||
.value(ByteBuffer.wrap(UUID.randomUUID().toString().getBytes())));
|
||||
|
||||
StepVerifier.create(connection.stringCommands().set(generator)).expectNextCount(nrKeys).verifyComplete();
|
||||
connection.stringCommands().set(generator).as(StepVerifier::create) //
|
||||
.expectNextCount(nrKeys) //
|
||||
.verifyComplete();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class JacksonJsonTests {
|
||||
@Test
|
||||
void shouldWriteAndReadPerson() {
|
||||
|
||||
StepVerifier.create(typedOperations.opsForValue().set("homer", new Person("Homer", "Simpson"))) //
|
||||
typedOperations.opsForValue().set("homer", new Person("Homer", "Simpson")).as(StepVerifier::create) //
|
||||
.expectNext(true) //
|
||||
.verifyComplete();
|
||||
|
||||
|
||||
@@ -45,7 +45,10 @@ class ListOperationsTests {
|
||||
|
||||
@BeforeEach
|
||||
void before() {
|
||||
StepVerifier.create(operations.execute(it -> it.serverCommands().flushDb())).expectNext("OK").verifyComplete();
|
||||
|
||||
operations.execute(it -> it.serverCommands().flushDb()).as(StepVerifier::create) //
|
||||
.expectNext("OK") //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +66,7 @@ class ListOperationsTests {
|
||||
.log("example.springdata.redis", Level.INFO);
|
||||
|
||||
log.info("Blocking pop...waiting for message");
|
||||
StepVerifier.create(blpop) //
|
||||
blpop.as(StepVerifier::create) //
|
||||
.then(() -> {
|
||||
|
||||
Mono.delay(Duration.ofSeconds(10)).doOnSuccess(it -> {
|
||||
|
||||
@@ -46,7 +46,10 @@ class ValueOperationsTests {
|
||||
|
||||
@BeforeEach
|
||||
void before() {
|
||||
StepVerifier.create(operations.execute(it -> it.serverCommands().flushDb())).expectNext("OK").verifyComplete();
|
||||
|
||||
operations.execute(it -> it.serverCommands().flushDb()).as(StepVerifier::create) //
|
||||
.expectNext("OK") //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,14 +70,14 @@ class ValueOperationsTests {
|
||||
|
||||
log.info("Initial access (takes a while...)");
|
||||
|
||||
StepVerifier.create(cachedMono).expectSubscription() //
|
||||
cachedMono.as(StepVerifier::create).expectSubscription() //
|
||||
.expectNoEvent(Duration.ofSeconds(9)) //
|
||||
.expectNext("Hello, World!") //
|
||||
.verifyComplete();
|
||||
|
||||
log.info("Subsequent access (use cached value)");
|
||||
|
||||
var duration = StepVerifier.create(cachedMono) //
|
||||
var duration = cachedMono.as(StepVerifier::create) //
|
||||
.expectNext("Hello, World!") //
|
||||
.verifyComplete();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user