From 9ea2912e98a62fd79bf909a95c8e650e625eacc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Thu, 3 Sep 2020 16:30:42 +0200 Subject: [PATCH 1/6] Added ConfiguratorTest.java. Updated pom.xml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- buisnesslogic/pom.xml | 13 ++++++-- .../configutils/ConfiguratorTest.java | 33 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 buisnesslogic/src/test/java/com/plannaplan/configutils/ConfiguratorTest.java diff --git a/buisnesslogic/pom.xml b/buisnesslogic/pom.xml index 77e0dd0..52928ba 100644 --- a/buisnesslogic/pom.xml +++ b/buisnesslogic/pom.xml @@ -28,8 +28,17 @@ 4.11 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/test/java/com/plannaplan/configutils/ConfiguratorTest.java b/buisnesslogic/src/test/java/com/plannaplan/configutils/ConfiguratorTest.java new file mode 100644 index 0000000..446c2d8 --- /dev/null +++ b/buisnesslogic/src/test/java/com/plannaplan/configutils/ConfiguratorTest.java @@ -0,0 +1,33 @@ +package com.plannaplan.configutils; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; + +import com.plannaplan.Configurator; +import com.plannaplan.models.ConfigData; + +import org.junit.Test; + +@SpringBootTest +public class ConfiguratorTest { + + @Autowired + private Configurator restTemplate; + + @Test + public void greetingShouldReturnDefaultMessage() throws Exception { + InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx"); + ConfigData data = new ConfigData(null,null,inputStream); + this.restTemplate.config(data); + assertTrue(true); + + } +} \ No newline at end of file From f6d4674ec847a41f4fbb2dfd5b3e9e6830a35743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Thu, 3 Sep 2020 16:59:27 +0200 Subject: [PATCH 2/6] Inny error, zmiana lokalizacji pliku MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../{configutils => }/ConfiguratorTest.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) rename buisnesslogic/src/test/java/com/plannaplan/{configutils => }/ConfiguratorTest.java (58%) diff --git a/buisnesslogic/src/test/java/com/plannaplan/configutils/ConfiguratorTest.java b/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java similarity index 58% rename from buisnesslogic/src/test/java/com/plannaplan/configutils/ConfiguratorTest.java rename to buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java index 446c2d8..66edbef 100644 --- a/buisnesslogic/src/test/java/com/plannaplan/configutils/ConfiguratorTest.java +++ b/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java @@ -1,31 +1,32 @@ -package com.plannaplan.configutils; +package com.plannaplan; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertTrue; import java.io.InputStream; +import com.plannaplan.App; import com.plannaplan.Configurator; import com.plannaplan.models.ConfigData; import org.junit.Test; +import org.junit.runner.RunWith; +@RunWith(SpringRunner.class) @SpringBootTest public class ConfiguratorTest { - + @Autowired private Configurator restTemplate; @Test public void greetingShouldReturnDefaultMessage() throws Exception { - InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx"); - ConfigData data = new ConfigData(null,null,inputStream); + final InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx"); + final ConfigData data = new ConfigData(null, null, inputStream); this.restTemplate.config(data); assertTrue(true); From b659f70a1f1e39548161f7c7e5604fca28fb5acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Thu, 3 Sep 2020 17:02:17 +0200 Subject: [PATCH 3/6] Changed version junit 4.11 to 4.12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- buisnesslogic/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buisnesslogic/pom.xml b/buisnesslogic/pom.xml index 52928ba..92358d6 100644 --- a/buisnesslogic/pom.xml +++ b/buisnesslogic/pom.xml @@ -25,7 +25,7 @@ junit junit - 4.11 + 4.12 test From 56e519dcd64fa236aadb5924fdba6b254db4c0c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Thu, 3 Sep 2020 17:09:35 +0200 Subject: [PATCH 4/6] Updated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- buisnesslogic/pom.xml | 3 +-- .../src/test/java/com/plannaplan/ConfiguratorTest.java | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/buisnesslogic/pom.xml b/buisnesslogic/pom.xml index 92358d6..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 diff --git a/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java b/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java index 66edbef..c12a293 100644 --- a/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java +++ b/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java @@ -2,6 +2,7 @@ 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.assertj.core.api.Assertions.assertThat; @@ -18,6 +19,7 @@ import org.junit.runner.RunWith; @RunWith(SpringRunner.class) @SpringBootTest +@ContextConfiguration public class ConfiguratorTest { @Autowired From 16b9cb3cf2277b4fa54f7fe2e4e4c071e80767e9 Mon Sep 17 00:00:00 2001 From: Filip Izydorczyk Date: Fri, 4 Sep 2020 16:09:57 +0200 Subject: [PATCH 5/6] Spring starts on test run --- .../src/test/java/com/plannaplan/TestApplication.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 buisnesslogic/src/test/java/com/plannaplan/TestApplication.java 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 { + +} From 7a7c882163c2fa1ef64064557518ca90154bc84c Mon Sep 17 00:00:00 2001 From: Filip Izydorczyk Date: Fri, 4 Sep 2020 16:24:00 +0200 Subject: [PATCH 6/6] Added config test --- .../plannaplan/services/CourseService.java | 4 +++ .../com/plannaplan/services/GroupService.java | 4 +++ .../plannaplan/services/LecturerService.java | 4 +++ .../java/com/plannaplan/ConfiguratorTest.java | 28 ++++++++++++++----- 4 files changed, 33 insertions(+), 7 deletions(-) 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 index c12a293..102c5a1 100644 --- a/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java +++ b/buisnesslogic/src/test/java/com/plannaplan/ConfiguratorTest.java @@ -5,14 +5,14 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; -import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertTrue; import java.io.InputStream; -import com.plannaplan.App; -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; @@ -22,15 +22,29 @@ import org.junit.runner.RunWith; @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 greetingShouldReturnDefaultMessage() throws Exception { - final InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx"); + 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); - assertTrue(true); - + 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