DATAMONGO-2323 - Polishing.

Use .as(StepVerifier::create) syntax where possible.
This commit is contained in:
Mark Paluch
2019-07-17 14:35:18 +02:00
parent 46de82fe0b
commit 0ad8857368
15 changed files with 288 additions and 262 deletions

View File

@@ -107,7 +107,7 @@ public class DefaultReactiveIndexOperationsTests {
IndexDefinition id = new Index().named("with-collation").on("xyz", Direction.ASC)
.collation(Collation.of("de_AT").caseFirst(CaseFirst.off()));
StepVerifier.create(indexOps.ensureIndex(id)).expectNextCount(1).verifyComplete();
indexOps.ensureIndex(id).as(StepVerifier::create).expectNextCount(1).verifyComplete();
Document expected = new Document("locale", "de_AT") //
.append("caseLevel", false) //
@@ -119,7 +119,7 @@ public class DefaultReactiveIndexOperationsTests {
.append("normalization", false) //
.append("backwards", false);
StepVerifier.create(indexOps.getIndexInfo().filter(this.indexByName("with-collation"))) //
indexOps.getIndexInfo().filter(this.indexByName("with-collation")).as(StepVerifier::create) //
.consumeNextWith(indexInfo -> {
assertThat(indexInfo.getCollation()).isPresent();
@@ -141,9 +141,9 @@ public class DefaultReactiveIndexOperationsTests {
IndexDefinition id = new Index().named("partial-with-criteria").on("k3y", Direction.ASC)
.partial(of(where("q-t-y").gte(10)));
StepVerifier.create(indexOps.ensureIndex(id)).expectNextCount(1).verifyComplete();
indexOps.ensureIndex(id).as(StepVerifier::create).expectNextCount(1).verifyComplete();
StepVerifier.create(indexOps.getIndexInfo().filter(this.indexByName("partial-with-criteria"))) //
indexOps.getIndexInfo().filter(this.indexByName("partial-with-criteria")).as(StepVerifier::create) //
.consumeNextWith(indexInfo -> {
assertThat(indexInfo.getPartialFilterExpression()).isEqualTo("{ \"q-t-y\" : { \"$gte\" : 10 } }");
}) //
@@ -158,9 +158,9 @@ public class DefaultReactiveIndexOperationsTests {
IndexDefinition id = new Index().named("partial-with-mapped-criteria").on("k3y", Direction.ASC)
.partial(of(where("quantity").gte(10)));
StepVerifier.create(indexOps.ensureIndex(id)).expectNextCount(1).verifyComplete();
indexOps.ensureIndex(id).as(StepVerifier::create).expectNextCount(1).verifyComplete();
StepVerifier.create(indexOps.getIndexInfo().filter(this.indexByName("partial-with-mapped-criteria"))) //
indexOps.getIndexInfo().filter(this.indexByName("partial-with-mapped-criteria")).as(StepVerifier::create) //
.consumeNextWith(indexInfo -> {
assertThat(indexInfo.getPartialFilterExpression()).isEqualTo("{ \"qty\" : { \"$gte\" : 10 } }");
}).verifyComplete();
@@ -174,9 +174,9 @@ public class DefaultReactiveIndexOperationsTests {
IndexDefinition id = new Index().named("partial-with-dbo").on("k3y", Direction.ASC)
.partial(of(new org.bson.Document("qty", new org.bson.Document("$gte", 10))));
StepVerifier.create(indexOps.ensureIndex(id)).expectNextCount(1).verifyComplete();
indexOps.ensureIndex(id).as(StepVerifier::create).expectNextCount(1).verifyComplete();
StepVerifier.create(indexOps.getIndexInfo().filter(this.indexByName("partial-with-dbo"))) //
indexOps.getIndexInfo().filter(this.indexByName("partial-with-dbo")).as(StepVerifier::create) //
.consumeNextWith(indexInfo -> {
assertThat(indexInfo.getPartialFilterExpression()).isEqualTo("{ \"qty\" : { \"$gte\" : 10 } }");
}) //
@@ -196,9 +196,9 @@ public class DefaultReactiveIndexOperationsTests {
this.template.getCollectionName(DefaultIndexOperationsIntegrationTestsSample.class),
new QueryMapper(template.getConverter()), MappingToSameCollection.class);
StepVerifier.create(indexOps.ensureIndex(id)).expectNextCount(1).verifyComplete();
indexOps.ensureIndex(id).as(StepVerifier::create).expectNextCount(1).verifyComplete();
StepVerifier.create(indexOps.getIndexInfo().filter(this.indexByName("partial-with-inheritance"))) //
indexOps.getIndexInfo().filter(this.indexByName("partial-with-inheritance")).as(StepVerifier::create) //
.consumeNextWith(indexInfo -> {
assertThat(indexInfo.getPartialFilterExpression()).isEqualTo("{ \"a_g_e\" : { \"$gte\" : 10 } }");
}) //

View File

@@ -21,14 +21,15 @@ import static org.springframework.data.mongodb.core.query.Query.*;
import static org.springframework.data.mongodb.core.schema.JsonSchemaProperty.*;
import lombok.Data;
import org.bson.Document;
import reactor.test.StepVerifier;
import org.bson.Document;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.schema.MongoJsonSchema;
@@ -91,7 +92,7 @@ public class JsonSchemaQueryTests {
template.save(roseSpringHeart);
template.save(kazmardBoombub);
}
@AfterClass
public static void afterClass() {
if (client != null) {
@@ -115,9 +116,9 @@ public class JsonSchemaQueryTests {
com.mongodb.reactivestreams.client.MongoClient mongoClient = com.mongodb.reactivestreams.client.MongoClients.create();
StepVerifier.create(new ReactiveMongoTemplate(mongoClient, DATABASE_NAME)
.find(query(matchingDocumentStructure(schema)), Person.class)).expectNextCount(2).verifyComplete();
new ReactiveMongoTemplate(mongoClient, DATABASE_NAME).find(query(matchingDocumentStructure(schema)), Person.class)
.as(StepVerifier::create).expectNextCount(2).verifyComplete();
mongoClient.close();
}

View File

@@ -124,26 +124,27 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1719
public void findAll() {
StepVerifier.create(template.query(Person.class).all().collectList()).consumeNextWith(actual -> {
template.query(Person.class).all().collectList().as(StepVerifier::create).consumeNextWith(actual -> {
assertThat(actual).containsExactlyInAnyOrder(han, luke);
}).verifyComplete();
}
@Test // DATAMONGO-1719
public void findAllWithCollection() {
StepVerifier.create(template.query(Human.class).inCollection(STAR_WARS).all()).expectNextCount(2).verifyComplete();
template.query(Human.class).inCollection(STAR_WARS).all().as(StepVerifier::create).expectNextCount(2)
.verifyComplete();
}
@Test // DATAMONGO-2323
public void findAllAsDocumentDocument() {
StepVerifier.create(template.query(Document.class).inCollection(STAR_WARS).all()).expectNextCount(2)
template.query(Document.class).inCollection(STAR_WARS).all().as(StepVerifier::create).expectNextCount(2)
.verifyComplete();
}
@Test // DATAMONGO-1719
public void findAllWithProjection() {
StepVerifier.create(template.query(Person.class).as(Jedi.class).all().map(it -> it.getClass().getName())) //
template.query(Person.class).as(Jedi.class).all().map(it -> it.getClass().getName()).as(StepVerifier::create) //
.expectNext(Jedi.class.getName(), Jedi.class.getName()) //
.verifyComplete();
}
@@ -151,7 +152,7 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1719
public void findAllBy() {
StepVerifier.create(template.query(Person.class).matching(query(where("firstname").is("luke"))).all()) //
template.query(Person.class).matching(query(where("firstname").is("luke"))).all().as(StepVerifier::create) //
.expectNext(luke) //
.verifyComplete();
}
@@ -159,8 +160,8 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1719
public void findAllByWithCollectionUsingMappingInformation() {
StepVerifier
.create(template.query(Jedi.class).inCollection(STAR_WARS).matching(query(where("name").is("luke"))).all())
template.query(Jedi.class).inCollection(STAR_WARS).matching(query(where("name").is("luke"))).all()
.as(StepVerifier::create)
.consumeNextWith(it -> assertThat(it).isInstanceOf(Jedi.class)) //
.verifyComplete();
}
@@ -168,9 +169,8 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1719
public void findAllByWithCollection() {
StepVerifier
.create(
template.query(Human.class).inCollection(STAR_WARS).matching(query(where("firstname").is("luke"))).all())
template.query(Human.class).inCollection(STAR_WARS).matching(query(where("firstname").is("luke"))).all()
.as(StepVerifier::create)
.expectNextCount(1) //
.verifyComplete();
}
@@ -178,8 +178,8 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1719
public void findAllByWithProjection() {
StepVerifier
.create(template.query(Person.class).as(Jedi.class).matching(query(where("firstname").is("luke"))).all())
template.query(Person.class).as(Jedi.class).matching(query(where("firstname").is("luke"))).all()
.as(StepVerifier::create)
.consumeNextWith(it -> assertThat(it).isInstanceOf(Jedi.class)) //
.verifyComplete();
}
@@ -187,8 +187,8 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1719
public void findAllByWithClosedInterfaceProjection() {
StepVerifier.create(
template.query(Person.class).as(PersonProjection.class).matching(query(where("firstname").is("luke"))).all())
template.query(Person.class).as(PersonProjection.class).matching(query(where("firstname").is("luke"))).all()
.as(StepVerifier::create)
.consumeNextWith(it -> {
assertThat(it).isInstanceOf(PersonProjection.class);
@@ -200,8 +200,8 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1719
public void findAllByWithOpenInterfaceProjection() {
StepVerifier.create(template.query(Person.class).as(PersonSpELProjection.class)
.matching(query(where("firstname").is("luke"))).all()).consumeNextWith(it -> {
template.query(Person.class).as(PersonSpELProjection.class).matching(query(where("firstname").is("luke"))).all()
.as(StepVerifier::create).consumeNextWith(it -> {
assertThat(it).isInstanceOf(PersonSpELProjection.class);
assertThat(it.getName()).isEqualTo("luke");
@@ -212,7 +212,7 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1719
public void findBy() {
StepVerifier.create(template.query(Person.class).matching(query(where("firstname").is("luke"))).one())
template.query(Person.class).matching(query(where("firstname").is("luke"))).one().as(StepVerifier::create)
.expectNext(luke) //
.verifyComplete();
}
@@ -220,14 +220,14 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1719
public void findByNoMatch() {
StepVerifier.create(template.query(Person.class).matching(query(where("firstname").is("spock"))).one())
template.query(Person.class).matching(query(where("firstname").is("spock"))).one().as(StepVerifier::create)
.verifyComplete();
}
@Test // DATAMONGO-1719
public void findByTooManyResults() {
StepVerifier.create(template.query(Person.class).matching(query(where("firstname").in("han", "luke"))).one())
template.query(Person.class).matching(query(where("firstname").in("han", "luke"))).one().as(StepVerifier::create)
.expectError(IncorrectResultSizeDataAccessException.class) //
.verify();
}
@@ -244,7 +244,7 @@ public class ReactiveFindOperationSupportTests {
blocking.save(alderan);
blocking.save(dantooine);
StepVerifier.create(template.query(Planet.class).near(NearQuery.near(-73.9667, 40.78).spherical(true)).all())
template.query(Planet.class).near(NearQuery.near(-73.9667, 40.78).spherical(true)).all().as(StepVerifier::create)
.consumeNextWith(actual -> {
assertThat(actual.getDistance()).isNotNull();
}) //
@@ -264,8 +264,9 @@ public class ReactiveFindOperationSupportTests {
blocking.save(alderan);
blocking.save(dantooine);
StepVerifier.create(template.query(Object.class).inCollection(STAR_WARS).as(Human.class)
.near(NearQuery.near(-73.9667, 40.78).spherical(true)).all()).consumeNextWith(actual -> {
template.query(Object.class).inCollection(STAR_WARS).as(Human.class)
.near(NearQuery.near(-73.9667, 40.78).spherical(true)).all().as(StepVerifier::create)
.consumeNextWith(actual -> {
assertThat(actual.getDistance()).isNotNull();
assertThat(actual.getContent()).isInstanceOf(Human.class);
assertThat(actual.getContent().getId()).isEqualTo("alderan");
@@ -286,8 +287,8 @@ public class ReactiveFindOperationSupportTests {
blocking.save(alderan);
blocking.save(dantooine);
StepVerifier.create(template.query(Planet.class).as(PlanetProjection.class)
.near(NearQuery.near(-73.9667, 40.78).spherical(true)).all()).consumeNextWith(it -> {
template.query(Planet.class).as(PlanetProjection.class).near(NearQuery.near(-73.9667, 40.78).spherical(true)).all()
.as(StepVerifier::create).consumeNextWith(it -> {
assertThat(it.getDistance()).isNotNull();
assertThat(it.getContent()).isInstanceOf(PlanetProjection.class);
@@ -309,8 +310,8 @@ public class ReactiveFindOperationSupportTests {
blocking.save(alderan);
blocking.save(dantooine);
StepVerifier.create(template.query(Planet.class).as(PlanetSpELProjection.class)
.near(NearQuery.near(-73.9667, 40.78).spherical(true)).all()).consumeNextWith(it -> {
template.query(Planet.class).as(PlanetSpELProjection.class).near(NearQuery.near(-73.9667, 40.78).spherical(true))
.all().as(StepVerifier::create).consumeNextWith(it -> {
assertThat(it.getDistance()).isNotNull();
assertThat(it.getContent()).isInstanceOf(PlanetSpELProjection.class);
@@ -397,26 +398,26 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1719
public void firstShouldReturnFirstEntryInCollection() {
StepVerifier.create(template.query(Person.class).first()).expectNextCount(1).verifyComplete();
template.query(Person.class).first().as(StepVerifier::create).expectNextCount(1).verifyComplete();
}
@Test // DATAMONGO-1719
public void countShouldReturnNrOfElementsInCollectionWhenNoQueryPresent() {
StepVerifier.create(template.query(Person.class).count()).expectNext(2L).verifyComplete();
template.query(Person.class).count().as(StepVerifier::create).expectNext(2L).verifyComplete();
}
@Test // DATAMONGO-1719
public void countShouldReturnNrOfElementsMatchingQuery() {
StepVerifier
.create(template.query(Person.class).matching(query(where("firstname").is(luke.getFirstname()))).count())
template.query(Person.class).matching(query(where("firstname").is(luke.getFirstname()))).count()
.as(StepVerifier::create)
.expectNext(1L) //
.verifyComplete();
}
@Test // DATAMONGO-1719
public void existsShouldReturnTrueIfAtLeastOneElementExistsInCollection() {
StepVerifier.create(template.query(Person.class).exists()).expectNext(true).verifyComplete();
template.query(Person.class).exists().as(StepVerifier::create).expectNext(true).verifyComplete();
}
@Test // DATAMONGO-1719
@@ -424,14 +425,14 @@ public class ReactiveFindOperationSupportTests {
blocking.remove(new BasicQuery("{}"), STAR_WARS);
StepVerifier.create(template.query(Person.class).exists()).expectNext(false).verifyComplete();
template.query(Person.class).exists().as(StepVerifier::create).expectNext(false).verifyComplete();
}
@Test // DATAMONGO-1719
public void existsShouldReturnTrueIfAtLeastOneElementMatchesQuery() {
StepVerifier
.create(template.query(Person.class).matching(query(where("firstname").is(luke.getFirstname()))).exists())
template.query(Person.class).matching(query(where("firstname").is(luke.getFirstname()))).exists()
.as(StepVerifier::create)
.expectNext(true) //
.verifyComplete();
}
@@ -439,7 +440,7 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1719
public void existsShouldReturnFalseWhenNoElementMatchesQuery() {
StepVerifier.create(template.query(Person.class).matching(query(where("firstname").is("spock"))).exists())
template.query(Person.class).matching(query(where("firstname").is("spock"))).exists().as(StepVerifier::create)
.expectNext(false) //
.verifyComplete();
}
@@ -447,7 +448,8 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1761
public void distinctReturnsEmptyListIfNoMatchFound() {
StepVerifier.create(template.query(Person.class).distinct("actually-not-property-in-use").as(String.class).all())
template.query(Person.class).distinct("actually-not-property-in-use").as(String.class).all()
.as(StepVerifier::create)
.verifyComplete();
}
@@ -460,7 +462,7 @@ public class ReactiveFindOperationSupportTests {
blocking.save(anakin);
StepVerifier.create(template.query(Person.class).distinct("lastname").as(String.class).all())
template.query(Person.class).distinct("lastname").as(String.class).all().as(StepVerifier::create)
.assertNext(in("solo", "skywalker")).assertNext(in("solo", "skywalker")) //
.verifyComplete();
}
@@ -486,7 +488,7 @@ public class ReactiveFindOperationSupportTests {
Consumer<Object> containedInAbilities = in(anakin.ability, padme.ability, jaja.ability);
StepVerifier.create(template.query(Person.class).distinct("ability").all()) //
template.query(Person.class).distinct("ability").all().as(StepVerifier::create) //
.assertNext(containedInAbilities) //
.assertNext(containedInAbilities) //
.assertNext(containedInAbilities) //
@@ -505,7 +507,7 @@ public class ReactiveFindOperationSupportTests {
blocking.save(anakin);
StepVerifier.create(template.query(Person.class).distinct("ability").all()) //
template.query(Person.class).distinct("ability").all().as(StepVerifier::create) //
.expectNext(anakin.ability) //
.verifyComplete();
}
@@ -522,7 +524,7 @@ public class ReactiveFindOperationSupportTests {
blocking.save(anakin);
StepVerifier.create(template.query(Person.class).distinct("ability").as(Sith.class).all()) //
template.query(Person.class).distinct("ability").as(Sith.class).all().as(StepVerifier::create) //
.expectNext(sith) //
.verifyComplete();
}
@@ -539,7 +541,7 @@ public class ReactiveFindOperationSupportTests {
blocking.save(anakin);
StepVerifier.create(template.query(Person.class).distinct("ability").as(Document.class).all())
template.query(Person.class).distinct("ability").as(Document.class).all().as(StepVerifier::create)
.expectNext(new Document("rank", "lord").append("_class", Sith.class.getName())) //
.verifyComplete();
}
@@ -547,7 +549,7 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1761
public void distinctMapsFieldNameCorrectly() {
StepVerifier.create(template.query(Jedi.class).inCollection(STAR_WARS).distinct("name").as(String.class).all())
template.query(Jedi.class).inCollection(STAR_WARS).distinct("name").as(String.class).all().as(StepVerifier::create)
.assertNext(in("han", "luke")).assertNext(in("han", "luke")) //
.verifyComplete();
}
@@ -556,7 +558,7 @@ public class ReactiveFindOperationSupportTests {
public void distinctReturnsRawValuesIfReturnTypeIsBsonValue() {
Consumer<BsonValue> inValues = in(new BsonString("solo"), new BsonString("skywalker"));
StepVerifier.create(template.query(Person.class).distinct("lastname").as(BsonValue.class).all())
template.query(Person.class).distinct("lastname").as(BsonValue.class).all().as(StepVerifier::create)
.assertNext(inValues) //
.assertNext(inValues) //
.verifyComplete();
@@ -567,7 +569,7 @@ public class ReactiveFindOperationSupportTests {
blocking.save(new Document("darth", "vader"), STAR_WARS);
StepVerifier.create(template.query(Person.class).distinct("darth").all()) //
template.query(Person.class).distinct("darth").all().as(StepVerifier::create) //
.expectNext("vader") //
.verifyComplete();
}
@@ -580,7 +582,7 @@ public class ReactiveFindOperationSupportTests {
blocking.save(luke);
StepVerifier.create(template.query(Person.class).distinct("father").as(Jedi.class).all())
template.query(Person.class).distinct("father").as(Jedi.class).all().as(StepVerifier::create)
.expectNext(new Jedi("anakin")) //
.verifyComplete();
}
@@ -593,7 +595,8 @@ public class ReactiveFindOperationSupportTests {
blocking.save(luke);
StepVerifier.create(template.query(Object.class).inCollection(STAR_WARS).distinct("father").as(Jedi.class).all())
template.query(Object.class).inCollection(STAR_WARS).distinct("father").as(Jedi.class).all()
.as(StepVerifier::create)
.expectNext(new Jedi("anakin")) //
.verifyComplete();
}
@@ -609,7 +612,7 @@ public class ReactiveFindOperationSupportTests {
Person expected = new Person();
expected.firstname = luke.father.firstname;
StepVerifier.create(template.query(Person.class).distinct("father").all()) //
template.query(Person.class).distinct("father").all().as(StepVerifier::create) //
.expectNext(expected) //
.verifyComplete();
}
@@ -617,7 +620,7 @@ public class ReactiveFindOperationSupportTests {
@Test // DATAMONGO-1761
public void distinctThrowsExceptionWhenExplicitMappingTypeCannotBeApplied() {
StepVerifier.create(template.query(Person.class).distinct("firstname").as(Long.class).all())
template.query(Person.class).distinct("firstname").as(Long.class).all().as(StepVerifier::create)
.expectError(InvalidDataAccessApiUsageException.class) //
.verify();
}

View File

@@ -69,18 +69,18 @@ public class ReactiveMongoTemplateCollationTests {
@Before
public void setUp() {
StepVerifier.create(template.dropCollection(COLLECTION_NAME)).verifyComplete();
template.dropCollection(COLLECTION_NAME).as(StepVerifier::create).verifyComplete();
}
@Test // DATAMONGO-1693
public void createCollectionWithCollation() {
StepVerifier.create(template.createCollection(COLLECTION_NAME, CollectionOptions.just(Collation.of("en_US")))) //
template.createCollection(COLLECTION_NAME, CollectionOptions.just(Collation.of("en_US"))).as(StepVerifier::create) //
.expectNextCount(1) //
.verifyComplete();
Mono<Document> collation = getCollationInfo(COLLECTION_NAME);
StepVerifier.create(collation) //
collation.as(StepVerifier::create) //
.consumeNextWith(document -> assertThat(document.get("locale")).isEqualTo("en_US")) //
.verifyComplete();

View File

@@ -66,7 +66,7 @@ public class ReactiveMongoTemplateExecuteTests {
.mergeWith(operations.dropCollection("execute_test1")) //
.mergeWith(operations.dropCollection("execute_test2"));
StepVerifier.create(cleanup).verifyComplete();
cleanup.as(StepVerifier::create).verifyComplete();
if (mongoVersion == null) {
mongoVersion = operations.executeCommand("{ buildInfo: 1 }") //
@@ -79,7 +79,7 @@ public class ReactiveMongoTemplateExecuteTests {
@Test // DATAMONGO-1444
public void executeCommandJsonCommandShouldReturnSingleResponse() {
StepVerifier.create(operations.executeCommand("{ buildInfo: 1 }")).consumeNextWith(actual -> {
operations.executeCommand("{ buildInfo: 1 }").as(StepVerifier::create).consumeNextWith(actual -> {
assertThat(actual, hasKey("version"));
}).verifyComplete();
@@ -88,7 +88,7 @@ public class ReactiveMongoTemplateExecuteTests {
@Test // DATAMONGO-1444
public void executeCommandDocumentCommandShouldReturnSingleResponse() {
StepVerifier.create(operations.executeCommand(new Document("buildInfo", 1))).consumeNextWith(actual -> {
operations.executeCommand(new Document("buildInfo", 1)).as(StepVerifier::create).consumeNextWith(actual -> {
assertThat(actual, hasKey("version"));
}).verifyComplete();
@@ -99,10 +99,10 @@ public class ReactiveMongoTemplateExecuteTests {
assumeTrue(mongoVersion.isGreaterThan(THREE));
StepVerifier.create(operations.executeCommand("{ insert: 'execute_test', documents: [{},{},{}]}"))
operations.executeCommand("{ insert: 'execute_test', documents: [{},{},{}]}").as(StepVerifier::create)
.expectNextCount(1).verifyComplete();
StepVerifier.create(operations.executeCommand("{ find: 'execute_test'}")) //
operations.executeCommand("{ find: 'execute_test'}").as(StepVerifier::create) //
.consumeNextWith(actual -> {
assertThat(actual.get("ok", Double.class), is(closeTo(1D, 0D)));
@@ -114,7 +114,7 @@ public class ReactiveMongoTemplateExecuteTests {
@Test // DATAMONGO-1444
public void executeCommandJsonCommandShouldTranslateExceptions() {
StepVerifier.create(operations.executeCommand("{ unknown: 1 }")) //
operations.executeCommand("{ unknown: 1 }").as(StepVerifier::create) //
.expectError(InvalidDataAccessApiUsageException.class) //
.verify();
}
@@ -122,7 +122,7 @@ public class ReactiveMongoTemplateExecuteTests {
@Test // DATAMONGO-1444
public void executeCommandDocumentCommandShouldTranslateExceptions() {
StepVerifier.create(operations.executeCommand(new Document("unknown", 1))) //
operations.executeCommand(new Document("unknown", 1)).as(StepVerifier::create) //
.expectError(InvalidDataAccessApiUsageException.class) //
.verify();
@@ -131,7 +131,7 @@ public class ReactiveMongoTemplateExecuteTests {
@Test // DATAMONGO-1444
public void executeCommandWithReadPreferenceCommandShouldTranslateExceptions() {
StepVerifier.create(operations.executeCommand(new Document("unknown", 1), ReadPreference.nearest())) //
operations.executeCommand(new Document("unknown", 1), ReadPreference.nearest()).as(StepVerifier::create) //
.expectError(InvalidDataAccessApiUsageException.class) //
.verify();
}
@@ -143,11 +143,11 @@ public class ReactiveMongoTemplateExecuteTests {
.mergeWith(operations.executeCommand("{ insert: 'execute_test1', documents: [{},{},{}]}"))
.mergeWith(operations.executeCommand("{ insert: 'execute_test2', documents: [{},{},{}]}"));
StepVerifier.create(documentFlux).expectNextCount(3).verifyComplete();
documentFlux.as(StepVerifier::create).expectNextCount(3).verifyComplete();
Flux<Document> execute = operations.execute(MongoDatabase::listCollections);
StepVerifier.create(execute.filter(document -> document.getString("name").startsWith("execute_test"))) //
execute.filter(document -> document.getString("name").startsWith("execute_test")).as(StepVerifier::create) //
.expectNextCount(3) //
.verifyComplete();
}
@@ -169,27 +169,28 @@ public class ReactiveMongoTemplateExecuteTests {
throw new MongoException(50, "hi there");
});
StepVerifier.create(execute).expectError(UncategorizedMongoDbException.class).verify();
execute.as(StepVerifier::create).expectError(UncategorizedMongoDbException.class).verify();
}
@Test // DATAMONGO-1444
public void executeOnCollectionWithTypeShouldReturnFindResults() {
StepVerifier.create(operations.executeCommand("{ insert: 'person', documents: [{},{},{}]}")) //
operations.executeCommand("{ insert: 'person', documents: [{},{},{}]}").as(StepVerifier::create) //
.expectNextCount(1) //
.verifyComplete();
StepVerifier.create(operations.execute(Person.class, MongoCollection::find)).expectNextCount(3).verifyComplete();
operations.execute(Person.class, MongoCollection::find).as(StepVerifier::create).expectNextCount(3)
.verifyComplete();
}
@Test // DATAMONGO-1444
public void executeOnCollectionWithNameShouldReturnFindResults() {
StepVerifier.create(operations.executeCommand("{ insert: 'execute_test', documents: [{},{},{}]}")) //
operations.executeCommand("{ insert: 'execute_test', documents: [{},{},{}]}").as(StepVerifier::create) //
.expectNextCount(1) //
.verifyComplete();
StepVerifier.create(operations.execute("execute_test", MongoCollection::find)) //
operations.execute("execute_test", MongoCollection::find).as(StepVerifier::create) //
.expectNextCount(3) //
.verifyComplete();
}

View File

@@ -75,14 +75,19 @@ public class ReactiveMongoTemplateTransactionTests {
template = new ReactiveMongoTemplate(client, DATABASE_NAME);
StepVerifier.create(MongoTestUtils.createOrReplaceCollection(DATABASE_NAME, COLLECTION_NAME, client)) //
MongoTestUtils.createOrReplaceCollection(DATABASE_NAME, COLLECTION_NAME, client).as(StepVerifier::create) //
.expectNext(Success.SUCCESS) //
.verifyComplete();
StepVerifier.create(MongoTestUtils.createOrReplaceCollection(DATABASE_NAME, "person", client))
MongoTestUtils.createOrReplaceCollection(DATABASE_NAME, "person", client).as(StepVerifier::create)
.expectNext(Success.SUCCESS) //
.verifyComplete();
MongoTestUtils.createOrReplaceCollection(DATABASE_NAME, "personWithVersionPropertyOfTypeInteger", client)
.as(StepVerifier::create).expectNext(Success.SUCCESS) //
.verifyComplete();
template.insert(DOCUMENT, COLLECTION_NAME).as(StepVerifier::create).expectNextCount(1).verifyComplete();
StepVerifier.create(template.insert(DOCUMENT, COLLECTION_NAME)).expectNextCount(1).verifyComplete();
template.insertAll(Arrays.asList(AHMANN, ARLEN, LEESHA, RENNA)) //

View File

@@ -136,7 +136,7 @@ public class ReactiveMongoTemplateUnitTests {
any(Class.class));
Map<String, String> entity = new LinkedHashMap<>();
StepVerifier.create(template.save(entity, "foo")).consumeNextWith(actual -> {
template.save(entity, "foo").as(StepVerifier::create).consumeNextWith(actual -> {
assertThat(entity, hasKey("_id"));
}).verifyComplete();

View File

@@ -67,7 +67,7 @@ public class ReactiveRemoveOperationSupportTests {
@Test // DATAMONGO-1719
public void removeAll() {
StepVerifier.create(template.remove(Person.class).all()).consumeNextWith(actual -> {
template.remove(Person.class).all().as(StepVerifier::create).consumeNextWith(actual -> {
assertThat(actual.getDeletedCount()).isEqualTo(2L);
}).verifyComplete();
}
@@ -75,22 +75,22 @@ public class ReactiveRemoveOperationSupportTests {
@Test // DATAMONGO-1719
public void removeAllMatching() {
StepVerifier.create(template.remove(Person.class).matching(query(where("firstname").is("han"))).all())
template.remove(Person.class).matching(query(where("firstname").is("han"))).all().as(StepVerifier::create)
.consumeNextWith(actual -> assertThat(actual.getDeletedCount()).isEqualTo(1L)).verifyComplete();
}
@Test // DATAMONGO-1719
public void removeAllMatchingWithAlternateDomainTypeAndCollection() {
StepVerifier
.create(template.remove(Jedi.class).inCollection(STAR_WARS).matching(query(where("name").is("luke"))).all())
template.remove(Jedi.class).inCollection(STAR_WARS).matching(query(where("name").is("luke"))).all()
.as(StepVerifier::create)
.consumeNextWith(actual -> assertThat(actual.getDeletedCount()).isEqualTo(1L)).verifyComplete();
}
@Test // DATAMONGO-1719
public void removeAndReturnAllMatching() {
StepVerifier.create(template.remove(Person.class).matching(query(where("firstname").is("han"))).findAndRemove())
template.remove(Person.class).matching(query(where("firstname").is("han"))).findAndRemove().as(StepVerifier::create)
.expectNext(han).verifyComplete();
}

View File

@@ -90,7 +90,7 @@ public class ReactiveUpdateOperationSupportTests {
@Test // DATAMONGO-1719
public void updateFirst() {
StepVerifier.create(template.update(Person.class).apply(new Update().set("firstname", "Han")).first())
template.update(Person.class).apply(new Update().set("firstname", "Han")).first().as(StepVerifier::create)
.consumeNextWith(actual -> {
assertThat(actual.getModifiedCount()).isEqualTo(1L);
@@ -102,7 +102,7 @@ public class ReactiveUpdateOperationSupportTests {
@Test // DATAMONGO-1719
public void updateAll() {
StepVerifier.create(template.update(Person.class).apply(new Update().set("firstname", "Han")).all())
template.update(Person.class).apply(new Update().set("firstname", "Han")).all().as(StepVerifier::create)
.consumeNextWith(actual -> {
assertThat(actual.getModifiedCount()).isEqualTo(2L);
@@ -113,8 +113,8 @@ public class ReactiveUpdateOperationSupportTests {
@Test // DATAMONGO-1719
public void updateAllMatching() {
StepVerifier
.create(template.update(Person.class).matching(queryHan()).apply(new Update().set("firstname", "Han")).all())
template.update(Person.class).matching(queryHan()).apply(new Update().set("firstname", "Han")).all()
.as(StepVerifier::create)
.consumeNextWith(actual -> {
assertThat(actual.getModifiedCount()).isEqualTo(1L);
@@ -125,8 +125,8 @@ public class ReactiveUpdateOperationSupportTests {
@Test // DATAMONGO-1719
public void updateWithDifferentDomainClassAndCollection() {
StepVerifier.create(template.update(Jedi.class).inCollection(STAR_WARS)
.matching(query(where("_id").is(han.getId()))).apply(new Update().set("name", "Han")).all())
template.update(Jedi.class).inCollection(STAR_WARS).matching(query(where("_id").is(han.getId())))
.apply(new Update().set("name", "Han")).all().as(StepVerifier::create)
.consumeNextWith(actual -> {
assertThat(actual.getModifiedCount()).isEqualTo(1L);
@@ -140,8 +140,8 @@ public class ReactiveUpdateOperationSupportTests {
@Test // DATAMONGO-1719
public void findAndModify() {
StepVerifier.create(
template.update(Person.class).matching(queryHan()).apply(new Update().set("firstname", "Han")).findAndModify())
template.update(Person.class).matching(queryHan()).apply(new Update().set("firstname", "Han")).findAndModify()
.as(StepVerifier::create)
.expectNext(han).verifyComplete();
assertThat(blocking.findOne(queryHan(), Person.class)).isNotEqualTo(han).hasFieldOrPropertyWithValue("firstname",
@@ -151,9 +151,8 @@ public class ReactiveUpdateOperationSupportTests {
@Test // DATAMONGO-1719
public void findAndModifyWithDifferentDomainTypeAndCollection() {
StepVerifier
.create(template.update(Jedi.class).inCollection(STAR_WARS).matching(query(where("_id").is(han.getId())))
.apply(new Update().set("name", "Han")).findAndModify())
template.update(Jedi.class).inCollection(STAR_WARS).matching(query(where("_id").is(han.getId())))
.apply(new Update().set("name", "Han")).findAndModify().as(StepVerifier::create)
.consumeNextWith(actual -> assertThat(actual.getName()).isEqualTo("han")).verifyComplete();
assertThat(blocking.findOne(queryHan(), Person.class)).isNotEqualTo(han).hasFieldOrPropertyWithValue("firstname",
@@ -163,8 +162,9 @@ public class ReactiveUpdateOperationSupportTests {
@Test // DATAMONGO-1719
public void findAndModifyWithOptions() {
StepVerifier.create(template.update(Person.class).matching(queryHan()).apply(new Update().set("firstname", "Han"))
.withOptions(FindAndModifyOptions.options().returnNew(true)).findAndModify()).consumeNextWith(actual -> {
template.update(Person.class).matching(queryHan()).apply(new Update().set("firstname", "Han"))
.withOptions(FindAndModifyOptions.options().returnNew(true)).findAndModify().as(StepVerifier::create)
.consumeNextWith(actual -> {
assertThat(actual).isNotEqualTo(han).hasFieldOrPropertyWithValue("firstname", "Han");
}).verifyComplete();
@@ -173,8 +173,8 @@ public class ReactiveUpdateOperationSupportTests {
@Test // DATAMONGO-1719
public void upsert() {
StepVerifier.create(template.update(Person.class).matching(query(where("id").is("id-3")))
.apply(new Update().set("firstname", "Chewbacca")).upsert()).consumeNextWith(actual -> {
template.update(Person.class).matching(query(where("id").is("id-3")))
.apply(new Update().set("firstname", "Chewbacca")).upsert().as(StepVerifier::create).consumeNextWith(actual -> {
assertThat(actual.getModifiedCount()).isEqualTo(0L);
assertThat(actual.getUpsertedId()).isEqualTo(new BsonString("id-3"));

View File

@@ -66,12 +66,11 @@ public class ReactiveAggregationTests {
private void cleanDb() {
StepVerifier
.create(reactiveMongoTemplate.dropCollection(INPUT_COLLECTION) //
.then(reactiveMongoTemplate.dropCollection(OUTPUT_COLLECTION)) //
.then(reactiveMongoTemplate.dropCollection(Product.class)) //
.then(reactiveMongoTemplate.dropCollection(City.class)) //
.then(reactiveMongoTemplate.dropCollection(Venue.class))) //
reactiveMongoTemplate.dropCollection(INPUT_COLLECTION) //
.then(reactiveMongoTemplate.dropCollection(OUTPUT_COLLECTION)) //
.then(reactiveMongoTemplate.dropCollection(Product.class)) //
.then(reactiveMongoTemplate.dropCollection(City.class)) //
.then(reactiveMongoTemplate.dropCollection(Venue.class)).as(StepVerifier::create) //
.verifyComplete();
}
@@ -79,7 +78,7 @@ public class ReactiveAggregationTests {
public void expressionsInProjectionExampleShowcase() {
Product product = new Product("P1", "A", 1.99, 3, 0.05, 0.19);
StepVerifier.create(reactiveMongoTemplate.insert(product)).expectNextCount(1).verifyComplete();
reactiveMongoTemplate.insert(product).as(StepVerifier::create).expectNextCount(1).verifyComplete();
double shippingCosts = 1.2;
@@ -88,7 +87,7 @@ public class ReactiveAggregationTests {
.andExpression("netPrice * 10", shippingCosts).as("salesPrice") //
);
StepVerifier.create(reactiveMongoTemplate.aggregate(agg, Document.class)).consumeNextWith(actual -> {
reactiveMongoTemplate.aggregate(agg, Document.class).as(StepVerifier::create).consumeNextWith(actual -> {
assertThat(actual).containsEntry("_id", product.id);
assertThat(actual).containsEntry("name", product.name);
@@ -104,13 +103,13 @@ public class ReactiveAggregationTests {
City braunschweig = new City("Braunschweig", 102);
City weinheim = new City("Weinheim", 103);
StepVerifier.create(reactiveMongoTemplate.insertAll(Arrays.asList(dresden, linz, braunschweig, weinheim)))
reactiveMongoTemplate.insertAll(Arrays.asList(dresden, linz, braunschweig, weinheim)).as(StepVerifier::create)
.expectNextCount(4).verifyComplete();
Aggregation agg = newAggregation( //
match(where("population").lt(103)));
StepVerifier.create(reactiveMongoTemplate.aggregate(agg, "city", City.class).collectList())
reactiveMongoTemplate.aggregate(agg, "city", City.class).collectList().as(StepVerifier::create)
.consumeNextWith(actual -> {
assertThat(actual).hasSize(3).contains(dresden, linz, braunschweig);
}).verifyComplete();
@@ -124,14 +123,15 @@ public class ReactiveAggregationTests {
City braunschweig = new City("Braunschweig", 102);
City weinheim = new City("Weinheim", 103);
StepVerifier.create(reactiveMongoTemplate.insertAll(Arrays.asList(dresden, linz, braunschweig, weinheim)))
reactiveMongoTemplate.insertAll(Arrays.asList(dresden, linz, braunschweig, weinheim)).as(StepVerifier::create)
.expectNextCount(4).verifyComplete();
Aggregation agg = newAggregation( //
out(OUTPUT_COLLECTION));
StepVerifier.create(reactiveMongoTemplate.aggregate(agg, "city", City.class)).expectNextCount(4).verifyComplete();
StepVerifier.create(reactiveMongoTemplate.find(new Query(), City.class, OUTPUT_COLLECTION)).expectNextCount(4)
reactiveMongoTemplate.aggregate(agg, "city", City.class).as(StepVerifier::create).expectNextCount(4)
.verifyComplete();
reactiveMongoTemplate.find(new Query(), City.class, OUTPUT_COLLECTION).as(StepVerifier::create).expectNextCount(4)
.verifyComplete();
}

View File

@@ -60,11 +60,10 @@ public class ReactiveMapReduceTests {
@Before
public void setUp() {
StepVerifier
.create(template.dropCollection(ValueObject.class) //
.mergeWith(template.dropCollection("jmr1")) //
.mergeWith(template.dropCollection("jmr1_out")) //
.mergeWith(Mono.from(factory.getMongoDatabase("reactive-jrm1-out-db").drop()).then())) //
template.dropCollection(ValueObject.class) //
.mergeWith(template.dropCollection("jmr1")) //
.mergeWith(template.dropCollection("jmr1_out")) //
.mergeWith(Mono.from(factory.getMongoDatabase("reactive-jrm1-out-db").drop()).then()).as(StepVerifier::create) //
.verifyComplete();
}
@@ -73,9 +72,10 @@ public class ReactiveMapReduceTests {
createMapReduceData();
StepVerifier
.create(template.mapReduce(new Query(), Person.class, "jmr1", ValueObject.class, mapFunction, reduceFunction,
MapReduceOptions.options()).buffer(4)) //
template
.mapReduce(new Query(), Person.class, "jmr1", ValueObject.class, mapFunction, reduceFunction,
MapReduceOptions.options())
.buffer(4).as(StepVerifier::create) //
.consumeNextWith(result -> {
assertThat(result).containsExactlyInAnyOrder(new ValueObject("a", 1), new ValueObject("b", 2),
new ValueObject("c", 2), new ValueObject("d", 1));
@@ -88,13 +88,12 @@ public class ReactiveMapReduceTests {
createMapReduceData();
StepVerifier
.create(template.mapReduce(new Query(), Person.class, "jmr1", ValueObject.class, mapFunction, reduceFunction, //
MapReduceOptions.options().outputCollection("mapreduceout"))) //
template.mapReduce(new Query(), Person.class, "jmr1", ValueObject.class, mapFunction, reduceFunction, //
MapReduceOptions.options().outputCollection("mapreduceout")).as(StepVerifier::create) //
.expectNextCount(4) //
.verifyComplete();
StepVerifier.create(template.find(new Query(), ValueObject.class, "mapreduceout").buffer(4)) //
template.find(new Query(), ValueObject.class, "mapreduceout").buffer(4).as(StepVerifier::create) //
.consumeNextWith(result -> {
assertThat(result).containsExactlyInAnyOrder(new ValueObject("a", 1), new ValueObject("b", 2),
new ValueObject("c", 2), new ValueObject("d", 1));
@@ -107,9 +106,10 @@ public class ReactiveMapReduceTests {
createMapReduceData();
StepVerifier
.create(template.mapReduce(query(where("x").ne(new String[] { "a", "b" })), ValueObject.class, "jmr1",
ValueObject.class, mapFunction, reduceFunction, MapReduceOptions.options()).buffer(4)) //
template
.mapReduce(query(where("x").ne(new String[] { "a", "b" })), ValueObject.class, "jmr1", ValueObject.class,
mapFunction, reduceFunction, MapReduceOptions.options())
.buffer(4).as(StepVerifier::create) //
.consumeNextWith(result -> {
assertThat(result).containsExactlyInAnyOrder(new ValueObject("b", 1), new ValueObject("c", 2),
new ValueObject("d", 1));
@@ -122,12 +122,13 @@ public class ReactiveMapReduceTests {
createMapReduceData();
StepVerifier
.create(template.mapReduce(new Query(), ValueObject.class, "jmr1", ValueObject.class, mapFunction,
reduceFunction, MapReduceOptions.options().outputCollection("jmr1_out")))
template
.mapReduce(new Query(), ValueObject.class, "jmr1", ValueObject.class, mapFunction, reduceFunction,
MapReduceOptions.options().outputCollection("jmr1_out"))
.as(StepVerifier::create)
.expectNextCount(4).verifyComplete();
StepVerifier.create(template.find(new Query(), ValueObject.class, "jmr1_out").buffer(4)) //
template.find(new Query(), ValueObject.class, "jmr1_out").buffer(4).as(StepVerifier::create) //
.consumeNextWith(result -> {
assertThat(result).containsExactlyInAnyOrder(new ValueObject("a", 1), new ValueObject("b", 2),
new ValueObject("c", 2), new ValueObject("d", 1));
@@ -140,9 +141,10 @@ public class ReactiveMapReduceTests {
createMapReduceData();
StepVerifier
.create(template.mapReduce(new Query(), ValueObject.class, "jmr1", ValueObject.class, mapFunction,
reduceFunction, MapReduceOptions.options().outputDatabase("reactive-jrm1-out-db").outputCollection("jmr1_out")))
template
.mapReduce(new Query(), ValueObject.class, "jmr1", ValueObject.class, mapFunction, reduceFunction,
MapReduceOptions.options().outputDatabase("reactive-jrm1-out-db").outputCollection("jmr1_out"))
.as(StepVerifier::create)
.expectNextCount(4).verifyComplete();
Flux.from(factory.getMongoDatabase("reactive-jrm1-out-db").listCollectionNames()).buffer(10)
@@ -154,9 +156,10 @@ public class ReactiveMapReduceTests {
createMapReduceData();
StepVerifier
.create(template.mapReduce(query(where("values").ne(new String[] { "a", "b" })), MappedFieldsValueObject.class,
"jmr1", ValueObject.class, mapFunction, reduceFunction, MapReduceOptions.options()).buffer(4)) //
template
.mapReduce(query(where("values").ne(new String[] { "a", "b" })), MappedFieldsValueObject.class, "jmr1",
ValueObject.class, mapFunction, reduceFunction, MapReduceOptions.options())
.buffer(4).as(StepVerifier::create) //
.consumeNextWith(result -> {
assertThat(result).containsExactlyInAnyOrder(new ValueObject("b", 1), new ValueObject("c", 2),
new ValueObject("d", 1));
@@ -169,9 +172,10 @@ public class ReactiveMapReduceTests {
createMapReduceData();
StepVerifier
.create(template.mapReduce(query(where("values").ne(new String[] { "a", "b" })), MappedFieldsValueObject.class,
ValueObject.class, mapFunction, reduceFunction, MapReduceOptions.options()).buffer(4)) //
template
.mapReduce(query(where("values").ne(new String[] { "a", "b" })), MappedFieldsValueObject.class,
ValueObject.class, mapFunction, reduceFunction, MapReduceOptions.options())
.buffer(4).as(StepVerifier::create) //
.consumeNextWith(result -> {
assertThat(result).containsExactlyInAnyOrder(new ValueObject("b", 1), new ValueObject("c", 2),
new ValueObject("d", 1));

View File

@@ -73,7 +73,7 @@ public class ReactiveMongoJsonSchemaTests {
@Before
public void setUp() {
StepVerifier.create(template.dropCollection(Person.class)).verifyComplete();
template.dropCollection(Person.class).as(StepVerifier::create).verifyComplete();
}
@Test // DATAMONGO-1835
@@ -88,7 +88,7 @@ public class ReactiveMongoJsonSchemaTests {
).build();
StepVerifier.create(template.createCollection(Person.class, CollectionOptions.empty().schema(schema)))
template.createCollection(Person.class, CollectionOptions.empty().schema(schema)).as(StepVerifier::create)
.expectNextCount(1).verifyComplete();
Document $jsonSchema = new MongoJsonSchemaMapper(template.getConverter()).mapSchema(schema.toDocument(),

View File

@@ -73,7 +73,7 @@ public class ConvertingReactiveMongoRepositoryTests {
@Before
public void setUp() {
StepVerifier.create(reactiveRepository.deleteAll()).verifyComplete();
reactiveRepository.deleteAll().as(StepVerifier::create).verifyComplete();
dave = new ReactivePerson("Dave", "Matthews", 42);
oliver = new ReactivePerson("Oliver August", "Matthews", 4);
@@ -83,14 +83,15 @@ public class ConvertingReactiveMongoRepositoryTests {
leroi = new ReactivePerson("Leroi", "Moore", 41);
alicia = new ReactivePerson("Alicia", "Keys", 30);
StepVerifier.create(reactiveRepository.saveAll(Arrays.asList(oliver, dave, carter, boyd, stefan, leroi, alicia))) //
reactiveRepository.saveAll(Arrays.asList(oliver, dave, carter, boyd, stefan, leroi, alicia))
.as(StepVerifier::create) //
.expectNextCount(7) //
.verifyComplete();
}
@Test // DATAMONGO-1444
public void reactiveStreamsMethodsShouldWork() {
StepVerifier.create(reactivePersonRepostitory.existsById(dave.getId())).expectNext(true).verifyComplete();
reactivePersonRepostitory.existsById(dave.getId()).as(StepVerifier::create).expectNext(true).verifyComplete();
}
@Test // DATAMONGO-1444
@@ -99,7 +100,7 @@ public class ConvertingReactiveMongoRepositoryTests {
}
@Test // DATAMONGO-1444
public void simpleRxJava1MethodsShouldWork() throws Exception {
public void simpleRxJava1MethodsShouldWork() {
rxJava1PersonRepostitory.existsById(dave.getId()) //
.test() //
@@ -110,7 +111,7 @@ public class ConvertingReactiveMongoRepositoryTests {
}
@Test // DATAMONGO-1444
public void existsWithSingleRxJava1IdMethodsShouldWork() throws Exception {
public void existsWithSingleRxJava1IdMethodsShouldWork() {
rxJava1PersonRepostitory.existsById(Single.just(dave.getId())) //
.test() //
@@ -121,7 +122,7 @@ public class ConvertingReactiveMongoRepositoryTests {
}
@Test // DATAMONGO-1444
public void singleRxJava1QueryMethodShouldWork() throws Exception {
public void singleRxJava1QueryMethodShouldWork() {
rxJava1PersonRepostitory.findByFirstnameAndLastname(dave.getFirstname(), dave.getLastname()) //
.test() //
@@ -132,7 +133,7 @@ public class ConvertingReactiveMongoRepositoryTests {
}
@Test // DATAMONGO-1444
public void singleProjectedRxJava1QueryMethodShouldWork() throws Exception {
public void singleProjectedRxJava1QueryMethodShouldWork() {
List<ProjectedPerson> people = rxJava1PersonRepostitory.findProjectedByLastname(carter.getLastname()) //
.test() //
@@ -147,7 +148,7 @@ public class ConvertingReactiveMongoRepositoryTests {
}
@Test // DATAMONGO-1444
public void observableRxJava1QueryMethodShouldWork() throws Exception {
public void observableRxJava1QueryMethodShouldWork() {
rxJava1PersonRepostitory.findByLastname(boyd.getLastname()) //
.test() //
@@ -159,7 +160,7 @@ public class ConvertingReactiveMongoRepositoryTests {
}
@Test // DATAMONGO-1610
public void simpleRxJava2MethodsShouldWork() throws Exception {
public void simpleRxJava2MethodsShouldWork() {
TestObserver<Boolean> testObserver = rxJava2PersonRepostitory.existsById(dave.getId()).test();
@@ -170,7 +171,7 @@ public class ConvertingReactiveMongoRepositoryTests {
}
@Test // DATAMONGO-1610
public void existsWithSingleRxJava2IdMethodsShouldWork() throws Exception {
public void existsWithSingleRxJava2IdMethodsShouldWork() {
TestObserver<Boolean> testObserver = rxJava2PersonRepostitory.existsById(io.reactivex.Single.just(dave.getId()))
.test();
@@ -182,7 +183,7 @@ public class ConvertingReactiveMongoRepositoryTests {
}
@Test // DATAMONGO-1610
public void flowableRxJava2QueryMethodShouldWork() throws Exception {
public void flowableRxJava2QueryMethodShouldWork() {
io.reactivex.subscribers.TestSubscriber<ReactivePerson> testSubscriber = rxJava2PersonRepostitory
.findByFirstnameAndLastname(dave.getFirstname(), dave.getLastname()).test();
@@ -194,7 +195,7 @@ public class ConvertingReactiveMongoRepositoryTests {
}
@Test // DATAMONGO-1610
public void singleProjectedRxJava2QueryMethodShouldWork() throws Exception {
public void singleProjectedRxJava2QueryMethodShouldWork() {
TestObserver<ProjectedPerson> testObserver = rxJava2PersonRepostitory
.findProjectedByLastname(Maybe.just(carter.getLastname())).test();
@@ -210,7 +211,7 @@ public class ConvertingReactiveMongoRepositoryTests {
}
@Test // DATAMONGO-1610
public void observableProjectedRxJava2QueryMethodShouldWork() throws Exception {
public void observableProjectedRxJava2QueryMethodShouldWork() {
TestObserver<ProjectedPerson> testObserver = rxJava2PersonRepostitory
.findProjectedByLastname(Single.just(carter.getLastname())).test();
@@ -226,7 +227,7 @@ public class ConvertingReactiveMongoRepositoryTests {
}
@Test // DATAMONGO-1610
public void maybeRxJava2QueryMethodShouldWork() throws Exception {
public void maybeRxJava2QueryMethodShouldWork() {
TestObserver<ReactivePerson> testObserver = rxJava2PersonRepostitory.findByLastname(boyd.getLastname()).test();
@@ -251,7 +252,7 @@ public class ConvertingReactiveMongoRepositoryTests {
@Test // DATAMONGO-1444
public void shouldFindOneBySingleOfLastName() {
StepVerifier.create(reactiveRepository.findByLastname(Single.just(carter.getLastname()))) //
reactiveRepository.findByLastname(Single.just(carter.getLastname())).as(StepVerifier::create) //
.expectNext(carter) //
.verifyComplete();
}
@@ -259,7 +260,8 @@ public class ConvertingReactiveMongoRepositoryTests {
@Test // DATAMONGO-1444
public void shouldFindByObservableOfLastNameIn() {
StepVerifier.create(reactiveRepository.findByLastnameIn(Observable.just(carter.getLastname(), dave.getLastname()))) //
reactiveRepository.findByLastnameIn(Observable.just(carter.getLastname(), dave.getLastname()))
.as(StepVerifier::create) //
.expectNextCount(3) //
.verifyComplete();
}

View File

@@ -120,29 +120,30 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
alicia = new Person("Alicia", "Keys", 30, Sex.FEMALE);
StepVerifier.create(repository.saveAll(Arrays.asList(oliver, dave, carter, boyd, stefan, leroi, alicia))) //
repository.saveAll(Arrays.asList(oliver, dave, carter, boyd, stefan, leroi, alicia)).as(StepVerifier::create) //
.expectNextCount(7) //
.verifyComplete();
}
@Test // DATAMONGO-1444
public void shouldFindByLastName() {
StepVerifier.create(repository.findByLastname(dave.getLastname())).expectNextCount(2).verifyComplete();
repository.findByLastname(dave.getLastname()).as(StepVerifier::create).expectNextCount(2).verifyComplete();
}
@Test // DATAMONGO-1444
public void shouldFindOneByLastName() {
StepVerifier.create(repository.findOneByLastname(carter.getLastname())).expectNext(carter).verifyComplete();
repository.findOneByLastname(carter.getLastname()).as(StepVerifier::create).expectNext(carter).verifyComplete();
}
@Test // DATAMONGO-1444
public void shouldFindOneByPublisherOfLastName() {
StepVerifier.create(repository.findByLastname(Mono.just(carter.getLastname()))).expectNext(carter).verifyComplete();
repository.findByLastname(Mono.just(carter.getLastname())).as(StepVerifier::create).expectNext(carter)
.verifyComplete();
}
@Test // DATAMONGO-1444
public void shouldFindByPublisherOfLastNameIn() {
StepVerifier.create(repository.findByLastnameIn(Flux.just(carter.getLastname(), dave.getLastname()))) //
repository.findByLastnameIn(Flux.just(carter.getLastname(), dave.getLastname())).as(StepVerifier::create) //
.expectNextCount(3) //
.verifyComplete();
}
@@ -150,8 +151,8 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
@Test // DATAMONGO-1444
public void shouldFindByPublisherOfLastNameInAndAgeGreater() {
StepVerifier
.create(repository.findByLastnameInAndAgeGreaterThan(Flux.just(carter.getLastname(), dave.getLastname()), 41)) //
repository.findByLastnameInAndAgeGreaterThan(Flux.just(carter.getLastname(), dave.getLastname()), 41)
.as(StepVerifier::create) //
.expectNextCount(2) //
.verifyComplete();
}
@@ -159,7 +160,7 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
@Test // DATAMONGO-1444
public void shouldFindUsingPublishersInStringQuery() {
StepVerifier.create(repository.findStringQuery(Flux.just("Beauford", "Matthews"), Mono.just(41))) //
repository.findStringQuery(Flux.just("Beauford", "Matthews"), Mono.just(41)).as(StepVerifier::create) //
.expectNextCount(2) //
.verifyComplete();
}
@@ -167,11 +168,11 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
@Test // DATAMONGO-1444
public void shouldFindByLastNameAndSort() {
StepVerifier.create(repository.findByLastname("Matthews", Sort.by(ASC, "age"))) //
repository.findByLastname("Matthews", Sort.by(ASC, "age")).as(StepVerifier::create) //
.expectNext(oliver, dave) //
.verifyComplete();
StepVerifier.create(repository.findByLastname("Matthews", Sort.by(DESC, "age"))) //
repository.findByLastname("Matthews", Sort.by(DESC, "age")).as(StepVerifier::create) //
.expectNext(dave, oliver) //
.verifyComplete();
}
@@ -179,13 +180,14 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
@Test // DATAMONGO-1444
public void shouldUseTailableCursor() throws Exception {
StepVerifier.create(template.dropCollection(Capped.class) //
template.dropCollection(Capped.class) //
.then(template.createCollection(Capped.class, //
CollectionOptions.empty().size(1000).maxDocuments(100).capped()))) //
CollectionOptions.empty().size(1000).maxDocuments(100).capped()))
.as(StepVerifier::create) //
.expectNextCount(1) //
.verifyComplete();
StepVerifier.create(template.insert(new Capped("value", Math.random()))).expectNextCount(1).verifyComplete();
template.insert(new Capped("value", Math.random())).as(StepVerifier::create).expectNextCount(1).verifyComplete();
BlockingQueue<Capped> documents = new LinkedBlockingDeque<>(100);
@@ -193,7 +195,7 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
assertThat(documents.poll(5, TimeUnit.SECONDS)).isNotNull();
StepVerifier.create(template.insert(new Capped("value", Math.random()))).expectNextCount(1).verifyComplete();
template.insert(new Capped("value", Math.random())).as(StepVerifier::create).expectNextCount(1).verifyComplete();
assertThat(documents.poll(5, TimeUnit.SECONDS)).isNotNull();
assertThat(documents).isEmpty();
@@ -203,13 +205,14 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
@Test // DATAMONGO-1444
public void shouldUseTailableCursorWithProjection() throws Exception {
StepVerifier.create(template.dropCollection(Capped.class) //
template.dropCollection(Capped.class) //
.then(template.createCollection(Capped.class, //
CollectionOptions.empty().size(1000).maxDocuments(100).capped()))) //
CollectionOptions.empty().size(1000).maxDocuments(100).capped()))
.as(StepVerifier::create) //
.expectNextCount(1) //
.verifyComplete();
StepVerifier.create(template.insert(new Capped("value", Math.random()))).expectNextCount(1).verifyComplete();
template.insert(new Capped("value", Math.random())).as(StepVerifier::create).expectNextCount(1).verifyComplete();
BlockingQueue<CappedProjection> documents = new LinkedBlockingDeque<>(100);
@@ -219,7 +222,7 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
assertThat(projection1).isNotNull();
assertThat(projection1.getRandom()).isNotEqualTo(0);
StepVerifier.create(template.insert(new Capped("value", Math.random()))).expectNextCount(1).verifyComplete();
template.insert(new Capped("value", Math.random())).as(StepVerifier::create).expectNextCount(1).verifyComplete();
CappedProjection projection2 = documents.poll(5, TimeUnit.SECONDS);
assertThat(projection2).isNotNull();
@@ -248,9 +251,9 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
StepVerifier.create(repository.save(dave)).expectNextCount(1).verifyComplete();
repository.save(dave).as(StepVerifier::create).expectNextCount(1).verifyComplete();
StepVerifier.create(repository.findByLocationWithin(new Circle(-78.99171, 45.738868, 170))) //
repository.findByLocationWithin(new Circle(-78.99171, 45.738868, 170)).as(StepVerifier::create) //
.expectNext(dave) //
.verifyComplete();
}
@@ -260,10 +263,10 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
StepVerifier.create(repository.save(dave)).expectNextCount(1).verifyComplete();
repository.save(dave).as(StepVerifier::create).expectNextCount(1).verifyComplete();
StepVerifier.create(repository.findByLocationWithin(new Circle(-78.99171, 45.738868, 170), //
PageRequest.of(0, 10))) //
repository.findByLocationWithin(new Circle(-78.99171, 45.738868, 170), //
PageRequest.of(0, 10)).as(StepVerifier::create) //
.expectNext(dave) //
.verifyComplete();
}
@@ -273,11 +276,10 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
StepVerifier.create(repository.save(dave)).expectNextCount(1).verifyComplete();
repository.save(dave).as(StepVerifier::create).expectNextCount(1).verifyComplete();
StepVerifier.create(repository.findByLocationNear(new Point(-73.99, 40.73), //
new Distance(2000, Metrics.KILOMETERS)) //
).consumeNextWith(actual -> {
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);
@@ -285,15 +287,18 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
}
@Test // DATAMONGO-1444
public void findsPeoplePageableGeoresultByLocationWithinBox() {
public void findsPeoplePageableGeoresultByLocationWithinBox() throws InterruptedException {
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
StepVerifier.create(repository.save(dave)).expectNextCount(1).verifyComplete();
repository.save(dave).as(StepVerifier::create).expectNextCount(1).verifyComplete();
StepVerifier.create(repository.findByLocationNear(new Point(-73.99, 40.73), //
// Allow for index creation
Thread.sleep(500);
repository.findByLocationNear(new Point(-73.99, 40.73), //
new Distance(2000, Metrics.KILOMETERS), //
PageRequest.of(0, 10))) //
PageRequest.of(0, 10)).as(StepVerifier::create) //
.consumeNextWith(actual -> {
assertThat(actual.getDistance().getValue()).isCloseTo(1, offset(1d));
@@ -302,32 +307,35 @@ public class ReactiveMongoRepositoryTests implements BeanClassLoaderAware, BeanF
}
@Test // DATAMONGO-1444
public void findsPeopleByLocationWithinBox() {
public void findsPeopleByLocationWithinBox() throws InterruptedException {
Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point);
StepVerifier.create(repository.save(dave)).expectNextCount(1).verifyComplete();
repository.save(dave).as(StepVerifier::create).expectNextCount(1).verifyComplete();
StepVerifier.create(repository.findPersonByLocationNear(new Point(-73.99, 40.73), //
new Distance(2000, Metrics.KILOMETERS))) //
// 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();
}
@Test // DATAMONGO-1865
public void shouldErrorOnFindOneWithNonUniqueResult() {
StepVerifier.create(repository.findOneByLastname(dave.getLastname()))
repository.findOneByLastname(dave.getLastname()).as(StepVerifier::create)
.expectError(IncorrectResultSizeDataAccessException.class).verify();
}
@Test // DATAMONGO-1865
public void shouldReturnFirstFindFirstWithMoreResults() {
StepVerifier.create(repository.findFirstByLastname(dave.getLastname())).expectNextCount(1).verifyComplete();
repository.findFirstByLastname(dave.getLastname()).as(StepVerifier::create).expectNextCount(1).verifyComplete();
}
@Test // DATAMONGO-2030
public void shouldReturnExistsBy() {
StepVerifier.create(repository.existsByLastname(dave.getLastname())).expectNext(true).verifyComplete();
repository.existsByLastname(dave.getLastname()).as(StepVerifier::create).expectNext(true).verifyComplete();
}
@Test // DATAMONGO-1979

View File

@@ -90,7 +90,7 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
repository = factory.getRepository(ReactivePersonRepostitory.class);
StepVerifier.create(repository.deleteAll()).verifyComplete();
repository.deleteAll().as(StepVerifier::create).verifyComplete();
dave = new ReactivePerson("Dave", "Matthews", 42);
oliver = new ReactivePerson("Oliver August", "Matthews", 4);
@@ -100,102 +100,103 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
leroi = new ReactivePerson("Leroi", "Moore", 41);
alicia = new ReactivePerson("Alicia", "Keys", 30);
StepVerifier.create(repository.saveAll(Arrays.asList(oliver, dave, carter, boyd, stefan, leroi, alicia))) //
repository.saveAll(Arrays.asList(oliver, dave, carter, boyd, stefan, leroi, alicia)).as(StepVerifier::create) //
.expectNextCount(7) //
.verifyComplete();
}
@Test // DATAMONGO-1444
public void existsByIdShouldReturnTrueForExistingObject() {
StepVerifier.create(repository.existsById(dave.id)).expectNext(true).verifyComplete();
repository.existsById(dave.id).as(StepVerifier::create).expectNext(true).verifyComplete();
}
@Test // DATAMONGO-1444
public void existsByIdShouldReturnFalseForAbsentObject() {
StepVerifier.create(repository.existsById("unknown")).expectNext(false).verifyComplete();
repository.existsById("unknown").as(StepVerifier::create).expectNext(false).verifyComplete();
}
@Test // DATAMONGO-1444
public void existsByMonoOfIdShouldReturnTrueForExistingObject() {
StepVerifier.create(repository.existsById(Mono.just(dave.id))).expectNext(true).verifyComplete();
repository.existsById(Mono.just(dave.id)).as(StepVerifier::create).expectNext(true).verifyComplete();
}
@Test // DATAMONGO-1712
public void existsByFluxOfIdShouldReturnTrueForExistingObject() {
StepVerifier.create(repository.existsById(Flux.just(dave.id, oliver.id))).expectNext(true).verifyComplete();
repository.existsById(Flux.just(dave.id, oliver.id)).as(StepVerifier::create).expectNext(true).verifyComplete();
}
@Test // DATAMONGO-1444
public void existsByEmptyMonoOfIdShouldReturnEmptyMono() {
StepVerifier.create(repository.existsById(Mono.empty())).verifyComplete();
repository.existsById(Mono.empty()).as(StepVerifier::create).verifyComplete();
}
@Test // DATAMONGO-1444
public void findByIdShouldReturnObject() {
StepVerifier.create(repository.findById(dave.id)).expectNext(dave).verifyComplete();
repository.findById(dave.id).as(StepVerifier::create).expectNext(dave).verifyComplete();
}
@Test // DATAMONGO-1444
public void findByIdShouldCompleteWithoutValueForAbsentObject() {
StepVerifier.create(repository.findById("unknown")).verifyComplete();
repository.findById("unknown").as(StepVerifier::create).verifyComplete();
}
@Test // DATAMONGO-1444
public void findByIdByMonoOfIdShouldReturnTrueForExistingObject() {
StepVerifier.create(repository.findById(Mono.just(dave.id))).expectNext(dave).verifyComplete();
repository.findById(Mono.just(dave.id)).as(StepVerifier::create).expectNext(dave).verifyComplete();
}
@Test // DATAMONGO-1712
public void findByIdByFluxOfIdShouldReturnTrueForExistingObject() {
StepVerifier.create(repository.findById(Flux.just(dave.id, oliver.id))).expectNext(dave).verifyComplete();
repository.findById(Flux.just(dave.id, oliver.id)).as(StepVerifier::create).expectNext(dave).verifyComplete();
}
@Test // DATAMONGO-1444
public void findByIdByEmptyMonoOfIdShouldReturnEmptyMono() {
StepVerifier.create(repository.findById(Mono.empty())).verifyComplete();
repository.findById(Mono.empty()).as(StepVerifier::create).verifyComplete();
}
@Test // DATAMONGO-1444
public void findAllShouldReturnAllResults() {
StepVerifier.create(repository.findAll()).expectNextCount(7).verifyComplete();
repository.findAll().as(StepVerifier::create).expectNextCount(7).verifyComplete();
}
@Test // DATAMONGO-1444
public void findAllByIterableOfIdShouldReturnResults() {
StepVerifier.create(repository.findAllById(Arrays.asList(dave.id, boyd.id))).expectNextCount(2).verifyComplete();
repository.findAllById(Arrays.asList(dave.id, boyd.id)).as(StepVerifier::create).expectNextCount(2)
.verifyComplete();
}
@Test // DATAMONGO-1444
public void findAllByPublisherOfIdShouldReturnResults() {
StepVerifier.create(repository.findAllById(Flux.just(dave.id, boyd.id))).expectNextCount(2).verifyComplete();
repository.findAllById(Flux.just(dave.id, boyd.id)).as(StepVerifier::create).expectNextCount(2).verifyComplete();
}
@Test // DATAMONGO-1444
public void findAllByEmptyPublisherOfIdShouldReturnResults() {
StepVerifier.create(repository.findAllById(Flux.empty())).verifyComplete();
repository.findAllById(Flux.empty()).as(StepVerifier::create).verifyComplete();
}
@Test // DATAMONGO-1444
public void findAllWithSortShouldReturnResults() {
StepVerifier.create(repository.findAll(Sort.by(new Order(Direction.ASC, "age")))) //
repository.findAll(Sort.by(new Order(Direction.ASC, "age"))).as(StepVerifier::create) //
.expectNextCount(7) //
.verifyComplete();
}
@Test // DATAMONGO-1444
public void countShouldReturnNumberOfRecords() {
StepVerifier.create(repository.count()).expectNext(7L).verifyComplete();
repository.count().as(StepVerifier::create).expectNext(7L).verifyComplete();
}
@Test // DATAMONGO-1444
public void insertEntityShouldInsertEntity() {
StepVerifier.create(repository.deleteAll()).verifyComplete();
repository.deleteAll().as(StepVerifier::create).verifyComplete();
ReactivePerson person = new ReactivePerson("Homer", "Simpson", 36);
StepVerifier.create(repository.insert(person)).expectNext(person).verifyComplete();
repository.insert(person).as(StepVerifier::create).expectNext(person).verifyComplete();
assertThat(person.getId(), is(notNullValue()));
}
@@ -213,13 +214,13 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
@Test // DATAMONGO-1444
public void insertIterableOfEntitiesShouldInsertEntity() {
StepVerifier.create(repository.deleteAll()).verifyComplete();
repository.deleteAll().as(StepVerifier::create).verifyComplete();
dave.setId(null);
oliver.setId(null);
boyd.setId(null);
StepVerifier.create(repository.insert(Arrays.asList(dave, oliver, boyd))) //
repository.insert(Arrays.asList(dave, oliver, boyd)).as(StepVerifier::create) //
.expectNext(dave, oliver, boyd) //
.verifyComplete();
@@ -231,13 +232,13 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
@Test // DATAMONGO-1444
public void insertPublisherOfEntitiesShouldInsertEntity() {
StepVerifier.create(repository.deleteAll()).verifyComplete();
repository.deleteAll().as(StepVerifier::create).verifyComplete();
dave.setId(null);
oliver.setId(null);
boyd.setId(null);
StepVerifier.create(repository.insert(Flux.just(dave, oliver, boyd))).expectNextCount(3).verifyComplete();
repository.insert(Flux.just(dave, oliver, boyd)).as(StepVerifier::create).expectNextCount(3).verifyComplete();
assertThat(dave.getId(), is(notNullValue()));
assertThat(oliver.getId(), is(notNullValue()));
@@ -250,11 +251,11 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
dave.setFirstname("Hello, Dave");
dave.setLastname("Bowman");
StepVerifier.create(repository.save(dave)).expectNext(dave).verifyComplete();
repository.save(dave).as(StepVerifier::create).expectNext(dave).verifyComplete();
StepVerifier.create(repository.findByLastname("Matthews")).expectNext(oliver).verifyComplete();
repository.findByLastname("Matthews").as(StepVerifier::create).expectNext(oliver).verifyComplete();
StepVerifier.create(repository.findById(dave.id)).consumeNextWith(actual -> {
repository.findById(dave.id).as(StepVerifier::create).consumeNextWith(actual -> {
assertThat(actual.getFirstname(), is(equalTo(dave.getFirstname())));
assertThat(actual.getLastname(), is(equalTo(dave.getLastname())));
@@ -266,9 +267,9 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
ReactivePerson person = new ReactivePerson("Homer", "Simpson", 36);
StepVerifier.create(repository.save(person)).expectNext(person).verifyComplete();
repository.save(person).as(StepVerifier::create).expectNext(person).verifyComplete();
StepVerifier.create(repository.findById(person.id)).consumeNextWith(actual -> {
repository.findById(person.id).as(StepVerifier::create).consumeNextWith(actual -> {
assertThat(actual.getFirstname(), is(equalTo(person.getFirstname())));
assertThat(actual.getLastname(), is(equalTo(person.getLastname())));
@@ -278,13 +279,13 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
@Test // DATAMONGO-1444
public void saveIterableOfNewEntitiesShouldInsertEntity() {
StepVerifier.create(repository.deleteAll()).verifyComplete();
repository.deleteAll().as(StepVerifier::create).verifyComplete();
dave.setId(null);
oliver.setId(null);
boyd.setId(null);
StepVerifier.create(repository.saveAll(Arrays.asList(dave, oliver, boyd))).expectNextCount(3).verifyComplete();
repository.saveAll(Arrays.asList(dave, oliver, boyd)).as(StepVerifier::create).expectNextCount(3).verifyComplete();
assertThat(dave.getId(), is(notNullValue()));
assertThat(oliver.getId(), is(notNullValue()));
@@ -299,24 +300,24 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
dave.setFirstname("Hello, Dave");
dave.setLastname("Bowman");
StepVerifier.create(repository.saveAll(Arrays.asList(person, dave))).expectNextCount(2).verifyComplete();
repository.saveAll(Arrays.asList(person, dave)).as(StepVerifier::create).expectNextCount(2).verifyComplete();
StepVerifier.create(repository.findById(dave.id)).expectNext(dave).verifyComplete();
repository.findById(dave.id).as(StepVerifier::create).expectNext(dave).verifyComplete();
assertThat(person.id, is(notNullValue()));
StepVerifier.create(repository.findById(person.id)).expectNext(person).verifyComplete();
repository.findById(person.id).as(StepVerifier::create).expectNext(person).verifyComplete();
}
@Test // DATAMONGO-1444
public void savePublisherOfEntitiesShouldInsertEntity() {
StepVerifier.create(repository.deleteAll()).verifyComplete();
repository.deleteAll().as(StepVerifier::create).verifyComplete();
dave.setId(null);
oliver.setId(null);
boyd.setId(null);
StepVerifier.create(repository.saveAll(Flux.just(dave, oliver, boyd))).expectNextCount(3).verifyComplete();
repository.saveAll(Flux.just(dave, oliver, boyd)).as(StepVerifier::create).expectNextCount(3).verifyComplete();
assertThat(dave.getId(), is(notNullValue()));
assertThat(oliver.getId(), is(notNullValue()));
@@ -326,63 +327,63 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
@Test // DATAMONGO-1444
public void deleteAllShouldRemoveEntities() {
StepVerifier.create(repository.deleteAll()).verifyComplete();
repository.deleteAll().as(StepVerifier::create).verifyComplete();
StepVerifier.create(repository.findAll()).verifyComplete();
repository.findAll().as(StepVerifier::create).verifyComplete();
}
@Test // DATAMONGO-1444
public void deleteByIdShouldRemoveEntity() {
StepVerifier.create(repository.deleteById(dave.id)).verifyComplete();
repository.deleteById(dave.id).as(StepVerifier::create).verifyComplete();
StepVerifier.create(repository.findById(dave.id)).verifyComplete();
repository.findById(dave.id).as(StepVerifier::create).verifyComplete();
}
@Test // DATAMONGO-1712
public void deleteByIdUsingMonoShouldRemoveEntity() {
StepVerifier.create(repository.deleteById(Mono.just(dave.id))).verifyComplete();
repository.deleteById(Mono.just(dave.id)).as(StepVerifier::create).verifyComplete();
StepVerifier.create(repository.existsById(dave.id)).expectNext(false).verifyComplete();
repository.existsById(dave.id).as(StepVerifier::create).expectNext(false).verifyComplete();
}
@Test // DATAMONGO-1712
public void deleteByIdUsingFluxShouldRemoveEntity() {
StepVerifier.create(repository.deleteById(Flux.just(dave.id, oliver.id))).verifyComplete();
repository.deleteById(Flux.just(dave.id, oliver.id)).as(StepVerifier::create).verifyComplete();
StepVerifier.create(repository.existsById(dave.id)).expectNext(false).verifyComplete();
StepVerifier.create(repository.existsById(oliver.id)).expectNext(true).verifyComplete();
repository.existsById(dave.id).as(StepVerifier::create).expectNext(false).verifyComplete();
repository.existsById(oliver.id).as(StepVerifier::create).expectNext(true).verifyComplete();
}
@Test // DATAMONGO-1444
public void deleteShouldRemoveEntity() {
StepVerifier.create(repository.delete(dave)).verifyComplete();
repository.delete(dave).as(StepVerifier::create).verifyComplete();
StepVerifier.create(repository.findById(dave.id)).verifyComplete();
repository.findById(dave.id).as(StepVerifier::create).verifyComplete();
}
@Test // DATAMONGO-1444
public void deleteIterableOfEntitiesShouldRemoveEntities() {
StepVerifier.create(repository.deleteAll(Arrays.asList(dave, boyd))).verifyComplete();
repository.deleteAll(Arrays.asList(dave, boyd)).as(StepVerifier::create).verifyComplete();
StepVerifier.create(repository.findById(boyd.id)).verifyComplete();
repository.findById(boyd.id).as(StepVerifier::create).verifyComplete();
StepVerifier.create(repository.findByLastname("Matthews")).expectNext(oliver).verifyComplete();
repository.findByLastname("Matthews").as(StepVerifier::create).expectNext(oliver).verifyComplete();
}
@Test // DATAMONGO-1444
public void deletePublisherOfEntitiesShouldRemoveEntities() {
StepVerifier.create(repository.deleteAll(Flux.just(dave, boyd))).verifyComplete();
repository.deleteAll(Flux.just(dave, boyd)).as(StepVerifier::create).verifyComplete();
StepVerifier.create(repository.findById(boyd.id)).verifyComplete();
repository.findById(boyd.id).as(StepVerifier::create).verifyComplete();
StepVerifier.create(repository.findByLastname("Matthews")).expectNext(oliver).verifyComplete();
repository.findByLastname("Matthews").as(StepVerifier::create).expectNext(oliver).verifyComplete();
}
@Test // DATAMONGO-1619
@@ -390,7 +391,7 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
Example<ReactivePerson> example = Example.of(dave);
StepVerifier.create(repository.findOne(example)).expectNext(dave).verifyComplete();
repository.findOne(example).as(StepVerifier::create).expectNext(dave).verifyComplete();
}
@Test // DATAMONGO-1619
@@ -398,7 +399,7 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
Example<ReactivePerson> example = Example.of(dave, matching().withIgnorePaths("id", "age", "firstname"));
StepVerifier.create(repository.findAll(example)).expectNextCount(2).verifyComplete();
repository.findAll(example).as(StepVerifier::create).expectNextCount(2).verifyComplete();
}
@Test // DATAMONGO-1619
@@ -406,7 +407,8 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
Example<ReactivePerson> example = Example.of(dave, matching().withIgnorePaths("id", "age", "firstname"));
StepVerifier.create(repository.findAll(example, Sort.by("firstname"))).expectNext(dave, oliver).verifyComplete();
repository.findAll(example, Sort.by("firstname")).as(StepVerifier::create).expectNext(dave, oliver)
.verifyComplete();
}
@Test // DATAMONGO-1619
@@ -414,7 +416,7 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
Example<ReactivePerson> example = Example.of(dave, matching().withIgnorePaths("id", "age", "firstname"));
StepVerifier.create(repository.count(example)).expectNext(2L).verifyComplete();
repository.count(example).as(StepVerifier::create).expectNext(2L).verifyComplete();
}
@Test // DATAMONGO-1619
@@ -422,7 +424,7 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
Example<ReactivePerson> example = Example.of(dave, matching().withIgnorePaths("id", "age", "firstname"));
StepVerifier.create(repository.exists(example)).expectNext(true).verifyComplete();
repository.exists(example).as(StepVerifier::create).expectNext(true).verifyComplete();
}
@Test // DATAMONGO-1619
@@ -430,7 +432,7 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
Example<ReactivePerson> example = Example.of(new ReactivePerson("foo", "bar", -1));
StepVerifier.create(repository.exists(example)).expectNext(false).verifyComplete();
repository.exists(example).as(StepVerifier::create).expectNext(false).verifyComplete();
}
@Test // DATAMONGO-1619
@@ -439,7 +441,7 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
Example<ReactivePerson> example = Example.of(new ReactivePerson(null, "Matthews", -1),
matching().withIgnorePaths("age"));
StepVerifier.create(repository.findOne(example)).expectError(IncorrectResultSizeDataAccessException.class);
repository.findOne(example).as(StepVerifier::create).expectError(IncorrectResultSizeDataAccessException.class);
}
@Test // DATAMONGO-1907
@@ -447,7 +449,7 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
Example<ReactivePerson> example = Example.of(new ReactivePerson("foo", "bar", -1));
StepVerifier.create(repository.findOne(example)).verifyComplete();
repository.findOne(example).as(StepVerifier::create).verifyComplete();
}
interface ReactivePersonRepostitory extends ReactiveMongoRepository<ReactivePerson, String> {