Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated ErrorContextBuilder#buildWithDataStoreFactory #409

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jdbi.v3.core.Jdbi;
import org.kiwiproject.base.KiwiDeprecated;
import org.kiwiproject.base.KiwiDeprecated.Severity;
import org.kiwiproject.dropwizard.error.config.CleanupConfig;
import org.kiwiproject.dropwizard.error.dao.ApplicationErrorDao;
import org.kiwiproject.dropwizard.error.dao.ApplicationErrorJdbc;
Expand Down Expand Up @@ -145,7 +143,6 @@ public ErrorContextBuilder serviceDetails(ServiceDetails serviceDetails) {
* @return this builder
* @implNote The builder implementations have default values; using this will override those defaults.
* @see #buildInMemoryH2()
* @see #buildWithDataStoreFactory(DataSourceFactory)
* @see #buildWithJdbi3(Jdbi)
*/
public ErrorContextBuilder dataStoreType(DataStoreType dataStoreType) {
Expand Down Expand Up @@ -299,25 +296,6 @@ public ErrorContext buildInMemoryH2() {
return newJdbi3ErrorContext(jdbi);
}

/**
* Build an {@link ErrorContext} using given the {@code dataSourceFactory} that uses JDBI version 3.
*
* @param dataSourceFactory the Dropwizard {@link DataSourceFactory}
* @return a new {@link ErrorContext} instance
* @implNote If you do not invoke {@link #dataStoreType(DataStoreType)} prior to calling this method, this method
* will attempt to determine which {@link DataStoreType} it should use by calling
* {@link ApplicationErrorJdbc#dataStoreTypeOf(DataSourceFactory)}.
* @deprecated use {@link #buildWithJdbi3(DataSourceFactory)}. This will be removed in version 3.0.0.
*/
@Deprecated(since = "2.1.0", forRemoval = true)
@KiwiDeprecated(removeAt = "3.0.0",
reference = "https://github.com/kiwiproject/dropwizard-application-errors/issues/375",
usageSeverity = Severity.SEVERE,
replacedBy = "#buildWithJdbi3(DataSourceFactory)")
public ErrorContext buildWithDataStoreFactory(DataSourceFactory dataSourceFactory) {
return buildWithJdbi3(dataSourceFactory);
}

/**
* Build an {@link ErrorContext} using given the {@code dataSourceFactory} that uses JDBI version 3.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,83 +432,6 @@ void shouldForce_NOT_SHARED_DataStoreType() {
}
}

@SuppressWarnings("deprecation")
@Nested
class BuildWithDataStoreFactory_Deprecated {

private DataSourceFactory dataSourceFactory;

@BeforeEach
void setUp() {
dataSourceFactory = ApplicationErrorJdbc.createInMemoryH2Database();
}

@Test
void shouldBuildJdbi3Context(SoftAssertions softly) {
var errorContext = ErrorContextBuilder.newInstance()
.environment(environment)
.serviceDetails(serviceDetails)
.buildWithDataStoreFactory(dataSourceFactory);

softly.assertThat(errorContext).isExactlyInstanceOf(Jdbi3ErrorContext.class);
softly.assertThat(errorContext.errorDao()).isInstanceOf(Jdbi3ApplicationErrorDao.class);
}

@Test
void shouldRegisterResources() {
ErrorContextBuilder.newInstance()
.environment(environment)
.serviceDetails(serviceDetails)
.buildWithDataStoreFactory(dataSourceFactory);

verifyRegistersJerseyResources();
}

@Test
void shouldRegisterHealthCheck() {
ErrorContextBuilder.newInstance()
.environment(environment)
.serviceDetails(serviceDetails)
.buildWithDataStoreFactory(dataSourceFactory);

verifyRegistersHealthChecks();
}

@Test
void shouldDetermineDataStoreTypeIfNotSet() {
var errorContext = ErrorContextBuilder.newInstance()
.environment(environment)
.serviceDetails(serviceDetails)
.buildWithDataStoreFactory(dataSourceFactory);

assertThat(errorContext.dataStoreType()).isEqualTo(DataStoreType.NOT_SHARED);
}

@Test
void shouldForce_NOT_SHARED_ForEmbeddedH2Databases() {
var errorContext = ErrorContextBuilder.newInstance()
.environment(environment)
.serviceDetails(serviceDetails)
.dataStoreType(DataStoreType.SHARED)
.buildWithDataStoreFactory(dataSourceFactory);

assertThat(errorContext.dataStoreType()).isEqualTo(DataStoreType.NOT_SHARED);
}

@Test
void shouldWorkWithPostgres(SoftAssertions softly) {
var postgresDataSourceFactory = newPostgresDataSourceFactory();

var errorContext = ErrorContextBuilder.newInstance()
.environment(environment)
.serviceDetails(serviceDetails)
.buildWithDataStoreFactory(postgresDataSourceFactory);

softly.assertThat(errorContext.dataStoreType()).isEqualTo(DataStoreType.SHARED);
softly.assertThat(errorContext.errorDao()).isNotNull();
}
}

@Nested
class BuildWithJdbc_UsingDataStoreFactory {

Expand Down