// Path: ratelimitj-dropwizard/src/test/java/es/moki/ratelimij/dropwizard/component/app/RateLimitApplication.java
// public class RateLimitApplication extends Application<Configuration> {
// 
//     @Override
//     public void initialize(Bootstrap<Configuration> bootstrap) {
//         RedisClient redisClient = RedisClient.create("redis://localhost:7006");
//         RequestRateLimiterFactory factory = new RedisRateLimiterFactory(redisClient);
//         bootstrap.addBundle(new RateLimitBundle(factory));
//     }
// 
//     @Override
//     public void run(Configuration configuration, Environment environment) {
//         environment.jersey().register(new LoginResource());
//         environment.jersey().register(new UserResource());
//         environment.jersey().register(new TrekResource());
//         environment.jersey().register(new AuthDynamicFeature(
//                 new OAuthCredentialAuthFilter.Builder<PrincipalImpl>()
//                         .setAuthenticator(new TestOAuthAuthenticator()).setPrefix("Bearer")
//                         .buildAuthFilter()));
//         environment.jersey().register(RolesAllowedDynamicFeature.class);
//         environment.jersey().register(new AuthValueFactoryProvider.Binder<>(PrincipalImpl.class));
//     }
// }
// 
// Path: ratelimitj-dropwizard/src/test/java/es/moki/ratelimij/dropwizard/component/app/model/LoginRequest.java
// public class LoginRequest {
// 
//     public final String username;
// 
//     public final String password;
// 
//     @JsonCreator
//     public LoginRequest(@JsonProperty("username") String username,
//                         @JsonProperty("password") String password) {
//         this.username = username;
//         this.password = password;
//     }
// 
//     public String getUsername() {
//         return username;
//     }
// 
//     public String getPassword() {
//         return password;
//     }
// }
// 
// Path: ratelimitj-dropwizard/src/test/java/es/moki/ratelimij/dropwizard/extension/RedisStandaloneFlushExtension.java
// public class RedisStandaloneFlushExtension implements
//         BeforeAllCallback, AfterAllCallback, AfterEachCallback {
// 
//     private static RedisClient client;
//     private static StatefulRedisConnection<String, String> connect;
// 
//     @Override
//     @SuppressWarnings("FutureReturnValueIgnored")
//     public void afterAll(ExtensionContext context) {
//         client.shutdownAsync();
//     }
// 
//     @Override
//     public void afterEach(ExtensionContext context) {
//         connect.sync().flushdb();
//     }
// 
//     @Override
//     public void beforeAll(ExtensionContext context) {
//         client = RedisClient.create("redis://localhost:7006");
//         connect = client.connect();
//     }
// 
// }


import es.moki.ratelimij.dropwizard.component.app.RateLimitApplication;
import es.moki.ratelimij.dropwizard.component.app.model.LoginRequest;
import es.moki.ratelimitj.redis.extensions.RedisStandaloneFlushExtension;
import io.dropwizard.Configuration;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import java.util.stream.IntStream;
import static org.assertj.core.api.Assertions.assertThat;
package es.moki.ratelimij.dropwizard.component;




@ExtendWith({
        DropwizardExtensionsSupport.class,
        RedisStandaloneFlushExtension.class
})
public class DropwizardRateLimitComponentTest {

    private final DropwizardAppExtension<Configuration> app = new DropwizardAppExtension<>(
// Path: ratelimitj-dropwizard/src/test/java/es/moki/ratelimij/dropwizard/component/app/RateLimitApplication.java
// public class RateLimitApplication extends Application<Configuration> {
// 
//     @Override
//     public void initialize(Bootstrap<Configuration> bootstrap) {
//         RedisClient redisClient = RedisClient.create("redis://localhost:7006");
//         RequestRateLimiterFactory factory = new RedisRateLimiterFactory(redisClient);
//         bootstrap.addBundle(new RateLimitBundle(factory));
//     }
// 
//     @Override
//     public void run(Configuration configuration, Environment environment) {
//         environment.jersey().register(new LoginResource());
//         environment.jersey().register(new UserResource());
//         environment.jersey().register(new TrekResource());
//         environment.jersey().register(new AuthDynamicFeature(
//                 new OAuthCredentialAuthFilter.Builder<PrincipalImpl>()
//                         .setAuthenticator(new TestOAuthAuthenticator()).setPrefix("Bearer")
//                         .buildAuthFilter()));
//         environment.jersey().register(RolesAllowedDynamicFeature.class);
//         environment.jersey().register(new AuthValueFactoryProvider.Binder<>(PrincipalImpl.class));
//     }
// }
// 
// Path: ratelimitj-dropwizard/src/test/java/es/moki/ratelimij/dropwizard/component/app/model/LoginRequest.java
// public class LoginRequest {
// 
//     public final String username;
// 
//     public final String password;
// 
//     @JsonCreator
//     public LoginRequest(@JsonProperty("username") String username,
//                         @JsonProperty("password") String password) {
//         this.username = username;
//         this.password = password;
//     }
// 
//     public String getUsername() {
//         return username;
//     }
// 
//     public String getPassword() {
//         return password;
//     }
// }
// 
// Path: ratelimitj-dropwizard/src/test/java/es/moki/ratelimij/dropwizard/extension/RedisStandaloneFlushExtension.java
// public class RedisStandaloneFlushExtension implements
//         BeforeAllCallback, AfterAllCallback, AfterEachCallback {
// 
//     private static RedisClient client;
//     private static StatefulRedisConnection<String, String> connect;
// 
//     @Override
//     @SuppressWarnings("FutureReturnValueIgnored")
//     public void afterAll(ExtensionContext context) {
//         client.shutdownAsync();
//     }
// 
//     @Override
//     public void afterEach(ExtensionContext context) {
//         connect.sync().flushdb();
//     }
// 
//     @Override
//     public void beforeAll(ExtensionContext context) {
//         client = RedisClient.create("redis://localhost:7006");
//         connect = client.connect();
//     }
// 
// }


// Path: ratelimitj-dropwizard/src/test/java/es/moki/ratelimij/dropwizard/component/DropwizardRateLimitComponentTest.java
import es.moki.ratelimij.dropwizard.component.app.RateLimitApplication;
import es.moki.ratelimij.dropwizard.component.app.model.LoginRequest;
import es.moki.ratelimitj.redis.extensions.RedisStandaloneFlushExtension;
import io.dropwizard.Configuration;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import java.util.stream.IntStream;
import static org.assertj.core.api.Assertions.assertThat;

package es.moki.ratelimij.dropwizard.component;




@ExtendWith({
        DropwizardExtensionsSupport.class,
        RedisStandaloneFlushExtension.class
})
public class DropwizardRateLimitComponentTest {

    private final DropwizardAppExtension<Configuration> app = new DropwizardAppExtension<>(
            RateLimitApplication.class,