io.dropwizard.db.DatabaseConfiguration Java Examples

The following examples show how to use io.dropwizard.db.DatabaseConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractCommandTest.java    From dropwizard-flyway with Apache License 2.0 6 votes vote down vote up
@BeforeEach
public void setUp() throws Exception {
    // Setup necessary mock
    final JarLocation location = mock(JarLocation.class);
    when(location.getVersion()).thenReturn(Optional.of("1.0.0"));

    final DatabaseConfiguration dbConfiguration = mock(DatabaseConfiguration.class);
    when(dbConfiguration.getDataSourceFactory(any())).thenReturn(mock(PooledDataSourceFactory.class));

    final FlywayConfiguration flywayConfiguration = mock(FlywayConfiguration.class);
    mockFlywayFactory = mock(FlywayFactory.class);
    when(flywayConfiguration.getFlywayFactory(any())).thenReturn(mockFlywayFactory);

    mockFlyway = mock(Flyway.class);
    when(mockFlywayFactory.build(any())).thenReturn(mockFlyway);

    // Add commands you want to test
    final Bootstrap<TestConfiguration> bootstrap = new Bootstrap<>(new TestApplication());
    bootstrap.addCommand(new DbCommand<TestConfiguration>("db", dbConfiguration, flywayConfiguration, TestConfiguration.class));

    // Build what'll run the command and interpret arguments
    cli = new Cli(location, bootstrap, System.out, System.err);
}
 
Example #2
Source File: DbCommand.java    From dropwizard-flyway with Apache License 2.0 5 votes vote down vote up
public DbCommand(final String name, final DatabaseConfiguration<T> databaseConfiguration,
                 final FlywayConfiguration<T> flywayConfiguration,
                 final Class<T> configurationClass) {
    super(name, "Run database migration tasks",
            databaseConfiguration, flywayConfiguration, configurationClass);

    addSubCommand(new DbMigrateCommand<>(databaseConfiguration, flywayConfiguration, configurationClass));
    addSubCommand(new DbCleanCommand<>(databaseConfiguration, flywayConfiguration, configurationClass));
    addSubCommand(new DbInitCommand<>(databaseConfiguration, flywayConfiguration, configurationClass));
    addSubCommand(new DbValidateCommand<>(databaseConfiguration, flywayConfiguration, configurationClass));
    addSubCommand(new DbInfoCommand<>(databaseConfiguration, flywayConfiguration, configurationClass));
    addSubCommand(new DbRepairCommand<>(databaseConfiguration, flywayConfiguration, configurationClass));
}
 
Example #3
Source File: AbstractFlywayCommand.java    From dropwizard-flyway with Apache License 2.0 5 votes vote down vote up
AbstractFlywayCommand(final String name,
                      final String description,
                      final DatabaseConfiguration<T> databaseConfiguration,
                      final FlywayConfiguration<T> flywayConfiguration,
                      final Class<T> configurationClass) {
    super(name, description);
    this.databaseConfiguration = databaseConfiguration;
    this.flywayConfiguration = flywayConfiguration;
    this.configurationClass = configurationClass;
}
 
Example #4
Source File: DbValidateCommand.java    From dropwizard-flyway with Apache License 2.0 4 votes vote down vote up
public DbValidateCommand(final DatabaseConfiguration<T> databaseConfiguration,
                         final FlywayConfiguration<T> flywayConfiguration,
                         final Class<T> configurationClass) {
    super("validate", "Validates the applied migrations against the ones available on the classpath.",
            databaseConfiguration, flywayConfiguration, configurationClass);
}
 
Example #5
Source File: DbRepairCommand.java    From dropwizard-flyway with Apache License 2.0 4 votes vote down vote up
public DbRepairCommand(final DatabaseConfiguration<T> databaseConfiguration,
                       final FlywayConfiguration<T> flywayConfiguration,
                       final Class<T> configurationClass) {
    super("repair", "Repairs the metadata table.",
            databaseConfiguration, flywayConfiguration, configurationClass);
}
 
Example #6
Source File: NoOptionsFlywayCommand.java    From dropwizard-flyway with Apache License 2.0 4 votes vote down vote up
NoOptionsFlywayCommand(String name, String description, DatabaseConfiguration<T> databaseConfiguration,
                       FlywayConfiguration<T> flywayConfiguration, Class<T> configurationClass) {
    super(name, description, databaseConfiguration, flywayConfiguration, configurationClass);
}
 
Example #7
Source File: DbInitCommand.java    From dropwizard-flyway with Apache License 2.0 4 votes vote down vote up
public DbInitCommand(final DatabaseConfiguration<T> databaseConfiguration,
                     final FlywayConfiguration<T> flywayConfiguration,
                     final Class<T> configurationClass) {
    super("init", "Creates and initializes the metadata table (existing database).",
            databaseConfiguration, flywayConfiguration, configurationClass);
}
 
Example #8
Source File: DbInfoCommand.java    From dropwizard-flyway with Apache License 2.0 4 votes vote down vote up
public DbInfoCommand(final DatabaseConfiguration<T> databaseConfiguration,
                     final FlywayConfiguration<T> flywayConfiguration,
                     final Class<T> configurationClass) {
    super("info", "Prints the details and status information about all the migrations.",
            databaseConfiguration, flywayConfiguration, configurationClass);
}
 
Example #9
Source File: DbCleanCommand.java    From dropwizard-flyway with Apache License 2.0 4 votes vote down vote up
public DbCleanCommand(final DatabaseConfiguration<T> databaseConfiguration,
                      final FlywayConfiguration<T> flywayConfiguration,
                      final Class<T> configurationClass) {
    super("clean", "Drops all objects in the configured schemas.",
            databaseConfiguration, flywayConfiguration, configurationClass);
}
 
Example #10
Source File: DbMigrateCommand.java    From dropwizard-flyway with Apache License 2.0 4 votes vote down vote up
public DbMigrateCommand(final DatabaseConfiguration<T> databaseConfiguration,
                        final FlywayConfiguration<T> flywayConfiguration,
                        final Class<T> configurationClass) {
    super("migrate", "Migrates the database.",
            databaseConfiguration, flywayConfiguration, configurationClass);
}