Skip to content

Commit

Permalink
feat: fixing tests and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina committed Nov 29, 2023
1 parent b7e4fe2 commit dbb9576
Show file tree
Hide file tree
Showing 16 changed files with 1,165 additions and 1,051 deletions.
81 changes: 58 additions & 23 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,45 @@
<lithium.version>3.6.0</lithium.version>
<dropwizard.version>4.0.0</dropwizard.version>
<jwt.version>0.11.5</jwt.version>
<junit5.version>5.8.2</junit5.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-bom</artifactId>
<version>${dropwizard.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-auth</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-assets</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard-bundles</groupId>
<artifactId>dropwizard-configurable-assets-bundle</artifactId>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.1.1</version>
</dependency>

<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
Expand Down Expand Up @@ -77,43 +113,42 @@
<version>${jwt.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.dropwizard-bundles</groupId>
<artifactId>dropwizard-configurable-assets-bundle</artifactId>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>io.dropwizard-bundles</groupId>
<artifactId>dropwizard-redirect-bundle</artifactId>
<version>1.3.5</version>
</dependency>

<!--TODO. replace with jakarta version?-->
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server-impl</artifactId>
<version>9.4.53.v20231009</version>
</dependency>

<!-- test dependencies-->
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-servlets</artifactId>
<version>${dropwizard.version}</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-testing</artifactId>
<version>${dropwizard.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.2.0</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -123,9 +158,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.dropwizard.modules</groupId>
<artifactId>dropwizard-testing-junit4</artifactId>
<version>${dropwizard.version}</version>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.224</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 0 additions & 2 deletions backend/roman.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ server:
requestLog:
appenders:
- type: ${APPENDER_TYPE:-console}
filterFactories:
- type: status-filter-factory

logging:
level: INFO
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.wire.bots.roman.DAO;

import com.wire.bots.roman.DAO.mappers.UUIDMapper;
import jakarta.annotation.Nullable;
import org.jdbi.v3.core.mapper.ColumnMapper;
import org.jdbi.v3.core.statement.StatementContext;
import org.jdbi.v3.sqlobject.config.RegisterColumnMapper;
import org.jdbi.v3.sqlobject.customizer.Bind;
import org.jdbi.v3.sqlobject.statement.SqlQuery;
import org.jdbi.v3.sqlobject.statement.SqlUpdate;

import javax.annotation.Nullable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.wire.bots.roman.DAO.mappers;

import com.wire.xenon.tools.Logger;
import jakarta.annotation.Nullable;
import org.jdbi.v3.core.mapper.ColumnMapper;
import org.jdbi.v3.core.statement.StatementContext;

import javax.annotation.Nullable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/java/com/wire/bots/roman/Sender.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import com.wire.xenon.exceptions.MissingStateException;
import com.wire.xenon.models.AssetKey;
import com.wire.xenon.tools.Logger;
import jakarta.annotation.Nullable;

import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Base64;
import java.util.UUID;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/java/com/wire/bots/roman/Tools.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.wire.bots.roman;

import io.jsonwebtoken.Jwts;
import jakarta.annotation.Nullable;

import javax.annotation.Nullable;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,53 @@
import com.wire.xenon.backend.models.Conversation;
import com.wire.xenon.backend.models.NewBot;
import com.wire.xenon.backend.models.User;
import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.DropwizardTestSupport;
import io.dropwizard.configuration.ResourceConfigurationSourceProvider;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.jdbi.v3.core.Jdbi;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Random;
import java.util.UUID;

import static io.dropwizard.testing.ConfigOverride.config;
import static org.assertj.core.api.Assertions.assertThat;

@ExtendWith(DropwizardExtensionsSupport.class)
public class BroadcastResourceTest {
private static final String BOT_CLIENT_DUMMY = "bot_client_dummy";
private static final DropwizardTestSupport<Config> SUPPORT = new DropwizardTestSupport<>(
Application.class, "roman.yaml",
ConfigOverride.config("key", "TcZA2Kq4GaOcIbQuOvasrw34321cZAfLW4Ga54fsds43hUuOdcdm42"),
ConfigOverride.config("apiHost", "http://localhost:8090"));
private static final String CONFIG = "roman-test.yml";
@TempDir
static Path tempDir;
static final DropwizardAppExtension<Config> SUPPORT = new DropwizardAppExtension<>(
Application.class, CONFIG,
new ResourceConfigurationSourceProvider(),
config("database.url", () -> "jdbc:h2:" + tempDir.resolve("database.h2")),
config("key", "TcZA2Kq4GaOcIbQuOvasrw34321cZAfLW4Ga54fsds43hUuOdcdm42"),
config("apiHost", "http://localhost:8090"));
private Client client;
private Jdbi jdbi;

@Before
@BeforeEach
public void beforeClass() throws Exception {
SUPPORT.before();
Application app = SUPPORT.getApplication();
client = app.getClient();
jdbi = app.getJdbi();
}

@After
@AfterEach
public void afterClass() {
SUPPORT.after();
}
Expand Down
Loading

0 comments on commit dbb9576

Please sign in to comment.