Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
100 lines (85 sloc) 3.61 KB
package de.fh_zwickau.pti.geobe.domain
import de.fh_zwickau.pti.geobe.GroovaaApplication
import de.fh_zwickau.pti.geobe.dto.ProjectDto
import de.fh_zwickau.pti.geobe.repository.ProjectRepository
import de.fh_zwickau.pti.geobe.repository.SprintRepository
import de.fh_zwickau.pti.geobe.repository.TaskRepository
import de.fh_zwickau.pti.geobe.service.ProjectService
import de.fh_zwickau.pti.geobe.service.StartupService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.SpringApplicationConfiguration
import spock.lang.Specification
import javax.transaction.Transactional
* @author georg beier
@SpringApplicationConfiguration(classes = GroovaaApplication)
class ProjectServiceSpecification extends Specification {
private ProjectRepository projectRepository
private TaskRepository taskRepository
private SprintRepository sprintRepository
private ProjectService projectService
Project project
CompoundTask task
Subtask stask
public setup() {
project = new Project() = "ein Projekt"
task = new CompoundTask([description: "eine neue Aufgabe", tag: 'Guten Tag'])
stask = new Subtask([description: 'ohne Worte', tag: 'blah'])
private StartupService startupService
public cleanup() {
def "get a dto from a project"() {
when: 'a project with a task is in the database'
and: 'we ask for query dtos'
ProjectDto.QList qList = projectService.projects
ProjectDto.QFull qFull = projectService.getProjectDetails(
assert qList.all.size() == 1
assert qList.all.keySet().contains(
assert qList.all.values().name.any {it == }
assert ==
assert ==
assert qFull.budget == project.budget
assert qFull.backlog.all.size() == 2
assert qFull.sprints.all.size() == 0
assert qFull.backlog.all[] == task.tag
assert qFull.backlog.all[] == stask.tag
def "create a new project from a dto should throw exception"() {
given: 'a new CSet command object'
ProjectDto.CSet cSet = new ProjectDto.CSet([name: 'a new project', budget: 5000])
and: 'two tasks in the repository'
def tasks = [task] << new Subtask([tag: 'subtask1', estimate: 300, spent: 123, completed: false])
when: 'we call the project service with that command'
tasks.forEach {cSet.taskIds <<}
ProjectDto.QFull qFull = projectService.createOrUpdateProject(cSet)
then: 'an exception is thrown due to missing authorization'
// did not yet manage to authenticate with vaadin in a test case
// then: 'Project should be saved and QFull populated'
// assert projectRepository.findAll().size() == 1
// assert
// assert qFull.backlog.all.size() == 2
// assert projectRepository.findOne( ==
// assert projectRepository.findOne( == qFull.budget
// assert projectRepository.findOne( == 2