diff --git a/pom.xml b/pom.xml index 0bb84d7e..856b46ab 100644 --- a/pom.xml +++ b/pom.xml @@ -73,13 +73,13 @@ org.mongodb mongo-java-driver - 3.6.2 + 3.7.0 provided org.mongodb mongodb-driver-async - 3.6.2 + 3.7.0 provided diff --git a/src/main/java/com/github/fakemongo/FongoConnection.java b/src/main/java/com/github/fakemongo/FongoConnection.java index 4df542fb..a448a96b 100644 --- a/src/main/java/com/github/fakemongo/FongoConnection.java +++ b/src/main/java/com/github/fakemongo/FongoConnection.java @@ -320,7 +320,7 @@ public BulkWriteResult insertCommand(MongoNamespace namespace, boolean ordered, private void validateCollectionName(String collectionName) { if (collectionName == null || collectionName.isEmpty() || collectionName.startsWith("system.") - || collectionName.contains("$") || collectionName.contains("\0")) + || collectionName.contains("$") || collectionName.contains("\0")) throw new IllegalArgumentException("Invalid collection name " + collectionName); } @@ -616,12 +616,10 @@ public T command(String database, BsonDocument command, FieldNameValidator c if (payload.hasAnotherSplit()) { documentsToDelete = Collections.singletonList(payload.getPayload().get(payload.getPosition())); payload.setPosition(payload.getPosition() + 1); - } - else { + } else { documentsToDelete = Collections.emptyList(); } - } - else { + } else { documentsToDelete = command.getArray("deletes").getValues(); } @@ -658,8 +656,7 @@ public T command(String database, BsonDocument command, FieldNameValidator c if (payload != null) { return (T) new BsonDocument("ok", new BsonInt32(1)).append("n", new BsonInt32(numDocsDeleted)); - } - else { + } else { return (T) new Document("ok", 1).append("n", numDocsDeleted); } } else if (command.containsKey("find")) { diff --git a/src/main/java/com/mongodb/MockMongoClient.java b/src/main/java/com/mongodb/MockMongoClient.java index 25fe9480..f5c9995b 100644 --- a/src/main/java/com/mongodb/MockMongoClient.java +++ b/src/main/java/com/mongodb/MockMongoClient.java @@ -4,6 +4,9 @@ import com.github.fakemongo.FongoConnection; import com.mongodb.async.SingleResultCallback; import com.mongodb.client.MongoDatabase; +import com.mongodb.client.internal.FongoMongoDatabase; +import com.mongodb.client.internal.FongoOperationExecutor; +import com.mongodb.client.internal.OperationExecutor; import com.mongodb.connection.AsyncConnection; import com.mongodb.connection.BufferProvider; import com.mongodb.connection.Cluster; @@ -186,7 +189,7 @@ public boolean isClosed() { }; } - com.mongodb.OperationExecutor createOperationExecutor() { + OperationExecutor createOperationExecutor() { return new FongoOperationExecutor(fongo); } diff --git a/src/main/java/com/mongodb/FongoMongoCollection.java b/src/main/java/com/mongodb/client/internal/FongoMongoCollection.java similarity index 94% rename from src/main/java/com/mongodb/FongoMongoCollection.java rename to src/main/java/com/mongodb/client/internal/FongoMongoCollection.java index 7b4e1846..d8ec468b 100644 --- a/src/main/java/com/mongodb/FongoMongoCollection.java +++ b/src/main/java/com/mongodb/client/internal/FongoMongoCollection.java @@ -1,11 +1,15 @@ -package com.mongodb; +package com.mongodb.client.internal; import com.github.fakemongo.Fongo; +import com.mongodb.DBCollection; +import com.mongodb.DBObject; +import com.mongodb.MongoNamespace; +import com.mongodb.ReadConcern; +import com.mongodb.ReadPreference; +import com.mongodb.WriteConcern; import com.mongodb.client.MongoCollection; import com.mongodb.client.model.CountOptions; import com.mongodb.client.model.IndexModel; -import com.mongodb.client.model.UpdateOptions; -import com.mongodb.client.result.UpdateResult; import com.mongodb.util.FongoJSON; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/mongodb/FongoMongoDatabase.java b/src/main/java/com/mongodb/client/internal/FongoMongoDatabase.java similarity index 92% rename from src/main/java/com/mongodb/FongoMongoDatabase.java rename to src/main/java/com/mongodb/client/internal/FongoMongoDatabase.java index 666f31d5..4a1539ef 100644 --- a/src/main/java/com/mongodb/FongoMongoDatabase.java +++ b/src/main/java/com/mongodb/client/internal/FongoMongoDatabase.java @@ -1,6 +1,10 @@ -package com.mongodb; +package com.mongodb.client.internal; import com.github.fakemongo.Fongo; +import com.mongodb.MongoNamespace; +import com.mongodb.ReadConcern; +import com.mongodb.ReadPreference; +import com.mongodb.WriteConcern; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; import org.bson.codecs.configuration.CodecRegistry; diff --git a/src/main/java/com/mongodb/FongoOperationExecutor.java b/src/main/java/com/mongodb/client/internal/FongoOperationExecutor.java similarity index 84% rename from src/main/java/com/mongodb/FongoOperationExecutor.java rename to src/main/java/com/mongodb/client/internal/FongoOperationExecutor.java index 27ee942b..7634656b 100644 --- a/src/main/java/com/mongodb/FongoOperationExecutor.java +++ b/src/main/java/com/mongodb/client/internal/FongoOperationExecutor.java @@ -1,9 +1,11 @@ /** * Copyright (C) 2017 Deveryware S.A. All Rights Reserved. */ -package com.mongodb; +package com.mongodb.client.internal; import com.github.fakemongo.Fongo; +import com.mongodb.ReadPreference; +import com.mongodb.client.internal.OperationExecutor; import com.mongodb.operation.ReadOperation; import com.mongodb.operation.WriteOperation; import com.mongodb.session.ClientSession; @@ -14,7 +16,7 @@ public class FongoOperationExecutor implements OperationExecutor { private final Fongo fongo; - FongoOperationExecutor(Fongo fongo) { + public FongoOperationExecutor(Fongo fongo) { this.fongo = fongo; } diff --git a/src/test/java/com/mongodb/FongoMongoDatabaseTest.java b/src/test/java/com/mongodb/FongoMongoDatabaseTest.java index 65ab8956..3fc14cf1 100644 --- a/src/test/java/com/mongodb/FongoMongoDatabaseTest.java +++ b/src/test/java/com/mongodb/FongoMongoDatabaseTest.java @@ -3,6 +3,7 @@ import com.github.fakemongo.Fongo; import static com.mongodb.WriteConcern.REPLICA_ACKNOWLEDGED; import com.mongodb.client.MongoDatabase; +import com.mongodb.client.internal.FongoMongoDatabase; import static org.assertj.core.api.Assertions.assertThat; import org.bson.codecs.configuration.CodecRegistry; import org.junit.Before;