small fixes
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
qvalentin 2022-05-22 18:05:21 +02:00
parent 259c15b785
commit fd4a2c0e83
Signed by: qvalentin
GPG key ID: C979FA1EAFCABF1C
5 changed files with 31 additions and 22 deletions

View file

@ -13,7 +13,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
class GenericCSVDAOTest {
GenericCSVDAO<CategoryEntity> sut;
File file = new File("test.csv");
File file = File.createTempFile("test","link-ditch");
GenericCSVDAOTest() throws IOException {
}
@BeforeEach
public void beforeEach() throws IOException {
@ -35,8 +38,7 @@ class GenericCSVDAOTest {
public void addWorks() throws IOException {
assertEquals(0, sut.getALl().size());
var entityToAdd = new CategoryEntity("categoryName", 99);
sut.add(entityToAdd);
CategoryEntity entityToAdd = addDummyEntity("categoryName", 99);
var foundEntity = sut.getALl().stream().findFirst().orElseThrow();
assertEquals(entityToAdd, foundEntity);
@ -44,23 +46,27 @@ class GenericCSVDAOTest {
@Test
public void removeWorks() throws IOException {
var entityToAdd = new CategoryEntity("categoryName", 99);
sut.add(entityToAdd);
CategoryEntity entityToAdd = addDummyEntity("categoryName", 99);
sut.remove(entityToAdd);
assertEquals(0, sut.getALl().size());
}
@Test
public void removeAllWorks() throws IOException {
var entityToAdd1 = new CategoryEntity("categoryName1", 101);
sut.add(entityToAdd1);
var entityToAdd2 = new CategoryEntity("categoryName2", 102);
sut.add(entityToAdd2);
addDummyEntity("categoryName1", 101);
addDummyEntity("categoryName2", 102);
assertEquals(2, sut.getALl().size());
sut.removeAll();
assertEquals(0, sut.getALl().size());
}
private CategoryEntity addDummyEntity(String categoryName, int id) {
var entityToAdd = new CategoryEntity(categoryName, id);
sut.add(entityToAdd);
return entityToAdd;
}
}