MongoClientConfiguration { public MongoClientOptions getMongoClientOptions() throws MongoValidationException { int localThreashold = getIntegerSetting(LOCAL_THREADSHOLD); int maxConnectionsPerHost = getIntegerSetting(MAX_CONNECTIONS_PER_HOST); int connectTimeout = getIntegerSetting(CONNECTION_TIMEOUT); int maxConnectionIdleTime = getIntegerSetting(MAX_IDLE_TIME); ReadPreference readPreference = getReadPreference(); WriteConcern writeConcern = getWriteConcern(); MongoClientOptions clientOptions = new MongoClientOptions.Builder() .localThreshold(localThreashold) .connectionsPerHost(maxConnectionsPerHost).connectTimeout(connectTimeout) .maxConnectionIdleTime(maxConnectionIdleTime).readPreference(readPreference) .writeConcern(writeConcern).build(); return clientOptions; } MongoClientConfiguration(ConnectorClusterConfig connectorClusterConfig); MongoClientOptions getMongoClientOptions(); List<ServerAddress> getSeeds();  }
@Test public void wrongReadPreferenceTest() { Map<String, String> properties = new HashMap<String, String>(); properties.put(READ_PREFERENCE.getOptionName(), "falseReadPreference"); ConnectorClusterConfig wrongConfig = new ConnectorClusterConfig(CLUSTER_NAME, null, properties); MongoClientConfiguration config = new MongoClientConfiguration(wrongConfig); try { config.getMongoClientOptions(); fail("A exception must be thrown when no match any option"); } catch (MongoValidationException e) { } }
@Test public void wrongIntegerPreferenceTest() { Map<String, String> properties = new HashMap<String, String>(); properties.put(MAX_CONNECTIONS_PER_HOST.getOptionName(), "ten"); ConnectorClusterConfig wrongConfig = new ConnectorClusterConfig(CLUSTER_NAME, null, properties); MongoClientConfiguration config = new MongoClientConfiguration(wrongConfig); try { config.getMongoClientOptions(); fail("An exception must be thrown when a non integer received"); } catch (MongoValidationException e) { } }