Merge pull request 'testing-web' (#7) from testing-web into master
Testy zakończone sukcesem. Brak błędów pomiędzy discro. Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/7
This commit is contained in:
commit
333ceb9b74
@ -12,8 +12,7 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>buisnesslogic</name>
|
<name>buisnesslogic</name>
|
||||||
<!-- FIXME change it to the project's website -->
|
<url>http://plannaplan.pl</url>
|
||||||
<url>http://www.example.com</url>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
@ -25,11 +24,20 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.11</version>
|
<version>4.12</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.junit.vintage</groupId>
|
||||||
|
<artifactId>junit-vintage-engine</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
<artifactId>jaxb-api</artifactId>
|
<artifactId>jaxb-api</artifactId>
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.plannaplan;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class TestApplication {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user