@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()); }
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; }
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; } }
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(); }
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); }
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);  }