33 lines
1023 B
Java
Executable File
33 lines
1023 B
Java
Executable File
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 = new Course("Testowy kurs", "TK");
|
|
int startAmmount = this.courseService.getCoursesAmmount();
|
|
|
|
courseService.save(course);
|
|
assertTrue(this.courseService.getCoursesAmmount() > startAmmount);
|
|
|
|
courseService.delete(course);
|
|
assertTrue(this.courseService.getCoursesAmmount() == startAmmount);
|
|
}
|
|
}
|