1 package de.aikiit.bilanzanalyser.reader;
2
3 import org.junit.jupiter.api.Test;
4 import org.springframework.beans.factory.annotation.Value;
5 import org.springframework.boot.test.context.SpringBootTest;
6 import org.springframework.core.io.Resource;
7
8 import java.nio.file.Paths;
9
10 import static org.assertj.core.api.Assertions.assertThat;
11 import static org.junit.jupiter.api.Assertions.assertNotNull;
12
13 @SpringBootTest
14 class BilanzOdsReaderTest {
15
16 @Value("classpath:example-ausgaben.ods")
17 private Resource resource;
18
19 @Test
20 void createAndParseExampleData() throws Exception {
21 BilanzOdsReader reader = new BilanzOdsReader("Ausgaben", Paths.get(resource.getURI()));
22 assertNotNull(reader);
23 assertThat(reader.getSource()).hasFileName("example-ausgaben.ods");
24 assertThat(reader.getTableName()).isEqualTo("Ausgaben");
25
26 assertThat(reader.extractData().rows()).hasSize(140);
27 }
28
29 @Test
30 void createAndParseExampleDataForSpreadsheetNameThatDoesNotExist() throws Exception {
31 BilanzOdsReader reader = new BilanzOdsReader("NotExisting", Paths.get(resource.getURI()));
32 assertNotNull(reader);
33 assertThat(reader.extractData().isEmpty()).isTrue();
34 }
35
36 }