From 43660c4fe967e9691b1e0f48ce1900eb6555d082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Wed, 16 Sep 2020 17:14:37 +0200 Subject: [PATCH 1/7] Dodanie nowego testu do dodawnia kursu. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../services/CourseServiceTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 buisnesslogic/src/test/java/com/plannaplan/services/CourseServiceTest.java diff --git a/buisnesslogic/src/test/java/com/plannaplan/services/CourseServiceTest.java b/buisnesslogic/src/test/java/com/plannaplan/services/CourseServiceTest.java new file mode 100644 index 0000000..05e1a38 --- /dev/null +++ b/buisnesslogic/src/test/java/com/plannaplan/services/CourseServiceTest.java @@ -0,0 +1,32 @@ +package com.plannaplan.services; + +import static org.junit.Assert.assertTrue; + +import com.plannaplan.entities.Course; + +import org.junit.Test; +import org.junit.runner.RunWith; +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; + +@RunWith(SpringRunner.class) +@SpringBootTest +@ContextConfiguration +public class CourseServiceTest { + @Autowired + private CourseService courseService; + + @Test + public void shoulReturnYes() { + Course course; + int startAmmount = this.courseService.getCoursesAmmount(); + + course = new Course(); + course.setName("Testowy kurs"); + course.setSymbol("TK"); + courseService.save(course); + assertTrue(this.courseService.getCoursesAmmount() > startAmmount); + } +} From 283be6603d46c5f5fbdbfc476cfc15a6f2ccc50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Wed, 16 Sep 2020 17:15:56 +0200 Subject: [PATCH 2/7] Dodanie usuniecie kursu. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../src/main/java/com/plannaplan/services/CourseService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java b/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java index 446faea..755e801 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java @@ -25,6 +25,10 @@ public class CourseService { this.repo.save(course); } + public void remove(Course course){ + this.repo.delete(course); + } + public int getCoursesAmmount(){ return (int)this.repo.count(); } From 551011db1c6003407733011791b377c3a39d4613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Wed, 16 Sep 2020 17:21:01 +0200 Subject: [PATCH 3/7] Zmiana nazwy z Remove na Delete, dodanie testu na usuwanie. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../main/java/com/plannaplan/services/CourseService.java | 2 +- .../java/com/plannaplan/services/CourseServiceTest.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java b/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java index 755e801..15ae1aa 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java @@ -25,7 +25,7 @@ public class CourseService { this.repo.save(course); } - public void remove(Course course){ + public void delete(Course course){ this.repo.delete(course); } diff --git a/buisnesslogic/src/test/java/com/plannaplan/services/CourseServiceTest.java b/buisnesslogic/src/test/java/com/plannaplan/services/CourseServiceTest.java index 05e1a38..10a609f 100644 --- a/buisnesslogic/src/test/java/com/plannaplan/services/CourseServiceTest.java +++ b/buisnesslogic/src/test/java/com/plannaplan/services/CourseServiceTest.java @@ -19,14 +19,19 @@ public class CourseServiceTest { private CourseService courseService; @Test - public void shoulReturnYes() { + public void createAndDeleteCourse() { Course course; int startAmmount = this.courseService.getCoursesAmmount(); + // Create course course = new Course(); course.setName("Testowy kurs"); course.setSymbol("TK"); courseService.save(course); assertTrue(this.courseService.getCoursesAmmount() > startAmmount); + + // Delete course + courseService.delete(course); + assertTrue(this.courseService.getCoursesAmmount() == startAmmount); } } From d5e32a487b7a8b85651aad1abd36fa035c79e417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Wed, 16 Sep 2020 17:23:33 +0200 Subject: [PATCH 4/7] Added delete method in GroupService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../src/main/java/com/plannaplan/services/GroupService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/GroupService.java b/buisnesslogic/src/main/java/com/plannaplan/services/GroupService.java index e899dd8..3142411 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/services/GroupService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/GroupService.java @@ -28,6 +28,10 @@ public class GroupService { this.repo.save(group); } + public void delete(Groups groups){ + this.repo.delete(groups); + } + public int getGroupsAmmount(){ return (int)this.repo.count(); } From a717a85a809d7cc2ecdcb4657ca42caf0ec7f5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Wed, 16 Sep 2020 17:33:39 +0200 Subject: [PATCH 5/7] Created test GroupServiceTest.java. It contains createAndDeleteGroup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../plannaplan/services/GroupServiceTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 buisnesslogic/src/test/java/com/plannaplan/services/GroupServiceTest.java diff --git a/buisnesslogic/src/test/java/com/plannaplan/services/GroupServiceTest.java b/buisnesslogic/src/test/java/com/plannaplan/services/GroupServiceTest.java new file mode 100644 index 0000000..c6299cb --- /dev/null +++ b/buisnesslogic/src/test/java/com/plannaplan/services/GroupServiceTest.java @@ -0,0 +1,37 @@ +package com.plannaplan.services; + +import static org.junit.Assert.assertTrue; + +import com.plannaplan.entities.Groups; + +import org.junit.Test; +import org.junit.runner.RunWith; +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; + +@RunWith(SpringRunner.class) +@SpringBootTest +@ContextConfiguration +public class GroupServiceTest { + + @Autowired + private GroupService groupService; + + @Test + public void createAndDeleteGroup() { + Groups group; + int startAmmount = this.groupService.getGroupsAmmount(); + + //Create group + group = new Groups(); + group.setRoom("A1"); + groupService.save(group); + assertTrue(this.groupService.getGroupsAmmount() > startAmmount); + + // Delete course + groupService.delete(group); + assertTrue(this.groupService.getGroupsAmmount() == startAmmount); + } +} From 1cff3ceb74ba2a81aa874a1347823942937ad002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Wed, 16 Sep 2020 17:35:39 +0200 Subject: [PATCH 6/7] Added delete method into LecturerService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../main/java/com/plannaplan/services/LecturerService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java b/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java index 650fd42..d02548a 100644 --- a/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java @@ -19,6 +19,10 @@ public class LecturerService { repo.save(lecturer); } + public void delete(Lecturer lecturer) { + repo.delete(lecturer); + } + public int getLecturersAmmount(){ return (int)this.repo.count(); } From 6be6bd0184ff0e7c409457ad566e8d44d1875753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Wed, 16 Sep 2020 17:41:36 +0200 Subject: [PATCH 7/7] Added LecturerServiceTest with createAndDeleteLecturer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../services/LecturerServiceTest.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 buisnesslogic/src/test/java/com/plannaplan/services/LecturerServiceTest.java diff --git a/buisnesslogic/src/test/java/com/plannaplan/services/LecturerServiceTest.java b/buisnesslogic/src/test/java/com/plannaplan/services/LecturerServiceTest.java new file mode 100644 index 0000000..203f03f --- /dev/null +++ b/buisnesslogic/src/test/java/com/plannaplan/services/LecturerServiceTest.java @@ -0,0 +1,38 @@ +package com.plannaplan.services; + +import static org.junit.Assert.assertTrue; + +import com.plannaplan.entities.Lecturer; + +import org.junit.Test; +import org.junit.runner.RunWith; +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; + +@RunWith(SpringRunner.class) +@SpringBootTest +@ContextConfiguration +public class LecturerServiceTest { + @Autowired + private LecturerService lecturerService; + + @Test + public void createAndDeleteLecturer(){ + Lecturer lecturer; + int startAmmount = this.lecturerService.getLecturersAmmount(); + + // Create lecturer + lecturer = new Lecturer(); + lecturer.setName("Tomasz"); + lecturer.setSurname("Kowalski"); + lecturer.setTitle("prof."); + lecturerService.save(lecturer); + assertTrue(this.lecturerService.getLecturersAmmount() > startAmmount); + + // Delete lecturer + lecturerService.delete(lecturer); + assertTrue(this.lecturerService.getLecturersAmmount() == startAmmount); + } +}