2020-09-16 17:21:01 +02:00

38 lines
1.1 KiB
Java

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