diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java b/buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java index 446faea..15ae1aa 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 delete(Course course){ + this.repo.delete(course); + } + public int getCoursesAmmount(){ return (int)this.repo.count(); } 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(); } 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(); } 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..10a609f --- /dev/null +++ b/buisnesslogic/src/test/java/com/plannaplan/services/CourseServiceTest.java @@ -0,0 +1,37 @@ +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 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); + } +} 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); + } +} 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); + } +}