Added test for Supervisor objects in the Spring Data API .
This commit is contained in:
parent
f2b5b05bb0
commit
f0109af9cd
src
main/java/se/su/dsv/scipro/springdata/repos
test/java/se/su/dsv/scipro/springdata
@ -4,7 +4,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.match.dataobject.ProjectIdea;
|
||||
|
||||
/**
|
||||
* @author: fred-fri
|
||||
|
@ -9,7 +9,11 @@ import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UsernameDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.dataobjects.Username;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -25,20 +29,33 @@ public class TestSupervisor {
|
||||
@Autowired
|
||||
private SupervisorService supervisorService;
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
@Before
|
||||
public void startTransaction() throws Exception {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A test for implementing an Employee with Spring Data
|
||||
* Test for implementing a supervisorService with Spring Data
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void findAllSupervisorsWithSpringData() {
|
||||
List<Employee> employeeList = new ArrayList<Employee>();
|
||||
User davidH = new User();
|
||||
davidH.setFirstName("David");
|
||||
davidH.setLastName("Hallberg");
|
||||
davidH.setEmailAddress("dhallb@dsv.su.se");
|
||||
davidH = userDao.save(davidH);
|
||||
|
||||
Employee supervisor = new Employee();
|
||||
supervisor.setUser(davidH);
|
||||
supervisorService.save(supervisor);
|
||||
employeeList.addAll(supervisorService.findAllEmployees());
|
||||
assertTrue(employeeList.size() == 0);
|
||||
assertTrue(employeeList.size() == 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user