use of com.mongodb.connection.ServerVersion in project mongo-java-driver by mongodb.
the class CommandMonitoringTest method setUp.
@Before
public void setUp() {
ServerVersion serverVersion = ClusterFixture.getServerVersion();
if (definition.containsKey("ignore_if_server_version_less_than")) {
assumeFalse(serverVersion.compareTo(getServerVersion("ignore_if_server_version_less_than")) < 0);
}
if (definition.containsKey("ignore_if_server_version_greater_than")) {
assumeFalse(serverVersion.compareTo(getServerVersion("ignore_if_server_version_greater_than")) > 0);
}
if (definition.containsKey("ignore_if_topology_type")) {
BsonArray topologyTypes = definition.getArray("ignore_if_topology_type");
for (BsonValue type : topologyTypes) {
String typeString = type.asString().getValue();
if (typeString.equals("sharded")) {
assumeFalse(isSharded());
} else if (typeString.equals("replica_set")) {
assumeFalse(isDiscoverableReplicaSet());
} else if (typeString.equals("standalone")) {
assumeFalse(isSharded());
}
}
}
List<BsonDocument> documents = new ArrayList<BsonDocument>();
for (BsonValue document : data) {
documents.add(document.asDocument());
}
CollectionHelper<Document> collectionHelper = new CollectionHelper<Document>(new DocumentCodec(), new MongoNamespace(databaseName, collectionName));
collectionHelper.drop();
collectionHelper.insertDocuments(documents);
commandListener.reset();
collection = mongoClient.getDatabase(databaseName).getCollection(collectionName, BsonDocument.class);
if (definition.getDocument("operation").containsKey("read_preference")) {
collection = collection.withReadPreference(ReadPreference.valueOf(definition.getDocument("operation").getDocument("read_preference").getString("mode").getValue()));
}
helper = new JsonPoweredCrudTestHelper(description, collection);
}
Aggregations