Merge branch 'dev' into 127-paper-references
commit
43e7b9fe1f
@ -0,0 +1,3 @@
|
||||
.loader {
|
||||
padding-left:50%
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 673 B |
@ -1,57 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorator="default">
|
||||
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script src="/js/users.js"></script>
|
||||
<link rel="stylesheet" href="../css/base.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<nav layout:fragment="navbar">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="/"><span class="ui-menuitem-text"><i
|
||||
class="fa fa-plane fa-4" aria-hidden="true"></i> Balance</span></a>
|
||||
class="fa fa-plane fa-4" aria-style="display:none"></i> Balance</span></a>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container" layout:fragment="content">
|
||||
<form id="reset-form" method="post" class="margined-top-10">
|
||||
<fieldset>
|
||||
<div layout:fragment="content">
|
||||
<section class="bg-light" id="portfolio">
|
||||
|
||||
<div class="container">
|
||||
<div class="row justify-content-md-center">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<input type="text" name="email" id="emailReset" class="form-control"
|
||||
placeholder="E-Mail"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="email" name="email" id="email" class="form-control"
|
||||
placeholder="E-Mail" required="true" autofocus="autofocus"/>
|
||||
<input type="password" name="email" id="passwordNew" class="form-control"
|
||||
placeholder="Новый пароль" style="display:none"/>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success btn-block">Сбросить пароль</button>
|
||||
<div class="form-group">
|
||||
<input type="password" name="email" id="passwordConfirm" class="form-control"
|
||||
placeholder="Подтвердите пароль" style="display:none"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" name="email" id="resetKey" class="form-control"
|
||||
placeholder="Код подтверждения" style="display:none"/>
|
||||
</div>
|
||||
<div id="dvloader" class="loader" style="display:none"><img src="../img/main/ajax-loader.gif" /></div>
|
||||
<button id="btnSend" type="button" onclick="requestResetPassword()"
|
||||
class="btn btn-success btn-block">
|
||||
Отправить код подтверждения
|
||||
</button>
|
||||
<button id="btnReset" style="display:none" type="button" onclick="resetPassword()"
|
||||
class="btn btn-success btn-block">
|
||||
Сбросить
|
||||
пароль
|
||||
</button>
|
||||
<div class="form-group">
|
||||
<small class="form-text text-muted">
|
||||
<a href="/login">Вернуться к странице входа</a>
|
||||
</small>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<th:block layout:fragment="data-scripts">
|
||||
<script type="text/javascript">
|
||||
/*<![CDATA[*/
|
||||
$(document).ready(function () {
|
||||
$("#reset-form").submit(function () {
|
||||
var email = $("#email").val();
|
||||
if (isEmpty(email)) {
|
||||
showFeedbackMessage("Адрес электронной почты не задан", MessageTypesEnum.DANGER);
|
||||
return false;
|
||||
}
|
||||
postToRest(urlUsersPasswordResetRequest + "?email=" + email, null,
|
||||
function () {
|
||||
showFeedbackMessage("Запрос на смену пароля отправлен");
|
||||
},
|
||||
function () {
|
||||
$("#email").val("");
|
||||
}
|
||||
);
|
||||
return false;
|
||||
});
|
||||
});
|
||||
/*]]>*/
|
||||
|
||||
</script>
|
||||
</th:block>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,216 @@
|
||||
package ru.ulstu.students.service;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import ru.ulstu.core.util.DateUtils;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.deadline.service.DeadlineService;
|
||||
import ru.ulstu.students.model.Scheduler;
|
||||
import ru.ulstu.students.model.Task;
|
||||
import ru.ulstu.students.model.TaskDto;
|
||||
import ru.ulstu.students.model.TaskFilterDto;
|
||||
import ru.ulstu.students.repository.SchedulerRepository;
|
||||
import ru.ulstu.students.repository.TaskRepository;
|
||||
import ru.ulstu.tags.model.Tag;
|
||||
import ru.ulstu.tags.service.TagService;
|
||||
import ru.ulstu.timeline.service.EventService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TaskServiceTest {
|
||||
|
||||
@Mock
|
||||
TaskRepository taskRepository;
|
||||
|
||||
@Mock
|
||||
SchedulerRepository schedulerRepository;
|
||||
|
||||
@Mock
|
||||
private TagService tagService;
|
||||
|
||||
@Mock
|
||||
DeadlineService deadlineService;
|
||||
|
||||
@Mock
|
||||
EventService eventService;
|
||||
|
||||
@InjectMocks
|
||||
TaskService taskService;
|
||||
|
||||
private final static Sort SORT = new Sort(Sort.Direction.DESC, "createDate");
|
||||
private final static Integer ID = 1;
|
||||
private final static Task.TaskStatus STATUS = Task.TaskStatus.IN_WORK;
|
||||
private final static String TITLE = "title";
|
||||
private final static String DESCR = "descr";
|
||||
private final static String TAG = "tag";
|
||||
private final static Date YEAR = DateUtils.clearTime(DateUtils.addYears(new Date(), 0));
|
||||
|
||||
private List<Task> tasks;
|
||||
private List<Tag> tags;
|
||||
private Task task;
|
||||
private Task taskForSchedule;
|
||||
private TaskDto taskDto;
|
||||
private Tag tag;
|
||||
private Deadline deadline;
|
||||
private List<Deadline> deadlines;
|
||||
private Scheduler scheduler;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
task = new Task();
|
||||
|
||||
task.setId(ID);
|
||||
task.setTitle(TITLE);
|
||||
task.setDescription(DESCR);
|
||||
|
||||
|
||||
tag = new Tag();
|
||||
tag.setId(ID);
|
||||
tag.setTagName(TAG);
|
||||
|
||||
deadlines = new ArrayList<>();
|
||||
deadline = new Deadline(new Date(), DESCR);
|
||||
deadline.setId(ID);
|
||||
deadlines.add(deadline);
|
||||
|
||||
task.setDeadlines(deadlines);
|
||||
|
||||
tags = new ArrayList<>();
|
||||
tags.add(tag);
|
||||
|
||||
tasks.add(task);
|
||||
taskDto = new TaskDto(task);
|
||||
|
||||
taskForSchedule = new Task();
|
||||
taskForSchedule.setTitle(TITLE);
|
||||
taskForSchedule.setDescription(DESCR);
|
||||
|
||||
scheduler = new Scheduler();
|
||||
scheduler.setDate(new Date());
|
||||
scheduler.setTask(taskForSchedule);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAll() {
|
||||
|
||||
when(taskRepository.findAll(SORT)).thenReturn(tasks);
|
||||
assertEquals(Collections.singletonList(task), taskService.findAll());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filter() {
|
||||
when(tagService.findById(ID)).thenReturn(tag);
|
||||
when(taskRepository.filterNew(STATUS, tag)).thenReturn(tasks);
|
||||
|
||||
TaskFilterDto taskFilterDto = new TaskFilterDto();
|
||||
taskFilterDto.setTag(ID);
|
||||
taskFilterDto.setOrder("new");
|
||||
taskFilterDto.setStatus(STATUS);
|
||||
|
||||
assertEquals(Collections.singletonList(taskDto), taskService.filter(taskFilterDto));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void create() throws IOException {
|
||||
when(tagService.saveOrCreate(new ArrayList<>())).thenReturn(tags);
|
||||
when(deadlineService.saveOrCreate(new ArrayList<>())).thenReturn(deadlines);
|
||||
when(taskRepository.save(new Task())).thenReturn(task);
|
||||
eventService.createFromTask(new Task());
|
||||
|
||||
taskDto.setTags(tags);
|
||||
taskDto.setDeadlines(deadlines);
|
||||
|
||||
Task newTask = new Task();
|
||||
task.setId(ID);
|
||||
task.setTitle(TITLE);
|
||||
task.setDescription(DESCR);
|
||||
task.setTags(tags);
|
||||
task.setDeadlines(deadlines);
|
||||
|
||||
assertEquals(task.getId(), taskService.create(taskDto));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void delete() throws IOException {
|
||||
when(taskRepository.exists(ID)).thenReturn(true);
|
||||
when(taskRepository.findOne(ID)).thenReturn(task);
|
||||
when(schedulerRepository.findOneByTask(task)).thenReturn(null);
|
||||
|
||||
assertTrue(taskService.delete(ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateYearTasks() {
|
||||
when(tagService.getTags()).thenReturn(tags);
|
||||
tasks.get(0).setTags(tags);
|
||||
when(taskRepository.findAllYear(DateUtils.clearTime(DateUtils.addYears(new Date(), -1)))).thenReturn(tasks);
|
||||
tasks.get(0).setCreateDate(DateUtils.clearTime(DateUtils.addYears(new Date(), -1)));
|
||||
when(taskRepository.findByTag(tag)).thenReturn(tasks);
|
||||
|
||||
Task newTask = new Task();
|
||||
newTask.setTitle(tasks.get(0).getTitle());
|
||||
newTask.setTags(tasks.get(0).getTags());
|
||||
newTask.setCreateDate(new Date());
|
||||
newTask.setStatus(Task.TaskStatus.LOADED_FROM_KIAS);
|
||||
|
||||
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(task);
|
||||
|
||||
assertEquals(Arrays.asList(task), taskService.generateYearTasks());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkRepeatingTags() {
|
||||
when(tagService.getTags()).thenReturn(tags);
|
||||
tasks.get(0).setTags(tags);
|
||||
when(taskRepository.findAllYear(DateUtils.clearTime(DateUtils.addYears(new Date(), -1)))).thenReturn(tasks);
|
||||
|
||||
assertEquals(new HashSet<Tag>(Arrays.asList(tag)), taskService.checkRepeatingTags(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
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