diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java
index 38ce659..4ee4198 100644
--- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java
+++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java
@@ -92,6 +92,7 @@ public class ConferenceService extends BaseService {
conferenceDto.setName(conferenceDto.getTitle());
filterEmptyDeadlines(conferenceDto);
checkEmptyFieldsOfDeadline(conferenceDto, errors);
+ checkEmptyFieldsOfDates(conferenceDto, errors);
checkUniqueName(conferenceDto,
errors,
conferenceDto.getId(),
@@ -301,6 +302,12 @@ public class ConferenceService extends BaseService {
}
}
+ private void checkEmptyFieldsOfDates(ConferenceDto conferenceDto, Errors errors) {
+ if (conferenceDto.getBeginDate() == null || conferenceDto.getEndDate() == null) {
+ errors.rejectValue("beginDate", "errorCode", "Даты должны быть заполнены");
+ }
+ }
+
public void filterEmptyDeadlines(ConferenceDto conferenceDto) {
conferenceDto.setDeadlines(conferenceDto.getDeadlines().stream()
.filter(dto -> dto.getDate() != null || !org.springframework.util.StringUtils.isEmpty(dto.getDescription()))
diff --git a/src/main/resources/drivers/chromedriver b/src/main/resources/drivers/chromedriver
old mode 100644
new mode 100755
diff --git a/src/main/resources/drivers/geckodriver b/src/main/resources/drivers/geckodriver
old mode 100644
new mode 100755
diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html
index d629d4e..201aa01 100644
--- a/src/main/resources/templates/conferences/conference.html
+++ b/src/main/resources/templates/conferences/conference.html
@@ -42,12 +42,20 @@
placeholder="http://"/>
+
Incorrect description
+
+
+ Incorrect description
+
+
+
Incorrect title
@@ -94,6 +103,10 @@
+ Incorrect date
+
@@ -123,7 +136,6 @@
-
diff --git a/src/test/java/IndexTaskTest.java b/src/test/java/IndexTaskTest.java
new file mode 100644
index 0000000..51b5e07
--- /dev/null
+++ b/src/test/java/IndexTaskTest.java
@@ -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
> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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());
+ }
+
+
+}
diff --git a/src/test/java/students/TaskPage.java b/src/test/java/students/TaskPage.java
new file mode 100644
index 0000000..c0105b2
--- /dev/null
+++ b/src/test/java/students/TaskPage.java
@@ -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 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);
+ }
+
+
+}
diff --git a/src/test/java/students/TasksDashboardPage.java b/src/test/java/students/TasksDashboardPage.java
new file mode 100644
index 0000000..8cc6eda
--- /dev/null
+++ b/src/test/java/students/TasksDashboardPage.java
@@ -0,0 +1,10 @@
+package students;
+
+import core.PageObject;
+
+public class TasksDashboardPage extends PageObject {
+ @Override
+ public String getSubTitle() {
+ return null;
+ }
+}
diff --git a/src/test/java/students/TasksPage.java b/src/test/java/students/TasksPage.java
new file mode 100644
index 0000000..5c5d42c
--- /dev/null
+++ b/src/test/java/students/TasksPage.java
@@ -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 getTasks() {
+ return driver.findElements(By.cssSelector("span.h6"));
+ }
+
+ public List 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());
+ }
+}