Skip to content
Snippets Groups Projects
Commit 4df3ec43 authored by Martin Weise's avatar Martin Weise
Browse files

Refactoring complete

Former-commit-id: c434a305
parent 21de7787
Branches
Tags
1 merge request!42Fixed the query service tests
Showing
with 382 additions and 322 deletions
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>fda-query-service</artifactId>
<groupId>at.tuwien</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>api</artifactId>
<name>fda-query-service-api</name>
<properties>
<jacoco.version>0.8.7</jacoco.version>
</properties>
<dependencies />
</project>
\ No newline at end of file
package at.tuwien;
import lombok.*;
import java.util.Collection;
import java.util.List;
@Getter
@Setter
@ToString
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class InsertTableRawQuery {
private String query;
private List<Collection<Object>> values;
}
......@@ -19,6 +19,7 @@
<module>rest-service</module>
<module>services</module>
<module>report</module>
<module>api</module>
</modules>
<properties>
......@@ -30,6 +31,7 @@
<swagger.version>2.1.7</swagger.version>
<springfox.version>3.0.0</springfox.version>
<jacoco.version>0.8.7</jacoco.version>
<opencsv.version>5.4</opencsv.version>
</properties>
<dependencies>
......@@ -41,6 +43,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency><!-- https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#validation-starter-no-longer-included-in-web-starters -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
......@@ -139,6 +145,18 @@
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<!-- AMPQ -->
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>${rabbit-amqp-client.version}</version>
</dependency>
<!-- DTO -->
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>${opencsv.version}</version>
</dependency>
<!-- SQL Parser -->
<dependency>
<groupId>com.github.jsqlparser</groupId>
......
......@@ -3,14 +3,12 @@ package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.api.database.table.TableCsvDto;
import at.tuwien.config.DockerConfig;
import at.tuwien.config.MariaDbConfig;
import at.tuwien.config.ReadyConfig;
import at.tuwien.exception.DatabaseNotFoundException;
import at.tuwien.exception.ImageNotSupportedException;
import at.tuwien.exception.TableNotFoundException;
import at.tuwien.repository.jpa.ImageRepository;
import at.tuwien.repository.jpa.TableRepository;
import com.aventrix.jnanoid.jnanoid.NanoIdUtils;
import com.github.dockerjava.api.command.CreateContainerResponse;
import com.github.dockerjava.api.exception.NotModifiedException;
import com.github.dockerjava.api.model.Bind;
......@@ -40,162 +38,162 @@ import static at.tuwien.config.DockerConfig.hostConfig;
@Log4j2
public class DataEndpointQueueIntegrationTest extends BaseUnitTest {
@MockBean
private Channel channel;
@MockBean
private ReadyConfig readyConfig;
@Autowired
private DataEndpoint dataEndpoint;
@Autowired
private TableRepository tableRepository;
@Autowired
private ImageRepository imageRepository;
/**
* We need a container to test the CRUD operations as of now it is unfeasible to determine the correctness of the
* operations without a live container
*
* @throws InterruptedException Sleep interrupted.
*/
@BeforeAll
public static void beforeAll() throws InterruptedException {
afterAll();
/* create networks */
dockerClient.createNetworkCmd()
.withName(BROKER_NET)
.withIpam(new Network.Ipam()
.withConfig(new Network.Ipam.Config()
.withSubnet("172.29.0.0/16")))
.withEnableIpv6(false)
.exec();
dockerClient.createNetworkCmd()
.withName(DATABASE_NET)
.withIpam(new Network.Ipam()
.withConfig(new Network.Ipam.Config()
.withSubnet("172.28.0.0/16")))
.withEnableIpv6(false)
.exec();
/* create broker container */
final CreateContainerResponse response1 = dockerClient.createContainerCmd(BROKER_IMAGE)
.withHostConfig(hostConfig.withNetworkMode(BROKER_NET))
.withName(BROKER_INTERNALNAME)
.withIpv4Address(BROKER_IP)
.withHostName(BROKER_INTERNALNAME)
.withEnv("TZ=Europe/Vienna")
.exec();
dockerClient.startContainerCmd(response1.getId())
.exec();
/* create table container */
final String bind = new File("./src/test/resources/weather").toPath().toAbsolutePath() + ":/docker-entrypoint-initdb.d";
log.trace("container bind {}", bind);
final CreateContainerResponse response2 = dockerClient.createContainerCmd(IMAGE_1_REPOSITORY + ":" + IMAGE_1_TAG)
.withHostConfig(hostConfig.withNetworkMode(DATABASE_NET))
.withName(CONTAINER_1_INTERNALNAME)
.withIpv4Address(CONTAINER_1_IP)
.withHostName(CONTAINER_1_INTERNALNAME)
.withEnv("MARIADB_USER=mariadb", "MARIADB_PASSWORD=mariadb", "MARIADB_ROOT_PASSWORD=mariadb", "MARIADB_DATABASE=weather")
.withBinds(Bind.parse(bind))
.exec();
/* wait */
CONTAINER_1.setHash(response2.getId());
Thread.sleep(10 * 1000);
}
@AfterAll
public static void afterAll() {
/* stop containers and remove them */
dockerClient.listContainersCmd()
.withShowAll(true)
.exec()
.forEach(container -> {
log.info("Delete container {}", Arrays.asList(container.getNames()));
try {
dockerClient.stopContainerCmd(container.getId()).exec();
} catch (NotModifiedException e) {
// ignore
}
dockerClient.removeContainerCmd(container.getId()).exec();
});
/* remove networks */
dockerClient.listNetworksCmd()
.exec()
.stream()
.filter(n -> n.getName().startsWith("fda"))
.forEach(network -> {
log.info("Delete network {}", network.getName());
dockerClient.removeNetworkCmd(network.getId()).exec();
});
}
@BeforeEach
@Transactional
public void beforeEach() {
imageRepository.save(IMAGE_1);
TABLE_1.setDatabase(DATABASE_1);
tableRepository.save(TABLE_1);
}
@Test
public void insertFromTuple_succeeds() throws TableNotFoundException, TableMalformedException,
DatabaseNotFoundException, ImageNotSupportedException, InterruptedException, SQLException {
final TableCsvDto request = TableCsvDto.builder()
.data(List.of(new LinkedHashMap<>() {{
put(COLUMN_1_1_NAME, 1L);
put(COLUMN_1_2_NAME, "2020-12-01");
put(COLUMN_1_3_NAME, "Somewhere");
put(COLUMN_1_4_NAME, 15.0);
put(COLUMN_1_5_NAME, 20.0);
}}))
.build();
/* mock */
DockerConfig.startContainer(CONTAINER_1);
MariaDbConfig.clearDatabase(TABLE_1);
/* test */
dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
assertTrue(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, 1L));
assertFalse(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, 2L));
}
@Test
public void insertFromTuple_10k_succeeds() throws TableNotFoundException, TableMalformedException,
DatabaseNotFoundException, ImageNotSupportedException, InterruptedException, SQLException {
/* config */
final long limit = 10_000L;
/* mock */
final Random random = new Random();
final List<Map<String, Object>> data = new LinkedList<>();
for (long i = 0L; i <= limit; i++) {
final Long id = i;
data.add(new LinkedHashMap<>() {{
put(COLUMN_1_1_NAME, id);
put(COLUMN_1_2_NAME, "2020-01-01");
put(COLUMN_1_3_NAME, NanoIdUtils.randomNanoId());
put(COLUMN_1_4_NAME, random.nextDouble());
put(COLUMN_1_5_NAME, random.nextDouble());
}});
}
final TableCsvDto request = TableCsvDto.builder()
.data(data)
.build();
DockerConfig.startContainer(CONTAINER_1);
MariaDbConfig.clearDatabase(TABLE_1);
/* test */
final long start = System.currentTimeMillis();
dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
final long end = System.currentTimeMillis();
log.info("Inserted {}k records in {} seconds", limit / 1000, (end - start) / 1000.0);
assertTrue(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, 1L), "id 1 missing");
assertTrue(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, 1_000L), "id 1k missing");
assertTrue(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, 10_000L), "id 10k missing");
assertTrue(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, limit), "id 100k missing");
}
// @MockBean
// private Channel channel;
//
// @MockBean
// private ReadyConfig readyConfig;
//
// @Autowired
// private DataEndpoint dataEndpoint;
//
// @Autowired
// private TableRepository tableRepository;
//
// @Autowired
// private ImageRepository imageRepository;
//
// /**
// * We need a container to test the CRUD operations as of now it is unfeasible to determine the correctness of the
// * operations without a live container
// *
// * @throws InterruptedException Sleep interrupted.
// */
// @BeforeAll
// public static void beforeAll() throws InterruptedException {
// afterAll();
// /* create networks */
// dockerClient.createNetworkCmd()
// .withName(BROKER_NET)
// .withIpam(new Network.Ipam()
// .withConfig(new Network.Ipam.Config()
// .withSubnet("172.29.0.0/16")))
// .withEnableIpv6(false)
// .exec();
// dockerClient.createNetworkCmd()
// .withName(DATABASE_NET)
// .withIpam(new Network.Ipam()
// .withConfig(new Network.Ipam.Config()
// .withSubnet("172.28.0.0/16")))
// .withEnableIpv6(false)
// .exec();
// /* create broker container */
// final CreateContainerResponse response1 = dockerClient.createContainerCmd(BROKER_IMAGE)
// .withHostConfig(hostConfig.withNetworkMode(BROKER_NET))
// .withName(BROKER_INTERNALNAME)
// .withIpv4Address(BROKER_IP)
// .withHostName(BROKER_INTERNALNAME)
// .withEnv("TZ=Europe/Vienna")
// .exec();
// dockerClient.startContainerCmd(response1.getId())
// .exec();
// /* create table container */
// final String bind = new File("./src/test/resources/weather").toPath().toAbsolutePath() + ":/docker-entrypoint-initdb.d";
// log.trace("container bind {}", bind);
// final CreateContainerResponse response2 = dockerClient.createContainerCmd(IMAGE_1_REPOSITORY + ":" + IMAGE_1_TAG)
// .withHostConfig(hostConfig.withNetworkMode(DATABASE_NET))
// .withName(CONTAINER_1_INTERNALNAME)
// .withIpv4Address(CONTAINER_1_IP)
// .withHostName(CONTAINER_1_INTERNALNAME)
// .withEnv("MARIADB_USER=mariadb", "MARIADB_PASSWORD=mariadb", "MARIADB_ROOT_PASSWORD=mariadb", "MARIADB_DATABASE=weather")
// .withBinds(Bind.parse(bind))
// .exec();
// /* wait */
// CONTAINER_1.setHash(response2.getId());
// Thread.sleep(10 * 1000);
// }
//
// @AfterAll
// public static void afterAll() {
// /* stop containers and remove them */
// dockerClient.listContainersCmd()
// .withShowAll(true)
// .exec()
// .forEach(container -> {
// log.info("Delete container {}", Arrays.asList(container.getNames()));
// try {
// dockerClient.stopContainerCmd(container.getId()).exec();
// } catch (NotModifiedException e) {
// // ignore
// }
// dockerClient.removeContainerCmd(container.getId()).exec();
// });
// /* remove networks */
// dockerClient.listNetworksCmd()
// .exec()
// .stream()
// .filter(n -> n.getName().startsWith("fda"))
// .forEach(network -> {
// log.info("Delete network {}", network.getName());
// dockerClient.removeNetworkCmd(network.getId()).exec();
// });
// }
//
// @BeforeEach
// @Transactional
// public void beforeEach() {
// imageRepository.save(IMAGE_1);
// TABLE_1.setDatabase(DATABASE_1);
// tableRepository.save(TABLE_1);
// }
//
// @Test
// public void insertFromTuple_succeeds() throws TableNotFoundException, TableMalformedException,
// DatabaseNotFoundException, ImageNotSupportedException, InterruptedException, SQLException {
// final TableCsvDto request = TableCsvDto.builder()
// .data(List.of(new LinkedHashMap<>() {{
// put(COLUMN_1_1_NAME, 1L);
// put(COLUMN_1_2_NAME, "2020-12-01");
// put(COLUMN_1_3_NAME, "Somewhere");
// put(COLUMN_1_4_NAME, 15.0);
// put(COLUMN_1_5_NAME, 20.0);
// }}))
// .build();
//
// /* mock */
// DockerConfig.startContainer(CONTAINER_1);
// MariaDbConfig.clearDatabase(TABLE_1);
//
// /* test */
// dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
// assertTrue(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, 1L));
// assertFalse(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, 2L));
// }
//
// @Test
// public void insertFromTuple_10k_succeeds() throws TableNotFoundException, TableMalformedException,
// DatabaseNotFoundException, ImageNotSupportedException, InterruptedException, SQLException {
// /* config */
// final long limit = 10_000L;
//
// /* mock */
// final Random random = new Random();
// final List<Map<String, Object>> data = new LinkedList<>();
// for (long i = 0L; i <= limit; i++) {
// final Long id = i;
// data.add(new LinkedHashMap<>() {{
// put(COLUMN_1_1_NAME, id);
// put(COLUMN_1_2_NAME, "2020-01-01");
// put(COLUMN_1_3_NAME, NanoIdUtils.randomNanoId());
// put(COLUMN_1_4_NAME, random.nextDouble());
// put(COLUMN_1_5_NAME, random.nextDouble());
// }});
// }
// final TableCsvDto request = TableCsvDto.builder()
// .data(data)
// .build();
// DockerConfig.startContainer(CONTAINER_1);
// MariaDbConfig.clearDatabase(TABLE_1);
//
// /* test */
// final long start = System.currentTimeMillis();
// dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
// final long end = System.currentTimeMillis();
// log.info("Inserted {}k records in {} seconds", limit / 1000, (end - start) / 1000.0);
// assertTrue(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, 1L), "id 1 missing");
// assertTrue(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, 1_000L), "id 1k missing");
// assertTrue(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, 10_000L), "id 10k missing");
// assertTrue(MariaDbConfig.contains(TABLE_1, COLUMN_1_1_NAME, limit), "id 100k missing");
// }
}
......@@ -3,7 +3,6 @@ package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.api.database.table.TableCsvDto;
import at.tuwien.config.DockerConfig;
import at.tuwien.config.MariaDbConfig;
import at.tuwien.config.ReadyConfig;
import at.tuwien.exception.DatabaseConnectionException;
import at.tuwien.exception.DatabaseNotFoundException;
......@@ -50,167 +49,167 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(SpringExtension.class)
public class DataEndpointRestIntegrationTest extends BaseUnitTest {
@MockBean
private Channel channel;
@MockBean
private ReadyConfig readyConfig;
@Autowired
private ImageRepository imageRepository;
@Autowired
private TableRepository tableRepository;
@Autowired
private DatabaseRepository databaseRepository;
@Autowired
private DataEndpoint dataEndpoint;
@BeforeAll
public static void beforeAll() throws InterruptedException {
afterAll();
/* create network */
dockerClient.createNetworkCmd()
.withName("fda-userdb")
.withIpam(new Network.Ipam()
.withConfig(new Network.Ipam.Config()
.withSubnet("172.28.0.0/16")))
.withEnableIpv6(false)
.exec();
/* create container */
final String bind = new File("./src/test/resources/weather").toPath().toAbsolutePath() + ":/docker-entrypoint-initdb.d";
log.trace("container bind {}", bind);
final CreateContainerResponse response = dockerClient.createContainerCmd(IMAGE_1_REPOSITORY + ":" + IMAGE_1_TAG)
.withHostConfig(hostConfig.withNetworkMode("fda-userdb"))
.withName(CONTAINER_1_INTERNALNAME)
.withIpv4Address(CONTAINER_1_IP)
.withHostName(CONTAINER_1_INTERNALNAME)
.withEnv("MARIADB_USER=mariadb", "MARIADB_PASSWORD=mariadb", "MARIADB_ROOT_PASSWORD=mariadb", "MARIADB_DATABASE=weather")
.withBinds(Bind.parse(bind))
.exec();
/* set hash */
CONTAINER_1.setHash(response.getId());
}
@Transactional
@BeforeEach
public void beforeEach() {
imageRepository.save(IMAGE_1);
databaseRepository.save(DATABASE_1);
TABLE_1.setDatabase(DATABASE_1);
tableRepository.save(TABLE_1);
}
@AfterAll
public static void afterAll() {
/* stop containers and remove them */
dockerClient.listContainersCmd()
.withShowAll(true)
.exec()
.forEach(container -> {
log.info("Delete container {}", Arrays.asList(container.getNames()));
try {
dockerClient.stopContainerCmd(container.getId()).exec();
} catch (NotModifiedException e) {
// ignore
}
dockerClient.removeContainerCmd(container.getId()).exec();
});
/* remove networks */
dockerClient.listNetworksCmd()
.exec()
.stream()
.filter(n -> n.getName().startsWith("fda"))
.forEach(network -> {
log.info("Delete network {}", network.getName());
dockerClient.removeNetworkCmd(network.getId()).exec();
});
}
@Test
public void insertFromTuple_succeeds() throws TableNotFoundException, TableMalformedException,
DatabaseNotFoundException, ImageNotSupportedException, SQLException, InterruptedException {
final Map<String, Object> map = new LinkedHashMap<>() {{
put(COLUMN_1_1_NAME, 4);
put(COLUMN_1_2_NAME, "2020-11-01");
put(COLUMN_1_3_NAME, "Sydney");
put(COLUMN_1_4_NAME, 35.2);
put(COLUMN_1_5_NAME, 10.2);
}};
final TableCsvDto request = TableCsvDto.builder()
.data(List.of(map))
.build();
/* mock */
DockerConfig.startContainer(CONTAINER_1);
MariaDbConfig.clearDatabase(TABLE_1);
/* test */
final ResponseEntity<?> response = dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
}
@Test
public void insertFromTuple_empty_succeeds() throws SQLException, TableNotFoundException, TableMalformedException,
DatabaseNotFoundException, ImageNotSupportedException {
final TableCsvDto request = TableCsvDto.builder()
.data(List.of())
.build();
/* mock */
MariaDbConfig.clearDatabase(TABLE_1);
/* test */
dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
}
@Test
public void insertFromTuple_empty2_succeeds() throws SQLException, InterruptedException, TableNotFoundException,
TableMalformedException, DatabaseNotFoundException, ImageNotSupportedException {
final TableCsvDto request = TableCsvDto.builder()
.data(List.of(Map.of()))
.build();
/* mock */
DockerConfig.startContainer(CONTAINER_1);
MariaDbConfig.clearDatabase(TABLE_1);
/* test */
dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
}
@Test
public void insertFromFile_succeeds() throws TableNotFoundException, TableMalformedException,
DatabaseNotFoundException, ImageNotSupportedException, FileStorageException, SQLException,
InterruptedException {
final String request = "test:csv/csv_01.csv";
/* mock */
DockerConfig.startContainer(CONTAINER_1);
MariaDbConfig.clearDatabase(TABLE_1);
/* test */
final ResponseEntity<?> response = dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
}
@Test
public void getAll_succeeds() throws TableNotFoundException, TableMalformedException,
DatabaseNotFoundException, ImageNotSupportedException, SQLException, DatabaseConnectionException,
InterruptedException, PaginationException {
final Instant timestamp = Instant.now();
final Long page = 0L;
final Long size = 1L;
/* mock */
DockerConfig.startContainer(CONTAINER_1);
MariaDbConfig.clearDatabase(TABLE_1);
/* test */
final ResponseEntity<?> response = dataEndpoint.getAll(DATABASE_1_ID, TABLE_1_ID, timestamp, page, size);
assertEquals(HttpStatus.OK, response.getStatusCode());
}
// @MockBean
// private Channel channel;
//
// @MockBean
// private ReadyConfig readyConfig;
//
// @Autowired
// private ImageRepository imageRepository;
//
// @Autowired
// private TableRepository tableRepository;
//
// @Autowired
// private DatabaseRepository databaseRepository;
//
// @Autowired
// private DataEndpoint dataEndpoint;
//
// @BeforeAll
// public static void beforeAll() throws InterruptedException {
// afterAll();
// /* create network */
// dockerClient.createNetworkCmd()
// .withName("fda-userdb")
// .withIpam(new Network.Ipam()
// .withConfig(new Network.Ipam.Config()
// .withSubnet("172.28.0.0/16")))
// .withEnableIpv6(false)
// .exec();
// /* create container */
// final String bind = new File("./src/test/resources/weather").toPath().toAbsolutePath() + ":/docker-entrypoint-initdb.d";
// log.trace("container bind {}", bind);
// final CreateContainerResponse response = dockerClient.createContainerCmd(IMAGE_1_REPOSITORY + ":" + IMAGE_1_TAG)
// .withHostConfig(hostConfig.withNetworkMode("fda-userdb"))
// .withName(CONTAINER_1_INTERNALNAME)
// .withIpv4Address(CONTAINER_1_IP)
// .withHostName(CONTAINER_1_INTERNALNAME)
// .withEnv("MARIADB_USER=mariadb", "MARIADB_PASSWORD=mariadb", "MARIADB_ROOT_PASSWORD=mariadb", "MARIADB_DATABASE=weather")
// .withBinds(Bind.parse(bind))
// .exec();
// /* set hash */
// CONTAINER_1.setHash(response.getId());
// }
//
// @Transactional
// @BeforeEach
// public void beforeEach() {
// imageRepository.save(IMAGE_1);
// databaseRepository.save(DATABASE_1);
// TABLE_1.setDatabase(DATABASE_1);
// tableRepository.save(TABLE_1);
// }
//
// @AfterAll
// public static void afterAll() {
// /* stop containers and remove them */
// dockerClient.listContainersCmd()
// .withShowAll(true)
// .exec()
// .forEach(container -> {
// log.info("Delete container {}", Arrays.asList(container.getNames()));
// try {
// dockerClient.stopContainerCmd(container.getId()).exec();
// } catch (NotModifiedException e) {
// // ignore
// }
// dockerClient.removeContainerCmd(container.getId()).exec();
// });
// /* remove networks */
// dockerClient.listNetworksCmd()
// .exec()
// .stream()
// .filter(n -> n.getName().startsWith("fda"))
// .forEach(network -> {
// log.info("Delete network {}", network.getName());
// dockerClient.removeNetworkCmd(network.getId()).exec();
// });
// }
//
// @Test
// public void insertFromTuple_succeeds() throws TableNotFoundException, TableMalformedException,
// DatabaseNotFoundException, ImageNotSupportedException, SQLException, InterruptedException {
// final Map<String, Object> map = new LinkedHashMap<>() {{
// put(COLUMN_1_1_NAME, 4);
// put(COLUMN_1_2_NAME, "2020-11-01");
// put(COLUMN_1_3_NAME, "Sydney");
// put(COLUMN_1_4_NAME, 35.2);
// put(COLUMN_1_5_NAME, 10.2);
// }};
// final TableCsvDto request = TableCsvDto.builder()
// .data(List.of(map))
// .build();
//
// /* mock */
// DockerConfig.startContainer(CONTAINER_1);
// MariaDbConfig.clearDatabase(TABLE_1);
//
// /* test */
// final ResponseEntity<?> response = dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
// assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
// }
//
// @Test
// public void insertFromTuple_empty_succeeds() throws SQLException, TableNotFoundException, TableMalformedException,
// DatabaseNotFoundException, ImageNotSupportedException {
// final TableCsvDto request = TableCsvDto.builder()
// .data(List.of())
// .build();
//
// /* mock */
// MariaDbConfig.clearDatabase(TABLE_1);
//
// /* test */
// dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
// }
//
// @Test
// public void insertFromTuple_empty2_succeeds() throws SQLException, InterruptedException, TableNotFoundException,
// TableMalformedException, DatabaseNotFoundException, ImageNotSupportedException {
// final TableCsvDto request = TableCsvDto.builder()
// .data(List.of(Map.of()))
// .build();
//
// /* mock */
// DockerConfig.startContainer(CONTAINER_1);
// MariaDbConfig.clearDatabase(TABLE_1);
//
// /* test */
// dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
// }
//
// @Test
// public void insertFromFile_succeeds() throws TableNotFoundException, TableMalformedException,
// DatabaseNotFoundException, ImageNotSupportedException, FileStorageException, SQLException,
// InterruptedException {
// final String request = "test:csv/csv_01.csv";
//
// /* mock */
// DockerConfig.startContainer(CONTAINER_1);
// MariaDbConfig.clearDatabase(TABLE_1);
//
// /* test */
// final ResponseEntity<?> response = dataEndpoint.insert(DATABASE_1_ID, TABLE_1_ID, request);
// assertEquals(HttpStatus.ACCEPTED, response.getStatusCode());
// }
//
// @Test
// public void getAll_succeeds() throws TableNotFoundException, TableMalformedException,
// DatabaseNotFoundException, ImageNotSupportedException, SQLException, DatabaseConnectionException,
// InterruptedException, PaginationException {
// final Instant timestamp = Instant.now();
// final Long page = 0L;
// final Long size = 1L;
//
// /* mock */
// DockerConfig.startContainer(CONTAINER_1);
// MariaDbConfig.clearDatabase(TABLE_1);
//
// /* test */
// final ResponseEntity<?> response = dataEndpoint.getAll(DATABASE_1_ID, TABLE_1_ID, timestamp, page, size);
// assertEquals(HttpStatus.OK, response.getStatusCode());
// }
}
......@@ -2,6 +2,7 @@ package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.config.ReadyConfig;
import com.rabbitmq.client.Channel;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
......@@ -12,6 +13,9 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@SpringBootTest
public class EndpointUnitTest extends BaseUnitTest {
@MockBean
private Channel channel;
@MockBean
private ReadyConfig readyConfig;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment