Search in sources :

Example 1 with Context

use of org.flywaydb.core.api.callback.Context in project spring-boot by spring-projects.

the class Flyway6xAutoConfigurationTests method callbacksAreConfiguredAndOrdered.

@Test
void callbacksAreConfiguredAndOrdered() {
    this.contextRunner.withUserConfiguration(DataSourceAutoConfiguration.class, CallbackConfiguration.class).run((context) -> {
        assertThat(context).hasSingleBean(Flyway.class);
        Flyway flyway = context.getBean(Flyway.class);
        Callback callbackOne = context.getBean("callbackOne", Callback.class);
        Callback callbackTwo = context.getBean("callbackTwo", Callback.class);
        assertThat(flyway.getConfiguration().getCallbacks()).hasSize(2);
        assertThat(flyway.getConfiguration().getCallbacks()).containsExactly(callbackTwo, callbackOne);
        InOrder orderedCallbacks = inOrder(callbackOne, callbackTwo);
        orderedCallbacks.verify(callbackTwo).handle(any(Event.class), any(Context.class));
        orderedCallbacks.verify(callbackOne).handle(any(Event.class), any(Context.class));
    });
}
Also used : Context(org.flywaydb.core.api.callback.Context) Flyway(org.flywaydb.core.Flyway) Callback(org.flywaydb.core.api.callback.Callback) InOrder(org.mockito.InOrder) Event(org.flywaydb.core.api.callback.Event) DataSourceAutoConfiguration(org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration) Test(org.junit.jupiter.api.Test)

Example 2 with Context

use of org.flywaydb.core.api.callback.Context in project spring-boot by spring-projects.

the class FlywayAutoConfigurationTests method callbacksAreConfiguredAndOrderedByName.

@Test
void callbacksAreConfiguredAndOrderedByName() {
    this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, CallbackConfiguration.class).run((context) -> {
        assertThat(context).hasSingleBean(Flyway.class);
        Flyway flyway = context.getBean(Flyway.class);
        Callback callbackOne = context.getBean("callbackOne", Callback.class);
        Callback callbackTwo = context.getBean("callbackTwo", Callback.class);
        assertThat(flyway.getConfiguration().getCallbacks()).hasSize(2);
        InOrder orderedCallbacks = inOrder(callbackOne, callbackTwo);
        orderedCallbacks.verify(callbackTwo).handle(any(Event.class), any(Context.class));
        orderedCallbacks.verify(callbackOne).handle(any(Event.class), any(Context.class));
    });
}
Also used : DefaultDSLContext(org.jooq.impl.DefaultDSLContext) DSLContext(org.jooq.DSLContext) AssertableApplicationContext(org.springframework.boot.test.context.assertj.AssertableApplicationContext) Context(org.flywaydb.core.api.callback.Context) EmbeddedDataSourceConfiguration(org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration) Flyway(org.flywaydb.core.Flyway) Callback(org.flywaydb.core.api.callback.Callback) InOrder(org.mockito.InOrder) Event(org.flywaydb.core.api.callback.Event) Test(org.junit.jupiter.api.Test)

Example 3 with Context

use of org.flywaydb.core.api.callback.Context in project spring-boot by spring-projects.

the class Flyway7xAutoConfigurationTests method callbacksAreConfigured.

@Test
void callbacksAreConfigured() {
    this.contextRunner.withUserConfiguration(DataSourceAutoConfiguration.class, CallbackConfiguration.class).run((context) -> {
        assertThat(context).hasSingleBean(Flyway.class);
        Flyway flyway = context.getBean(Flyway.class);
        Callback callbackOne = context.getBean("callbackOne", Callback.class);
        Callback callbackTwo = context.getBean("callbackTwo", Callback.class);
        assertThat(flyway.getConfiguration().getCallbacks()).hasSize(2);
        assertThat(flyway.getConfiguration().getCallbacks()).containsExactlyInAnyOrder(callbackTwo, callbackOne);
        then(callbackOne).should(atLeastOnce()).handle(any(Event.class), any(Context.class));
        then(callbackTwo).should(atLeastOnce()).handle(any(Event.class), any(Context.class));
    });
}
Also used : Context(org.flywaydb.core.api.callback.Context) Flyway(org.flywaydb.core.Flyway) Callback(org.flywaydb.core.api.callback.Callback) Event(org.flywaydb.core.api.callback.Event) DataSourceAutoConfiguration(org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

Flyway (org.flywaydb.core.Flyway)3 Callback (org.flywaydb.core.api.callback.Callback)3 Context (org.flywaydb.core.api.callback.Context)3 Event (org.flywaydb.core.api.callback.Event)3 Test (org.junit.jupiter.api.Test)3 InOrder (org.mockito.InOrder)2 DataSourceAutoConfiguration (org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration)2 DSLContext (org.jooq.DSLContext)1 DefaultDSLContext (org.jooq.impl.DefaultDSLContext)1 EmbeddedDataSourceConfiguration (org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration)1 AssertableApplicationContext (org.springframework.boot.test.context.assertj.AssertableApplicationContext)1