Merge remote-tracking branch 'origin/dev' into 89-restore-password

This commit is contained in:
Artem.Arefev 2019-05-24 01:36:01 +04:00
commit 661da17f73
10 changed files with 404 additions and 5 deletions

View File

@ -18,6 +18,6 @@ fi
ssh $USERSERVER "cd /tmp && rm -rf $ARTIFACT_NAME*.jar && echo `date` 'killed' >> log_$ARTIFACT_NAME"
scp build/libs/$ARTIFACT_NAME-0.1.0-SNAPSHOT.jar $USERSERVER:/tmp/$ARTIFACT_NAME-0.1.0-SNAPSHOT.jar
ssh $USERSERVER -f "cd /tmp/ && /opt/jdk1.8.0_192/bin/java -jar $ARTIFACT_NAME-0.1.0-SNAPSHOT.jar -Xms 512m -Xmx 1024m --server.port=8443 --server.http.port=8080 --ng-tracker.base-url=http://193.110.3.124:8080 >> /home/user/logfile_$ARTIFACT_NAME" &
ssh $USERSERVER -f "cd /tmp/ && /opt/jdk1.8.0_192/bin/java -jar $ARTIFACT_NAME-0.1.0-SNAPSHOT.jar -Xms 512m -Xmx 1024m --server.port=8443 --server.http.port=8080 --ng-tracker.base-url=http://193.110.3.124:8080 --ng-tracker.dev-mode=false >> /home/user/logfile_$ARTIFACT_NAME" &
sleep 10
echo "is deployed"

View File

@ -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()))

View File

@ -232,7 +232,7 @@ public class User extends BaseEntity {
public String getUserAbbreviate() {
return String.format(USER_ABBREVIATE_TEMPLATE,
lastName == null ? "" : lastName,
firstName == null ? "" : firstName.substring(0, 1) + ".",
patronymic == null ? "" : patronymic.substring(0, 1) + ".");
firstName == null ? "" : firstName.substring(0, 1),
patronymic == null ? "" : patronymic.substring(0, 1));
}
}

0
src/main/resources/drivers/chromedriver Normal file → Executable file
View File

0
src/main/resources/drivers/geckodriver Normal file → Executable file
View File

View File

@ -42,12 +42,20 @@
placeholder="http://"/>
</div>
<p th:if="${#fields.hasErrors('url')}" th:errors="*{url}"
class="alert alert-danger">Incorrect description</p>
<p class="help-block text-danger"></p>
<div class="form-group">
<label for="description">Описание:</label>
<textarea class="form-control" rows="8" th:field="*{description}" id="description">
</textarea>
</div>
<p th:if="${#fields.hasErrors('description')}" th:errors="*{description}"
class="alert alert-danger">Incorrect description</p>
<p class="help-block text-danger"></p>
<div class="form-group">
<label for="deadlines">Дедлайны:</label>
<div class="deadline-list form-control list-group" id="deadlines">
@ -65,6 +73,7 @@
</div>
</div>
</div>
<p th:if="${#fields.hasErrors('deadlines')}" th:errors="*{deadlines}"
class="alert alert-danger">Incorrect title</p>
<p class="help-block text-danger"></p>
@ -94,6 +103,10 @@
</div>
</div>
</div>
<p th:if="${#fields.hasErrors('beginDate') || #fields.hasErrors('endDate')}"
th:errors="*{beginDate}"
class="alert alert-danger">Incorrect date</p>
<p class="help-block text-danger"></p>
<div class="form-group">
<label for="members">Участники:</label>
@ -123,7 +136,6 @@
</div>
<div class="form-group d-flex justify-content-between flex-wrap">
<!--<input type="hidden" th:value="*{ping}" th:name="ping"/>-->
<input id="ping-button" class="btn btn-primary"
type="submit" name="pingConference" value="Ping участникам"
th:disabled="*{id == null ? 'true' : 'false'}"/>

View File

@ -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());
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,10 @@
package students;
import core.PageObject;
public class TasksDashboardPage extends PageObject {
@Override
public String getSubTitle() {
return null;
}
}

View File

@ -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());
}
}