Removed ConfiguratorTest.java, and rewrite it into configutils/FileToDatabaseMigratorTest.java
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
parent
333ceb9b74
commit
408c8a8242
@ -1,50 +0,0 @@
|
|||||||
package com.plannaplan;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
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.runner.RunWith;
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@ContextConfiguration
|
|
||||||
public class ConfiguratorTest {
|
|
||||||
|
|
||||||
private static String FILE_NAME = "Zajecia.xlsx";
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Configurator restTemplate;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CourseService courseService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GroupService groupService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private LecturerService lecturerService;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void shouldImportDataFromFileToDatabase() throws Exception {
|
|
||||||
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
|
|
||||||
final ConfigData data = new ConfigData(null, null, inputStream);
|
|
||||||
this.restTemplate.config(data);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +1,52 @@
|
|||||||
package com.plannaplan.configutils;
|
package com.plannaplan.configutils;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import com.plannaplan.models.FileData;
|
import com.plannaplan.Configurator;
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
@ContextConfiguration
|
||||||
public class FileToDatabaseMigratorTest {
|
public class FileToDatabaseMigratorTest {
|
||||||
|
|
||||||
|
private static String FILE_NAME = "Zajecia.xlsx";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Configurator restTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CourseService courseService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GroupService groupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LecturerService lecturerService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldInsertToDatabase() {
|
public void shouldImportDataFromFileToDatabase() throws Exception {
|
||||||
// FileToDatabaseMigrator migrator = new FileToDatabaseMigrator();
|
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
|
||||||
// InputStream inputStream =
|
final ConfigData data = new ConfigData(null, null, inputStream);
|
||||||
// getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx");
|
this.restTemplate.config(data);
|
||||||
// FileReader r = new FileReader(inputStream);
|
int courses_ammount = this.courseService.getCoursesAmmount();
|
||||||
// FileData d = r.read();
|
int groups_ammount = this.groupService.getGroupsAmmount();
|
||||||
// migrator.migrate(d);
|
int lecturers_ammount = this.lecturerService.getLecturersAmmount();
|
||||||
|
|
||||||
|
assertTrue(courses_ammount > 0 && groups_ammount > 0 && lecturers_ammount > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user