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] 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); + } +}