diff --git a/buisnesslogic/pom.xml b/buisnesslogic/pom.xml index 77e0dd0..0306b93 100644 --- a/buisnesslogic/pom.xml +++ b/buisnesslogic/pom.xml @@ -12,8 +12,7 @@ 1.0-SNAPSHOT buisnesslogic - - http://www.example.com + http://plannaplan.pl UTF-8 @@ -25,11 +24,20 @@ junit junit - 4.11 + 4.12 test - - + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + javax.xml.bind jaxb-api diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java b/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java index e5933cc..446faea 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java @@ -24,4 +24,8 @@ public class CourseService { public void save(Course course) { this.repo.save(course); } + + public int getCoursesAmmount(){ + return (int)this.repo.count(); + } } \ No newline at end of file diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/GroupService.java b/buisnesslogic/src/main/java/com/plannaplan/services/GroupService.java index dee884b..e899dd8 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/services/GroupService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/GroupService.java @@ -27,4 +27,8 @@ public class GroupService { public void save(Groups group) { this.repo.save(group); } + + public int getGroupsAmmount(){ + return (int)this.repo.count(); + } } \ No newline at end of file diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java b/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java index 2eb1415..650fd42 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java @@ -18,4 +18,8 @@ public class LecturerService { public void save(Lecturer lecturer) { repo.save(lecturer); } + + public int getLecturersAmmount(){ + return (int)this.repo.count(); + } } \ No newline at end of file diff --git a/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java b/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java new file mode 100644 index 0000000..102c5a1 --- /dev/null +++ b/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java @@ -0,0 +1,50 @@ +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/TestApplication.java b/buisnesslogic/src/test/java/com/plannaplan/TestApplication.java new file mode 100644 index 0000000..613d816 --- /dev/null +++ b/buisnesslogic/src/test/java/com/plannaplan/TestApplication.java @@ -0,0 +1,8 @@ +package com.plannaplan; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class TestApplication { + +}