Added config test
This commit is contained in:
parent
16b9cb3cf2
commit
7a7c882163
@ -24,4 +24,8 @@ public class CourseService {
|
|||||||
public void save(Course course) {
|
public void save(Course course) {
|
||||||
this.repo.save(course);
|
this.repo.save(course);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCoursesAmmount(){
|
||||||
|
return (int)this.repo.count();
|
||||||
|
}
|
||||||
}
|
}
|
@ -27,4 +27,8 @@ public class GroupService {
|
|||||||
public void save(Groups group) {
|
public void save(Groups group) {
|
||||||
this.repo.save(group);
|
this.repo.save(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getGroupsAmmount(){
|
||||||
|
return (int)this.repo.count();
|
||||||
|
}
|
||||||
}
|
}
|
@ -18,4 +18,8 @@ public class LecturerService {
|
|||||||
public void save(Lecturer lecturer) {
|
public void save(Lecturer lecturer) {
|
||||||
repo.save(lecturer);
|
repo.save(lecturer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLecturersAmmount(){
|
||||||
|
return (int)this.repo.count();
|
||||||
|
}
|
||||||
}
|
}
|
@ -5,14 +5,14 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import com.plannaplan.App;
|
|
||||||
import com.plannaplan.Configurator;
|
|
||||||
import com.plannaplan.models.ConfigData;
|
import com.plannaplan.models.ConfigData;
|
||||||
|
import com.plannaplan.services.CourseService;
|
||||||
|
import com.plannaplan.services.GroupService;
|
||||||
|
import com.plannaplan.services.LecturerService;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -22,15 +22,29 @@ import org.junit.runner.RunWith;
|
|||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class ConfiguratorTest {
|
public class ConfiguratorTest {
|
||||||
|
|
||||||
|
private static String FILE_NAME = "Zajecia.xlsx";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Configurator restTemplate;
|
private Configurator restTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CourseService courseService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GroupService groupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LecturerService lecturerService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void greetingShouldReturnDefaultMessage() throws Exception {
|
public void shouldImportDataFromFileToDatabase() throws Exception {
|
||||||
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx");
|
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
|
||||||
final ConfigData data = new ConfigData(null, null, inputStream);
|
final ConfigData data = new ConfigData(null, null, inputStream);
|
||||||
this.restTemplate.config(data);
|
this.restTemplate.config(data);
|
||||||
assertTrue(true);
|
int courses_ammount = this.courseService.getCoursesAmmount();
|
||||||
|
int groups_ammount = this.groupService.getGroupsAmmount();
|
||||||
|
int lecturers_ammount = this.lecturerService.getLecturersAmmount();
|
||||||
|
|
||||||
|
assertTrue(courses_ammount > 0 && groups_ammount > 0 && lecturers_ammount > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user