#104 mod tests period task
This commit is contained in:
parent
82e454a50b
commit
ab17b9f152
@ -249,8 +249,9 @@ public class TaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void createPeriodTask(Scheduler scheduler) {
|
public Task createPeriodTask(Scheduler scheduler) {
|
||||||
Task newTask = copyTaskWithNewDates(scheduler.getTask());
|
Task newTask = copyTaskWithNewDates(scheduler.getTask());
|
||||||
taskRepository.save(newTask);
|
taskRepository.save(newTask);
|
||||||
|
return newTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import org.springframework.data.domain.Sort;
|
|||||||
import ru.ulstu.core.util.DateUtils;
|
import ru.ulstu.core.util.DateUtils;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.deadline.service.DeadlineService;
|
import ru.ulstu.deadline.service.DeadlineService;
|
||||||
|
import ru.ulstu.students.model.Scheduler;
|
||||||
import ru.ulstu.students.model.Task;
|
import ru.ulstu.students.model.Task;
|
||||||
import ru.ulstu.students.model.TaskDto;
|
import ru.ulstu.students.model.TaskDto;
|
||||||
import ru.ulstu.students.model.TaskFilterDto;
|
import ru.ulstu.students.model.TaskFilterDto;
|
||||||
@ -26,7 +27,6 @@ import java.util.Collections;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@ -64,14 +64,12 @@ public class TaskServiceTest {
|
|||||||
private List<Task> tasks;
|
private List<Task> tasks;
|
||||||
private List<Tag> tags;
|
private List<Tag> tags;
|
||||||
private Task task;
|
private Task task;
|
||||||
private TaskFilterDto filterDto;
|
private Task taskForSchedule;
|
||||||
private TaskDto taskDto;
|
private TaskDto taskDto;
|
||||||
private List<TaskDto> tasksDto;
|
|
||||||
private Tag tag;
|
private Tag tag;
|
||||||
private Tag tagNull;
|
|
||||||
private Deadline deadline;
|
private Deadline deadline;
|
||||||
private List<Deadline> deadlines;
|
private List<Deadline> deadlines;
|
||||||
private Set<Tag> repeatingTags;
|
private Scheduler scheduler;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -102,8 +100,14 @@ public class TaskServiceTest {
|
|||||||
tasks.add(task);
|
tasks.add(task);
|
||||||
taskDto = new TaskDto(task);
|
taskDto = new TaskDto(task);
|
||||||
|
|
||||||
repeatingTags = new HashSet<>();
|
taskForSchedule = new Task();
|
||||||
repeatingTags.add(tag);
|
taskForSchedule.setTitle(TITLE);
|
||||||
|
taskForSchedule.setDescription(DESCR);
|
||||||
|
|
||||||
|
scheduler = new Scheduler();
|
||||||
|
scheduler.setDate(new Date());
|
||||||
|
scheduler.setTask(taskForSchedule);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,8 +175,10 @@ public class TaskServiceTest {
|
|||||||
newTask.setStatus(Task.TaskStatus.LOADED_FROM_KIAS);
|
newTask.setStatus(Task.TaskStatus.LOADED_FROM_KIAS);
|
||||||
|
|
||||||
Deadline newDeadline = new Deadline();
|
Deadline newDeadline = new Deadline();
|
||||||
|
newDeadline.setId(ID);
|
||||||
newDeadline.setDescription(deadline.getDescription());
|
newDeadline.setDescription(deadline.getDescription());
|
||||||
newDeadline.setDate(DateUtils.addYears(deadline.getDate(), 1));
|
newDeadline.setDate(DateUtils.addYears(deadline.getDate(), 1));
|
||||||
|
when(deadlineService.create(newDeadline)).thenReturn(newDeadline);
|
||||||
newTask.setDeadlines(Arrays.asList(newDeadline));
|
newTask.setDeadlines(Arrays.asList(newDeadline));
|
||||||
|
|
||||||
when(taskRepository.save(newTask)).thenReturn(task);
|
when(taskRepository.save(newTask)).thenReturn(task);
|
||||||
@ -189,19 +195,22 @@ public class TaskServiceTest {
|
|||||||
assertEquals(new HashSet<Tag>(Arrays.asList(tag)), taskService.checkRepeatingTags(false));
|
assertEquals(new HashSet<Tag>(Arrays.asList(tag)), taskService.checkRepeatingTags(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getTaskStatuses() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getTags() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void findTasksByTag() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createPeriodTask() {
|
public void createPeriodTask() {
|
||||||
|
Task newTask = new Task();
|
||||||
|
newTask.setTitle(scheduler.getTask().getTitle());
|
||||||
|
newTask.setTags(scheduler.getTask().getTags());
|
||||||
|
newTask.setCreateDate(new Date());
|
||||||
|
|
||||||
|
Deadline newDeadline = new Deadline();
|
||||||
|
newDeadline.setId(ID);
|
||||||
|
newDeadline.setDescription(deadline.getDescription());
|
||||||
|
newDeadline.setDate(DateUtils.addYears(deadline.getDate(), 1));
|
||||||
|
when(deadlineService.create(newDeadline)).thenReturn(newDeadline);
|
||||||
|
newTask.setDeadlines(Arrays.asList(newDeadline));
|
||||||
|
|
||||||
|
when(taskRepository.save(newTask)).thenReturn(taskForSchedule);
|
||||||
|
|
||||||
|
assertEquals(taskForSchedule, taskService.createPeriodTask(scheduler));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user