Skip to content

Commit

Permalink
Upgrade to Dropwizard 4.0.0 (#1667)
Browse files Browse the repository at this point in the history
  • Loading branch information
RohanNagar committed Mar 31, 2023
1 parent f0c3c32 commit 5d55001
Show file tree
Hide file tree
Showing 39 changed files with 139 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import io.dropwizard.jackson.Jackson;
import io.dropwizard.testing.FixtureHelpers;
import io.dropwizard.util.Resources;

import java.util.StringJoiner;

Expand All @@ -25,14 +25,14 @@ class EmailTest {
@Test
void shouldSerializeToJson() throws Exception {
String expected = MAPPER.writeValueAsString(
MAPPER.readValue(FixtureHelpers.fixture("fixtures/email.json"), Email.class));
MAPPER.readValue(Resources.getResource("fixtures/email.json"), Email.class));

assertEquals(expected, MAPPER.writeValueAsString(email));
}

@Test
void shouldDeserializeFromJson() throws Exception {
Email fromJson = MAPPER.readValue(FixtureHelpers.fixture("fixtures/email.json"), Email.class);
Email fromJson = MAPPER.readValue(Resources.getResource("fixtures/email.json"), Email.class);

assertEquals(email, fromJson);
}
Expand Down
8 changes: 4 additions & 4 deletions api/src/test/java/com/sanctionco/thunder/models/UserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import io.dropwizard.jackson.Jackson;
import io.dropwizard.testing.FixtureHelpers;
import io.dropwizard.util.Resources;

import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -43,15 +43,15 @@ static void setup() {
@Test
void testNoPropertiesJsonSerialization() throws Exception {
String expected = MAPPER.writeValueAsString(MAPPER.readValue(
FixtureHelpers.fixture("fixtures/no_properties_user.json"), User.class));
Resources.getResource("fixtures/no_properties_user.json"), User.class));

assertEquals(expected, MAPPER.writeValueAsString(emptyPropertiesUser));
}

@Test
void testNoPropertiesJsonDeserialization() throws Exception {
User fromJson = MAPPER.readValue(
FixtureHelpers.fixture("fixtures/no_properties_user.json"), User.class);
Resources.getResource("fixtures/no_properties_user.json"), User.class);

assertEquals(emptyPropertiesUser, fromJson);
}
Expand All @@ -69,7 +69,7 @@ void testMultiplePropertiesJsonSerialization() throws Exception {
@Test
void testMultiplePropertiesJsonDeserialization() throws Exception {
User fromJson = MAPPER.readValue(
FixtureHelpers.fixture("fixtures/multiple_properties_user.json"), User.class);
Resources.getResource("fixtures/multiple_properties_user.json"), User.class);

assertEquals(multiplePropertiesUser, fromJson);
}
Expand Down
6 changes: 3 additions & 3 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
<artifactId>swagger-core-jakarta</artifactId>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-jaxrs2</artifactId>
<artifactId>swagger-jaxrs2-jakarta</artifactId>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-integration</artifactId>
<artifactId>swagger-integration-jakarta</artifactId>
</dependency>
<dependency>
<groupId>net.jodah</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import com.sanctionco.thunder.openapi.OpenApiConfiguration;
import com.sanctionco.thunder.secrets.SecretSourceProvider;

import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import io.dropwizard.core.Application;
import io.dropwizard.core.setup.Bootstrap;
import io.dropwizard.core.setup.Environment;

/**
* Starts up the Thunder application. The run method will add resources, health checks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
import com.sanctionco.thunder.validation.PropertyValidationConfiguration;
import com.sanctionco.thunder.validation.email.EmailValidationConfiguration;

import io.dropwizard.Configuration;
import io.dropwizard.core.Configuration;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

import java.util.Optional;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
* Provides Thunder configuration options that are defined in the configuration file. The
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sanctionco.thunder;

import javax.ws.rs.core.Response;
import jakarta.ws.rs.core.Response;

/**
* An exception class that is the parent class of internal exceptions within
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.fasterxml.jackson.annotation.JsonTypeInfo;

import io.dropwizard.core.setup.Environment;
import io.dropwizard.jackson.Discoverable;
import io.dropwizard.setup.Environment;

/**
* Provides the base interface for {@code AuthConfiguration} objects. Implementing classes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import io.dropwizard.auth.AuthDynamicFeature;
import io.dropwizard.auth.AuthValueFactoryProvider;
import io.dropwizard.auth.basic.BasicCredentialAuthFilter;
import io.dropwizard.setup.Environment;
import io.dropwizard.core.setup.Environment;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

import java.security.Principal;
import java.util.Collections;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
* Provides the HTTP Basic Authentication implementation of {@link AuthConfiguration}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
import io.dropwizard.auth.AuthDynamicFeature;
import io.dropwizard.auth.AuthValueFactoryProvider;
import io.dropwizard.auth.oauth.OAuthCredentialAuthFilter;
import io.dropwizard.setup.Environment;
import io.dropwizard.core.setup.Environment;
import io.dropwizard.validation.ValidationMethod;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;

import java.security.Principal;
import java.security.interfaces.RSAPublicKey;
import java.util.Objects;
import java.util.Optional;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;

import javax.validation.Valid;
import jakarta.validation.Valid;

/**
* Provides optional configuration options for password hashing, including the hash algorithm.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.sanctionco.thunder.ThunderException;

import javax.ws.rs.core.Response;
import jakarta.ws.rs.core.Response;

/**
* Represents an exception that occurred during a database operation. Provides constructors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import com.sanctionco.thunder.dao.UsersDao;
import com.sanctionco.thunder.dao.UsersDaoFactory;

import jakarta.validation.constraints.NotEmpty;

import java.net.URI;
import java.util.Objects;
import javax.validation.constraints.NotEmpty;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import com.sanctionco.thunder.dao.UsersDao;
import com.sanctionco.thunder.dao.UsersDaoFactory;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
import com.sanctionco.thunder.dao.UsersDao;
import com.sanctionco.thunder.dao.UsersDaoFactory;

import jakarta.validation.constraints.NotEmpty;

import java.util.Objects;
import javax.validation.constraints.NotEmpty;

import org.bson.Document;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.sanctionco.thunder.openapi;

import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import io.dropwizard.views.ViewBundle;
import io.dropwizard.core.Configuration;
import io.dropwizard.core.ConfiguredBundle;
import io.dropwizard.core.setup.Bootstrap;
import io.dropwizard.core.setup.Environment;
import io.dropwizard.views.common.ViewBundle;
import io.swagger.v3.core.converter.ModelConverters;
import io.swagger.v3.core.jackson.ModelResolver;
import io.swagger.v3.jaxrs2.SwaggerSerializers;
Expand All @@ -17,8 +17,8 @@
import org.slf4j.LoggerFactory;

/**
* A {@link io.dropwizard.ConfiguredBundle} that provides configuration of Swagger and Swagger UI
* on top of Dropwizard.
* A {@link io.dropwizard.core.ConfiguredBundle} that provides configuration of Swagger
* and Swagger UI on top of Dropwizard.
*
* <p>Code originally taken from <a href="https://github.com/smoketurner/dropwizard-swagger">
* Dropwizard Swagger</a>, with modifications for this project.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import com.codahale.metrics.annotation.Metered;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Provides a API method to get Swagger UI for all available endpoints. The methods contained
* in this class are available at the {@code /swagger} endpoint, and return a HTML
* {@link io.dropwizard.views.View} in the response.
* {@link io.dropwizard.views.common.View} in the response.
*
* <p>Code originally taken from <a href="https://github.com/smoketurner/dropwizard-swagger">
* Dropwizard Swagger</a>, with modifications for this project.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sanctionco.thunder.openapi;

import io.dropwizard.views.View;
import io.dropwizard.views.common.View;

import java.nio.charset.StandardCharsets;
import javax.annotation.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

import io.dropwizard.util.Duration;

import jakarta.validation.Valid;
import jakarta.ws.rs.container.AsyncResponse;
import jakarta.ws.rs.core.Response;

import java.util.concurrent.TimeUnit;
import javax.validation.Valid;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.core.Response;

/**
* Provides optional configuration options for Thunder operations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@
import io.dropwizard.auth.Auth;
import io.swagger.v3.oas.annotations.Parameter;

import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.container.AsyncResponse;
import jakarta.ws.rs.container.Suspended;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import java.security.Principal;
import java.util.Objects;
import java.util.Optional;
import javax.inject.Inject;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,26 @@
import io.dropwizard.auth.Auth;
import io.swagger.v3.oas.annotations.Parameter;

import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.container.AsyncResponse;
import jakarta.ws.rs.container.Suspended;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriBuilder;
import jakarta.ws.rs.core.UriInfo;

import java.net.URI;
import java.security.Principal;
import java.util.Objects;
import java.util.UUID;
import javax.inject.Inject;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import io.dropwizard.jackson.Jackson;
import io.dropwizard.jersey.validation.Validators;

import jakarta.validation.Validator;

import java.io.IOException;
import java.io.InputStream;
import javax.validation.Validator;

import org.apache.commons.text.StringSubstitutor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.sanctionco.thunder.secrets.SecretProvider;

import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotEmpty;

import java.net.URI;
import java.time.Duration;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;

import net.jodah.failsafe.Failsafe;
import net.jodah.failsafe.RetryPolicy;
Expand Down

0 comments on commit 5d55001

Please sign in to comment.