Added LecturerServiceTest with createAndDeleteLecturer
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
parent
1cff3ceb74
commit
6be6bd0184
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user