### Question:
StandardInfluxDatabaseService extends AbstractInfluxDatabaseService implements InfluxDatabaseService { @NonNull @Override public InfluxDB connect() throws IOException, GeneralSecurityException { ConfigurationContext context = getConfigurationContext(); SSLContextService sslService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); SSLContextService.ClientAuth clientAuth = getEnumValue(CLIENT_AUTH, context, SSLContextService.ClientAuth.class, DEFAULT_CLIENT_AUTH); String influxDbUrl = getDatabaseURL(); long connectionTimeout = context.getProperty(INFLUX_DB_CONNECTION_TIMEOUT).asTimePeriod(TimeUnit.SECONDS); String username = context.getProperty(USERNAME).evaluateAttributeExpressions().getValue(); String password = context.getProperty(PASSWORD).evaluateAttributeExpressions().getValue(); try { InfluxDB influxDB = connect(username, password, sslService, clientAuth, influxDbUrl, connectionTimeout); getLogger().info("InfluxDB connection created for host {}", new Object[]{influxDbUrl}); return influxDB; } catch (Exception e) { getLogger().error("Error while getting connection {}", new Object[]{e.getLocalizedMessage()}, e); throw new RuntimeException("Error while getting connection " + e.getLocalizedMessage(), e); } }  @NonNull @Override InfluxDB connect(); @NonNull @Override String getDatabaseURL();  }### Answer:
@Test public void successConnect() throws IOException, GeneralSecurityException { answerConnect = new CallsRealMethods(); testRunner.enableControllerService(service); InfluxDB influxDB = service.connect(); Assert.assertNotNull(influxDB); }
@Test public void errorHandling() throws IOException, GeneralSecurityException { answerConnect = invocation -> { throw new InfluxDBIOException(new IOException("simulate exception")); }; testRunner.enableControllerService(service); expectedException.expect(RuntimeException.class); expectedException.expectMessage("Error while getting connection java.io.IOException: simulate exception"); service.connect(); }