Merge remote-tracking branch 'origin/dev' into 93-activites-analytics
commit
d1182ea7c3
@ -0,0 +1,43 @@
|
|||||||
|
package ru.ulstu.paper.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AutoCompleteData {
|
||||||
|
private List<String> authors = new ArrayList<>();
|
||||||
|
private List<String> publicationTitles = new ArrayList<>();
|
||||||
|
private List<String> publishers = new ArrayList<>();
|
||||||
|
private List<String> journalOrCollectionTitles = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<String> getAuthors() {
|
||||||
|
return authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthors(List<String> authors) {
|
||||||
|
this.authors = authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getPublicationTitles() {
|
||||||
|
return publicationTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicationTitles(List<String> publicationTitles) {
|
||||||
|
this.publicationTitles = publicationTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getPublishers() {
|
||||||
|
return publishers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublishers(List<String> publishers) {
|
||||||
|
this.publishers = publishers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getJournalOrCollectionTitles() {
|
||||||
|
return journalOrCollectionTitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJournalOrCollectionTitles(List<String> journalOrCollectionTitles) {
|
||||||
|
this.journalOrCollectionTitles = journalOrCollectionTitles;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
package ru.ulstu.paper.model;
|
||||||
|
|
||||||
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Reference extends BaseEntity {
|
||||||
|
|
||||||
|
private String authors;
|
||||||
|
|
||||||
|
@Column(name = "publication_title")
|
||||||
|
private String publicationTitle;
|
||||||
|
|
||||||
|
@Column(name = "publication_year")
|
||||||
|
private Integer publicationYear;
|
||||||
|
|
||||||
|
private String publisher;
|
||||||
|
|
||||||
|
private String pages;
|
||||||
|
|
||||||
|
@Column(name = "journal_or_collection_title")
|
||||||
|
private String journalOrCollectionTitle;
|
||||||
|
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
@Column(name = "reference_type")
|
||||||
|
private ReferenceDto.ReferenceType referenceType = ReferenceDto.ReferenceType.ARTICLE;
|
||||||
|
|
||||||
|
public String getAuthors() {
|
||||||
|
return authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthors(String authors) {
|
||||||
|
this.authors = authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublicationTitle() {
|
||||||
|
return publicationTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicationTitle(String publicationTitle) {
|
||||||
|
this.publicationTitle = publicationTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPublicationYear() {
|
||||||
|
return publicationYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicationYear(Integer publicationYear) {
|
||||||
|
this.publicationYear = publicationYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublisher() {
|
||||||
|
return publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublisher(String publisher) {
|
||||||
|
this.publisher = publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPages() {
|
||||||
|
return pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPages(String pages) {
|
||||||
|
this.pages = pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJournalOrCollectionTitle() {
|
||||||
|
return journalOrCollectionTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJournalOrCollectionTitle(String journalOrCollectionTitle) {
|
||||||
|
this.journalOrCollectionTitle = journalOrCollectionTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceDto.ReferenceType getReferenceType() {
|
||||||
|
return referenceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferenceType(ReferenceDto.ReferenceType referenceType) {
|
||||||
|
this.referenceType = referenceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package ru.ulstu.paper.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import ru.ulstu.paper.model.Reference;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ReferenceRepository extends JpaRepository<Reference, Integer> {
|
||||||
|
void deleteById(Integer id);
|
||||||
|
|
||||||
|
@Query("SELECT DISTINCT r.authors FROM Reference r")
|
||||||
|
List<String> findDistinctAuthors();
|
||||||
|
|
||||||
|
@Query("SELECT DISTINCT r.publicationTitle FROM Reference r")
|
||||||
|
List<String> findDistinctPublicationTitles();
|
||||||
|
|
||||||
|
@Query("SELECT DISTINCT r.publisher FROM Reference r")
|
||||||
|
List<String> findDistinctPublishers();
|
||||||
|
|
||||||
|
@Query("SELECT DISTINCT r.journalOrCollectionTitle FROM Reference r where r.journalOrCollectionTitle <> ''")
|
||||||
|
List<String> findDistinctJournalOrCollectionTitles();
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
<changeSet author="masha" id="20190523_000000-1">
|
||||||
|
<createTable tableName="reference">
|
||||||
|
<column name="id" type="integer">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="authors" type="varchar(255)"/>
|
||||||
|
<column name="publication_title" type="varchar(255)"/>
|
||||||
|
<column name="publication_year" type="integer"/>
|
||||||
|
<column name="paper_id" type="integer"/>
|
||||||
|
<column name="publisher" type="varchar(255)"/>
|
||||||
|
<column name="pages" type="varchar(255)"/>
|
||||||
|
<column name="journal_or_collection_title" type="varchar(255)"/>
|
||||||
|
<column name="reference_type" type="varchar(255)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="version" type="integer"/>
|
||||||
|
</createTable>
|
||||||
|
<addPrimaryKey columnNames="id" constraintName="pk_reference" tableName="reference"/>
|
||||||
|
<addForeignKeyConstraint baseTableName="reference" baseColumnNames="paper_id"
|
||||||
|
constraintName="fk_reference_paper_id" referencedTableName="paper"
|
||||||
|
referencedColumnNames="id"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,3 @@
|
|||||||
|
.loader {
|
||||||
|
padding-left:50%
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 673 B |
@ -1,57 +1,59 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en"
|
<html lang="en"
|
||||||
xmlns:th="http://www.thymeleaf.org"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
layout:decorator="default">
|
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
|
<script src="/js/users.js"></script>
|
||||||
|
<link rel="stylesheet" href="../css/base.css"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav layout:fragment="navbar">
|
<nav layout:fragment="navbar">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<a class="navbar-brand" href="/"><span class="ui-menuitem-text"><i
|
<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>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="container" layout:fragment="content">
|
<div layout:fragment="content">
|
||||||
<form id="reset-form" method="post" class="margined-top-10">
|
<section class="bg-light" id="portfolio">
|
||||||
<fieldset>
|
|
||||||
|
<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">
|
<div class="form-group">
|
||||||
<input type="email" name="email" id="email" class="form-control"
|
<input type="password" name="email" id="passwordNew" class="form-control"
|
||||||
placeholder="E-Mail" required="true" autofocus="autofocus"/>
|
placeholder="Новый пароль" style="display:none"/>
|
||||||
</div>
|
</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">
|
<div class="form-group">
|
||||||
<small class="form-text text-muted">
|
<small class="form-text text-muted">
|
||||||
<a href="/login">Вернуться к странице входа</a>
|
<a href="/login">Вернуться к странице входа</a>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</div>
|
||||||
</form>
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</div>
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
@ -0,0 +1,214 @@
|
|||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import core.PageObject;
|
||||||
|
import core.TestTemplate;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.FixMethodOrder;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.MethodSorters;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import ru.ulstu.NgTrackerApplication;
|
||||||
|
import ru.ulstu.configuration.ApplicationProperties;
|
||||||
|
import students.TaskPage;
|
||||||
|
import students.TasksDashboardPage;
|
||||||
|
import students.TasksPage;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
|
@SpringBootTest(classes = NgTrackerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||||
|
public class IndexTaskTest extends TestTemplate {
|
||||||
|
private final Map<PageObject, List<String>> navigationHolder = ImmutableMap.of(
|
||||||
|
new TasksPage(), Arrays.asList("Список задач", "/students/tasks"),
|
||||||
|
new TasksDashboardPage(), Arrays.asList("Панель управления", "/students/dashboard"),
|
||||||
|
new TaskPage(), Arrays.asList("Создать задачу", "/students/task?id=0")
|
||||||
|
);
|
||||||
|
|
||||||
|
private final String TAG = "ATag";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationProperties applicationProperties;
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testACreateTask() {
|
||||||
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 2);
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||||
|
|
||||||
|
TaskPage taskPage = (TaskPage) getContext().initPage(page.getKey());
|
||||||
|
TasksPage tasksPage = (TasksPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 0).getKey());
|
||||||
|
String taskName = "Task " + (new Date()).getTime();
|
||||||
|
|
||||||
|
taskPage.setName(taskName);
|
||||||
|
taskPage.addDeadlineDate("01.01.2020", 0);
|
||||||
|
taskPage.addDeadlineDescription("Description", 0);
|
||||||
|
taskPage.save();
|
||||||
|
|
||||||
|
Assert.assertTrue(tasksPage.findTask(taskName));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBEditTaskName() {
|
||||||
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||||
|
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||||
|
TasksPage tasksPage = (TasksPage) getContext().initPage(page.getKey());
|
||||||
|
TaskPage taskPage = (TaskPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 2).getKey());
|
||||||
|
String taskNewName = "Task " + (new Date()).getTime();
|
||||||
|
|
||||||
|
tasksPage.goToFirstTask();
|
||||||
|
taskPage.removeName();
|
||||||
|
taskPage.setName(taskNewName);
|
||||||
|
taskPage.save();
|
||||||
|
|
||||||
|
Assert.assertTrue(tasksPage.findTask(taskNewName));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCDeleteTask() throws InterruptedException {
|
||||||
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||||
|
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||||
|
TasksPage tasksPage = (TasksPage) getContext().initPage(page.getKey());
|
||||||
|
|
||||||
|
Integer size = tasksPage.getTasks().size();
|
||||||
|
tasksPage.deleteFirstTask();
|
||||||
|
Thread.sleep(3000);
|
||||||
|
tasksPage.submit();
|
||||||
|
|
||||||
|
Assert.assertEquals(size - 1, tasksPage.getTasks().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDAddDeadline() {
|
||||||
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||||
|
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||||
|
TasksPage tasksPage = (TasksPage) getContext().initPage(page.getKey());
|
||||||
|
TaskPage taskPage = (TaskPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 2).getKey());
|
||||||
|
|
||||||
|
tasksPage.goToFirstTask();
|
||||||
|
String taskId = taskPage.getId();
|
||||||
|
Integer deadnum = taskPage.getDeadNum();
|
||||||
|
|
||||||
|
String descr = "Description";
|
||||||
|
String date = "06.06.2019";
|
||||||
|
String dateValue = "2019-06-06";
|
||||||
|
|
||||||
|
taskPage.clickAddDeadline();
|
||||||
|
taskPage.addDeadlineDescription(descr, deadnum);
|
||||||
|
taskPage.addDeadlineDate(date, deadnum);
|
||||||
|
taskPage.save();
|
||||||
|
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/students/task?id=%s", taskId));
|
||||||
|
|
||||||
|
Assert.assertTrue(taskPage.hasDeadline(descr, dateValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEEditDeadline() {
|
||||||
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||||
|
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||||
|
TasksPage tasksPage = (TasksPage) getContext().initPage(page.getKey());
|
||||||
|
TaskPage taskPage = (TaskPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 2).getKey());
|
||||||
|
|
||||||
|
tasksPage.goToFirstTask();
|
||||||
|
String taskId = taskPage.getId();
|
||||||
|
|
||||||
|
String descr = "DescriptionTwo";
|
||||||
|
String date = "12.12.2019";
|
||||||
|
String dateValue = "2019-12-12";
|
||||||
|
|
||||||
|
taskPage.clearDeadlineDate(0);
|
||||||
|
taskPage.clearDeadlineDescription(0);
|
||||||
|
taskPage.addDeadlineDescription(descr, 0);
|
||||||
|
taskPage.addDeadlineDate(date, 0);
|
||||||
|
taskPage.save();
|
||||||
|
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/students/task?id=%s", taskId));
|
||||||
|
|
||||||
|
Assert.assertTrue(taskPage.hasDeadline(descr, dateValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFDeleteDeadline() {
|
||||||
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||||
|
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||||
|
TasksPage tasksPage = (TasksPage) getContext().initPage(page.getKey());
|
||||||
|
TaskPage taskPage = (TaskPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 2).getKey());
|
||||||
|
|
||||||
|
tasksPage.goToFirstTask();
|
||||||
|
String taskId = taskPage.getId();
|
||||||
|
Integer deadNum = taskPage.getDeadNum();
|
||||||
|
|
||||||
|
taskPage.deleteDeadline();
|
||||||
|
taskPage.save();
|
||||||
|
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/students/task?id=%s", taskId));
|
||||||
|
|
||||||
|
Assert.assertEquals(deadNum - 1, (int) taskPage.getDeadNum());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGCreateTaskWithTag() throws InterruptedException {
|
||||||
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 2);
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||||
|
|
||||||
|
TaskPage taskPage = (TaskPage) getContext().initPage(page.getKey());
|
||||||
|
TasksPage tasksPage = (TasksPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 0).getKey());
|
||||||
|
String taskName = "Task " + (new Date()).getTime();
|
||||||
|
|
||||||
|
taskPage.setName(taskName);
|
||||||
|
taskPage.setTag(TAG);
|
||||||
|
Thread.sleep(1000);
|
||||||
|
taskPage.addDeadlineDate("01.01.2020", 0);
|
||||||
|
taskPage.addDeadlineDescription("Description", 0);
|
||||||
|
taskPage.save();
|
||||||
|
|
||||||
|
Assert.assertTrue(tasksPage.findTaskByTag(taskName, TAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHFindTagInFilter() {
|
||||||
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||||
|
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||||
|
TasksPage tasksPage = (TasksPage) getContext().initPage(page.getKey());
|
||||||
|
|
||||||
|
|
||||||
|
Assert.assertTrue(tasksPage.findTag(TAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIFilterByTag() {
|
||||||
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||||
|
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||||
|
TasksPage tasksPage = (TasksPage) getContext().initPage(page.getKey());
|
||||||
|
tasksPage.selectTag(TAG);
|
||||||
|
|
||||||
|
Assert.assertTrue(tasksPage.findTasksByTag(TAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testJFilterByStatus() {
|
||||||
|
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||||
|
|
||||||
|
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||||
|
TasksPage tasksPage = (TasksPage) getContext().initPage(page.getKey());
|
||||||
|
|
||||||
|
tasksPage.selectStatus();
|
||||||
|
Assert.assertTrue(tasksPage.findAllStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package students;
|
||||||
|
|
||||||
|
import core.PageObject;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.Keys;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TaskPage extends PageObject {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSubTitle() {
|
||||||
|
return driver.findElement(By.tagName("h3")).getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
driver.findElement(By.id("title")).sendKeys(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
driver.findElement(By.id("sendMessageButton")).click();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDeadlineDate(String deadDate, Integer deadNum) {
|
||||||
|
driver.findElement(By.id(String.format("deadlines%d.date", deadNum))).sendKeys(deadDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDeadlineDescription(String deadDescr, Integer deadNum) {
|
||||||
|
driver.findElement(By.id(String.format("deadlines%d.description", deadNum))).sendKeys(deadDescr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeName() {
|
||||||
|
driver.findElement(By.id("title")).clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return driver.findElement(By.id("id")).getAttribute("value");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDeadNum() {
|
||||||
|
return driver.findElements(By.cssSelector("#task-form .form-group:nth-of-type(5) .row")).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clickAddDeadline() {
|
||||||
|
driver.findElement(By.cssSelector("#addDeadline")).click();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WebElement> getDeadlines() {
|
||||||
|
return driver.findElements(By.cssSelector(".form-group:nth-of-type(5) .row"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteDeadline() {
|
||||||
|
driver.findElement(By.xpath("//*[@id=\"task-form\"]/div/div[1]/div[5]/div[1]/div[3]/a")).click();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearDeadlineDate(Integer deadNum) {
|
||||||
|
driver.findElement(By.id(String.format("deadlines%d.date", deadNum))).sendKeys(Keys.DELETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearDeadlineDescription(Integer deadNum) {
|
||||||
|
driver.findElement(By.id(String.format("deadlines%d.description", deadNum))).clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasDeadline(String deadDescr, String deadValue) {
|
||||||
|
return getDeadlines()
|
||||||
|
.stream()
|
||||||
|
.anyMatch(webElement -> {
|
||||||
|
return webElement.findElement(By.cssSelector("input[type=\"text\"]")).getAttribute("value").equals(deadDescr)
|
||||||
|
&& webElement.findElement(By.cssSelector("input[type=\"date\"]")).getAttribute("value").equals(deadValue);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTag(String tag) {
|
||||||
|
driver.findElement(By.className("input-tag-name")).sendKeys(tag);
|
||||||
|
driver.findElement(By.className("input-tag-name")).sendKeys(Keys.ENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package students;
|
||||||
|
|
||||||
|
import core.PageObject;
|
||||||
|
|
||||||
|
public class TasksDashboardPage extends PageObject {
|
||||||
|
@Override
|
||||||
|
public String getSubTitle() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
package students;
|
||||||
|
|
||||||
|
import core.PageObject;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TasksPage extends PageObject {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSubTitle() {
|
||||||
|
return driver.findElement(By.tagName("h3")).getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WebElement> getTasks() {
|
||||||
|
return driver.findElements(By.cssSelector("span.h6"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WebElement> getTaskRows() {
|
||||||
|
return driver.findElements(By.className("task-row"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void goToFirstTask() {
|
||||||
|
driver.findElement(By.xpath("//*[@id=\"tasks\"]/div/div[2]/div[1]/div/div/a[1]")).click();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean findTask(String taskName) {
|
||||||
|
return getTasks().stream()
|
||||||
|
.anyMatch(webElement -> webElement.getText().equals(taskName));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteFirstTask() {
|
||||||
|
js.executeScript("$('a[data-confirm]').click();");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submit() {
|
||||||
|
driver.findElement(By.xpath("//*[@id=\"dataConfirmOK\"]")).click();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean findTag(String tag) {
|
||||||
|
driver.findElements(By.className("bootstrap-select")).get(2).findElement(By.className("btn")).click();
|
||||||
|
driver.findElement(By.cssSelector(".bs-searchbox input")).sendKeys(tag);
|
||||||
|
return driver.findElement(By.xpath("//*[@id=\"tasks\"]/div/div[2]/div[2]/div[2]/div[2]/div/div[2]/ul")).findElement(By.className("text")).getText().equals(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean findTaskByTag(String name, String tag) {
|
||||||
|
return getTasks().stream()
|
||||||
|
.anyMatch(webElement -> webElement.getText().equals(name)
|
||||||
|
&& webElement.findElement(By.xpath("//*[@id=\"tasks\"]/div/div[2]/div[1]/div/div/a[1]/span[3]")).getText().equals(tag));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean findTasksByTag(String tag) {
|
||||||
|
return getTaskRows().stream()
|
||||||
|
.allMatch(webElement -> webElement.findElement(By.cssSelector("span.text-muted")).getText().equals(tag));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectTag(String tag) {
|
||||||
|
driver.findElements(By.className("bootstrap-select")).get(2).findElement(By.className("btn")).click();
|
||||||
|
driver.findElement(By.cssSelector(".bs-searchbox input")).sendKeys(tag);
|
||||||
|
driver.findElement(By.xpath("//*[@id=\"tasks\"]/div/div[2]/div[2]/div[2]/div[2]/div/div[2]/ul/li/a")).click();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void selectStatus() {
|
||||||
|
driver.findElements(By.className("bootstrap-select")).get(1).findElement(By.className("btn")).click();
|
||||||
|
driver.findElement(By.xpath("//*[@id=\"tasks\"]/div/div[2]/div[2]/div[2]/div[1]/div/div/ul/li[2]/a")).click();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean findAllStatus() {
|
||||||
|
return getTaskRows().stream()
|
||||||
|
.allMatch(webElement -> webElement.findElement(By.cssSelector("div i.text-primary")).isDisplayed());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue