Skip to content

Commit

Permalink
Remove deprecated ErrorContextBuilder#buildWithDataStoreFactory
Browse files Browse the repository at this point in the history
Closes #375
  • Loading branch information
sleberknight committed Sep 2, 2024
1 parent 97cf12e commit 53658ce
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 99 deletions.
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

0 comments on commit 53658ce

Please sign in to comment.