> page = Iterables.get(navigationHolder.entrySet(), 0);
+ getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
+ GrantsPage grantsPage = (GrantsPage) getContext().initPage(page.getKey());
+ GrantPage grantPage = (GrantPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
+
+ grantsPage.getFirstGrant();
+ String grantId = grantPage.getId();
+ Integer deadlineCount = grantPage.getDeadlineCount();
+
+ String description = "deadline test";
+ String date = "09.09.2019";
+ String dateValue = "2019-09-09";
+ grantPage.addDeadline();
+ grantPage.setDeadline(date, deadlineCount, description);
+ grantPage.saveGrant();
+
+ getContext().goTo(applicationProperties.getBaseUrl() + String.format("/grants/grant?id=%s", grantId));
+
+ Assert.assertTrue(grantPage.checkDeadline(description, dateValue));
+ }
+
+ @Test
+ public void deleteDeadline() {
+ Map.Entry
> page = Iterables.get(navigationHolder.entrySet(), 0);
+ getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
+ GrantsPage grantsPage = (GrantsPage) getContext().initPage(page.getKey());
+ GrantPage grantPage = (GrantPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
+
+ grantsPage.getFirstGrant();
+ String grantId = grantPage.getId();
+ Integer deadlineCount = grantPage.getDeadlineCount();
+
+ String description = "deadline test";
+ String date = "09.09.2019";
+ String dateValue = "2019-09-09";
+ grantPage.addDeadline();
+ grantPage.setDeadline(date, deadlineCount, description);
+ grantPage.saveGrant();
+
+ getContext().goTo(applicationProperties.getBaseUrl() + String.format("/grants/grant?id=%s", grantId));
+ deadlineCount = grantPage.getDeadlineCount();
+
+ grantPage.deleteDeadline();
+ grantPage.saveGrant();
+
+ getContext().goTo(applicationProperties.getBaseUrl() + String.format("/grants/grant?id=%s", grantId));
+ Integer newDeadlineCount = grantPage.getDeadlineCount();
+ Assert.assertEquals(deadlineCount - 1, (int) newDeadlineCount);
+ }
}
diff --git a/src/test/java/grant/GrantPage.java b/src/test/java/grant/GrantPage.java
index 809e22f..9fd1986 100644
--- a/src/test/java/grant/GrantPage.java
+++ b/src/test/java/grant/GrantPage.java
@@ -83,4 +83,30 @@ public class GrantPage extends PageObject {
select.deselectByVisibleText(select.getFirstSelectedOption().getText());
return select.getAllSelectedOptions();
}
+
+ public List getDeadlineList() {
+ return driver.findElements(By.id("deadlines"));
+ }
+
+ public Integer getDeadlineCount() {
+ return getDeadlineList().size();
+ }
+
+ public void addDeadline() {
+ driver.findElement(By.id("addDeadline")).click();
+ }
+
+ public boolean checkDeadline(String description, String dateValue) {
+ return getDeadlineList()
+ .stream()
+ .anyMatch(webElement -> {
+ return webElement.findElement(By.className("div-deadline-description")).findElement(
+ By.tagName("input")).getAttribute("value").equals(description)
+ && webElement.findElement(By.className("form-deadline-date")).getAttribute("value").equals(dateValue);
+ });
+ }
+
+ public void deleteDeadline() {
+ driver.findElements(By.className("btn-delete-deadline")).get(0).click();
+ }
}