### Question:
ConfigurationHelper { public static ExecutionDatabaseConfiguration getExecutionDatabaseConfiguration(final DatabaseConfiguration databaseConfiguration, final Settings settings, final ILSLog log) throws MojoExecutionException { if (databaseConfiguration == null) { return null; } final ExecutionDatabaseConfiguration executionDatabaseConfiguration = new ExecutionDatabaseConfiguration(); executionDatabaseConfiguration.setJdbcUrl(databaseConfiguration.getJdbcUrl()); final String serverId = databaseConfiguration.getServerId(); log.info("Resolving database server ID: " + serverId); final Server server = settings.getServer(serverId); if (server == null) { throw new MojoExecutionException( String.format("No definition found for server ID %s in settings.xml", serverId)); } final String username = server.getUsername(); final String password = server.getPassword(); if (username == null) { throw new MojoExecutionException( String.format("No username defined in server specification with ID %s in settings.xml", serverId)); } if (password == null) { throw new MojoExecutionException( String.format("No password defined in server specification with ID %s in settings.xml", serverId)); } executionDatabaseConfiguration.setUsername(username); executionDatabaseConfiguration.setPassword(password); return executionDatabaseConfiguration; } private  ConfigurationHelper(); static ExecutionDatabaseConfiguration getExecutionDatabaseConfiguration(final DatabaseConfiguration databaseConfiguration,
                                                                                   final Settings settings,
                                                                                   final ILSLog log); static List<ExecutionOutput> getExecutionOutputs(final List<Output> outputs, final String artifactBaseUrl,
                                                            final LSArtifact reportProtoTypeArtifact);  }### Answer:
@Test public void testGetExecutionDatabaseConfigurationSuccess() throws Exception { final Settings settings = createSettings(); final DatabaseConfiguration databaseConfiguration = new DatabaseConfiguration("jdbcUrl", "serverId"); final ExecutionDatabaseConfiguration executionDatabaseConfiguration = ConfigurationHelper .getExecutionDatabaseConfiguration(databaseConfiguration, settings, TestUtil.createTestLog()); Assert.assertEquals("jdbcUrl", "jdbcUrl", executionDatabaseConfiguration.getJdbcUrl()); Assert.assertEquals("username", "serverIdusername", executionDatabaseConfiguration.getUsername()); Assert.assertEquals("password", "serverIdpassword", executionDatabaseConfiguration.getPassword()); }
@Test public void testGetExecutionDatabaseConfigurationNull() throws Exception { final Settings settings = createSettings(); final DatabaseConfiguration databaseConfiguration = null; final ExecutionDatabaseConfiguration executionDatabaseConfiguration = ConfigurationHelper .getExecutionDatabaseConfiguration(databaseConfiguration, settings, TestUtil.createTestLog()); Assert.assertNull("result ExecutionDatabaseConfiguration", executionDatabaseConfiguration); }
@Test(expected = MojoExecutionException.class) public void testGetExecutionDatabaseConfigurationServerIdNotFound() throws Exception { final Settings settings = createSettings(); final DatabaseConfiguration databaseConfiguration = new DatabaseConfiguration("jdbcUrl", "serverId_noexisting"); ConfigurationHelper.getExecutionDatabaseConfiguration(databaseConfiguration, settings, TestUtil.createTestLog()); }