From 408c8a82421a7d35aef97a2605a13a842643aaa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Wed, 9 Sep 2020 16:26:42 +0200 Subject: [PATCH] Removed ConfiguratorTest.java, and rewrite it into configutils/FileToDatabaseMigratorTest.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../java/com/plannaplan/ConfiguratorTest.java | 50 ------------------- .../FileToDatabaseMigratorTest.java | 49 +++++++++++++++--- 2 files changed, 41 insertions(+), 58 deletions(-) delete mode 100644 buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java diff --git a/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java b/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java deleted file mode 100644 index 102c5a1..0000000 --- a/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.plannaplan; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.junit.Assert.assertTrue; - -import java.io.InputStream; - -import com.plannaplan.models.ConfigData; -import com.plannaplan.services.CourseService; -import com.plannaplan.services.GroupService; -import com.plannaplan.services.LecturerService; - -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(SpringRunner.class) -@SpringBootTest -@ContextConfiguration -public class ConfiguratorTest { - - private static String FILE_NAME = "Zajecia.xlsx"; - - @Autowired - private Configurator restTemplate; - - @Autowired - private CourseService courseService; - - @Autowired - private GroupService groupService; - - @Autowired - private LecturerService lecturerService; - - @Test - public void shouldImportDataFromFileToDatabase() throws Exception { - final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME); - final ConfigData data = new ConfigData(null, null, inputStream); - this.restTemplate.config(data); - int courses_ammount = this.courseService.getCoursesAmmount(); - int groups_ammount = this.groupService.getGroupsAmmount(); - int lecturers_ammount = this.lecturerService.getLecturersAmmount(); - - assertTrue(courses_ammount > 0 && groups_ammount > 0 && lecturers_ammount > 0); - } -} \ No newline at end of file diff --git a/buisnesslogic/src/test/java/com/plannaplan/configutils/FileToDatabaseMigratorTest.java b/buisnesslogic/src/test/java/com/plannaplan/configutils/FileToDatabaseMigratorTest.java index 36afe31..65dc116 100644 --- a/buisnesslogic/src/test/java/com/plannaplan/configutils/FileToDatabaseMigratorTest.java +++ b/buisnesslogic/src/test/java/com/plannaplan/configutils/FileToDatabaseMigratorTest.java @@ -1,19 +1,52 @@ package com.plannaplan.configutils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.Assert.assertTrue; + import java.io.InputStream; -import com.plannaplan.models.FileData; +import com.plannaplan.Configurator; +import com.plannaplan.models.ConfigData; +import com.plannaplan.services.CourseService; +import com.plannaplan.services.GroupService; +import com.plannaplan.services.LecturerService; import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(SpringRunner.class) +@SpringBootTest +@ContextConfiguration public class FileToDatabaseMigratorTest { + + private static String FILE_NAME = "Zajecia.xlsx"; + + @Autowired + private Configurator restTemplate; + + @Autowired + private CourseService courseService; + + @Autowired + private GroupService groupService; + + @Autowired + private LecturerService lecturerService; + @Test - public void shouldInsertToDatabase() { - // FileToDatabaseMigrator migrator = new FileToDatabaseMigrator(); - // InputStream inputStream = - // getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx"); - // FileReader r = new FileReader(inputStream); - // FileData d = r.read(); - // migrator.migrate(d); + public void shouldImportDataFromFileToDatabase() throws Exception { + final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME); + final ConfigData data = new ConfigData(null, null, inputStream); + this.restTemplate.config(data); + int courses_ammount = this.courseService.getCoursesAmmount(); + int groups_ammount = this.groupService.getGroupsAmmount(); + int lecturers_ammount = this.lecturerService.getLecturersAmmount(); + + assertTrue(courses_ammount > 0 && groups_ammount > 0 && lecturers_ammount > 0); } } \ No newline at end of file