Skip to content

Commit

Permalink
refs #337: upgrade for 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
William Delanoue committed Jun 5, 2018
1 parent 2cc5b3f commit d82f732
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.6.2</version>
<version>3.7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-async</artifactId>
<version>3.6.2</version>
<version>3.7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/com/github/fakemongo/FongoConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -616,12 +616,10 @@ public <T> 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();
}

Expand Down Expand Up @@ -658,8 +656,7 @@ public <T> 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")) {
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/mongodb/MockMongoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -186,7 +189,7 @@ public boolean isClosed() {
};
}

com.mongodb.OperationExecutor createOperationExecutor() {
OperationExecutor createOperationExecutor() {
return new FongoOperationExecutor(fongo);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -14,7 +16,7 @@
public class FongoOperationExecutor implements OperationExecutor {
private final Fongo fongo;

FongoOperationExecutor(Fongo fongo) {
public FongoOperationExecutor(Fongo fongo) {
this.fongo = fongo;
}

Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/mongodb/FongoMongoDatabaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d82f732

Please sign in to comment.