MongoClientURIConverter implements Converter<MongoClientURI> { @Override public MongoClientURI convertFrom(String value) { if (value == null) { throw new ParameterException("Couldn't convert value \"null\" to a MongoDB connection string."); } try { return new MongoClientURI(value); } catch (Exception e) { throw new ParameterException(e.getMessage(), e); } }  @Override MongoClientURI convertFrom(String value); @Override String convertTo(MongoClientURI value);  }
@Test public void convertFromValidConnectionString() throws Exception { final MongoClientURI uri = new MongoClientURIConverter().convertFrom("mongodb: assertEquals(new MongoClientURI("mongodb: }
@Test public void convertFromInvalidConnectionString() throws Exception { expectedException.expect(ParameterException.class); expectedException.expectMessage("The connection string is invalid. Connection strings must start with 'mongodb: new MongoClientURIConverter().convertFrom("http: }
@Test public void convertFromEmptyString() throws Exception { expectedException.expect(ParameterException.class); expectedException.expectMessage("The connection string is invalid. Connection strings must start with 'mongodb: new MongoClientURIConverter().convertFrom(""); }
@Test public void convertFromNull() throws Exception { expectedException.expect(ParameterException.class); expectedException.expectMessage("Couldn't convert value \"null\" to a MongoDB connection string."); new MongoClientURIConverter().convertFrom(null); }