show paper page
This commit is contained in:
parent
48955b9cfd
commit
7753dd104c
@ -6,7 +6,7 @@
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
|
||||
<h:head>
|
||||
<title>Fuzzy logic</title>
|
||||
<title>NG-Tracker</title>
|
||||
<h:outputStylesheet name="css/style.css"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
|
||||
</h:head>
|
||||
|
11
src/main/resources/META-INF/resources/paper/paper.xhtml
Normal file
11
src/main/resources/META-INF/resources/paper/paper.xhtml
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
>
|
||||
<ui:composition template="/basicTemplate.xhtml">
|
||||
<ui:define name="content">
|
||||
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
</html>
|
@ -2,7 +2,7 @@
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html">
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
<ui:composition template="/basicTemplate.xhtml">
|
||||
<ui:define name="content">
|
||||
<p:dataTable value="#{paperView.papers}" var="paper" paginator="true" rows="10">
|
||||
@ -12,7 +12,10 @@
|
||||
</ui:include>
|
||||
</p:column>
|
||||
<p:column headerText="Название">
|
||||
<h:outputText value="#{paper.title}"/>
|
||||
<h:outputLink value="/paper/paper.xhtml">
|
||||
#{paper.title}
|
||||
<f:param name="id" value="#{paper.id}"/>
|
||||
</h:outputLink>
|
||||
</p:column>
|
||||
</p:dataTable>
|
||||
</ui:define>
|
||||
|
@ -1,230 +0,0 @@
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import conference.ConferencePage;
|
||||
import conference.ConferencesDashboardPage;
|
||||
import conference.ConferencesPage;
|
||||
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.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
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 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 ConferenceTest extends TestTemplate {
|
||||
private final Map<PageObject, List<String>> navigationHolder = ImmutableMap.of(
|
||||
new ConferencesPage(), Arrays.asList("КОНФЕРЕНЦИИ", "/conferences/conferences"),
|
||||
new ConferencePage(), Arrays.asList("РЕДАКТИРОВАНИЕ КОНФЕРЕНЦИИ", "/conferences/conference?id=0"),
|
||||
new ConferencesDashboardPage(), Arrays.asList("АКТУАЛЬНЫЕ КОНФЕРЕНЦИИ", "/conferences/dashboard")
|
||||
);
|
||||
|
||||
@Autowired
|
||||
private ApplicationProperties applicationProperties;
|
||||
|
||||
@Test
|
||||
public void testACreateNewConference() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 1);
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ConferencePage conferencePage = (ConferencePage) getContext().initPage(page.getKey());
|
||||
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 0).getKey());
|
||||
|
||||
String newConferenceName = "test " + (new Date()).getTime();
|
||||
conferencePage.setName(newConferenceName);
|
||||
conferencePage.clickSaveBut();
|
||||
|
||||
Assert.assertTrue(conferencesPage.checkNameInList(newConferenceName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBChangeConferenceNameAndSave() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
||||
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
|
||||
conferencesPage.getFirstConference();
|
||||
String newConferenceName = "test " + (new Date()).getTime();
|
||||
conferencePage.clearName();
|
||||
conferencePage.setName(newConferenceName);
|
||||
conferencePage.clickSaveBut();
|
||||
|
||||
Assert.assertTrue(conferencesPage.checkNameInList(newConferenceName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCAddDeadlineAndSave() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
||||
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
|
||||
conferencesPage.getFirstConference();
|
||||
String conferenceId = conferencePage.getId();
|
||||
Integer deadlineCount = conferencePage.getDeadlineCount();
|
||||
|
||||
String description = "test";
|
||||
String date = "09.09.2019";
|
||||
String dateValue = "2019-09-09";
|
||||
conferencePage.clickAddDeadlineBut();
|
||||
conferencePage.setDeadlineDescription(description, deadlineCount);
|
||||
conferencePage.setDeadlineDate(date, deadlineCount);
|
||||
conferencePage.clickSaveBut();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
||||
|
||||
Assert.assertTrue(conferencePage.checkDeadline(description, dateValue));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDTakePartAndSave() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
||||
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
|
||||
conferencesPage.getFirstConference();
|
||||
String conferenceId = conferencePage.getId();
|
||||
Integer membersCount = conferencePage.getMemberCount();
|
||||
|
||||
conferencePage.clickTakePartBut();
|
||||
conferencePage.clickSaveBut();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
||||
|
||||
Assert.assertTrue(membersCount + 1 == conferencePage.getMemberCount()
|
||||
&& conferencePage.isTakePartButDisabledValueTrue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEDeleteDeadlineAndSave() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
||||
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
|
||||
conferencesPage.getFirstConference();
|
||||
String conferenceId = conferencePage.getId();
|
||||
Integer deadlineCount = conferencePage.getDeadlineCount();
|
||||
|
||||
conferencePage.clickDeleteDeadlineBut();
|
||||
conferencePage.clickSaveBut();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
||||
|
||||
Assert.assertEquals(deadlineCount - 1, (int) conferencePage.getDeadlineCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFAttachArticle() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
||||
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
|
||||
conferencesPage.getFirstConference();
|
||||
String conferenceId = conferencePage.getId();
|
||||
Integer paperCount = conferencePage.getArticlesCount();
|
||||
|
||||
conferencePage.showAllowToAttachArticles();
|
||||
WebElement paper = conferencePage.selectArticle();
|
||||
String paperName = paper.findElement(By.className("text")).getText();
|
||||
conferencePage.clickSaveBut();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
||||
|
||||
Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount()
|
||||
&& conferencePage.checkArticle(paperName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGAddArticle() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
||||
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
|
||||
conferencesPage.getFirstConference();
|
||||
String conferenceId = conferencePage.getId();
|
||||
Integer paperCount = conferencePage.getArticlesCount();
|
||||
|
||||
conferencePage.clickAddPaperBut();
|
||||
List<WebElement> webElements = conferencePage.getArticles();
|
||||
String paperName = webElements.get(webElements.size() - 1).findElements(By.tagName("input")).get(1).getAttribute("value");
|
||||
conferencePage.clickSaveBut();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
||||
|
||||
Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount()
|
||||
&& conferencePage.checkArticle(paperName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHUndockArticle() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
||||
ConferencePage conferencePage = (ConferencePage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
|
||||
conferencesPage.getFirstConference();
|
||||
String conferenceId = conferencePage.getId();
|
||||
Integer paperCount = conferencePage.getArticlesCount();
|
||||
|
||||
conferencePage.clickUndockArticleBut();
|
||||
conferencePage.clickSaveBut();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
|
||||
|
||||
Assert.assertEquals(paperCount - 1, (int) conferencePage.getArticlesCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testISortAndFilterConferenceList() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
||||
|
||||
conferencesPage.selectMember();
|
||||
conferencesPage.selectYear();
|
||||
|
||||
Assert.assertEquals(1, conferencesPage.getConferencesList().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJDeleteConf() throws InterruptedException {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ConferencesPage conferencesPage = (ConferencesPage) getContext().initPage(page.getKey());
|
||||
|
||||
Integer size = conferencesPage.getConferencesList().size();
|
||||
conferencesPage.deleteFirst();
|
||||
Thread.sleep(3000);
|
||||
conferencesPage.clickConfirm();
|
||||
|
||||
Assert.assertEquals(size - 1, conferencesPage.getConferencesList().size());
|
||||
}
|
||||
}
|
@ -1,225 +0,0 @@
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import core.PageObject;
|
||||
import core.TestTemplate;
|
||||
import grant.GrantPage;
|
||||
import grant.GrantsDashboardPage;
|
||||
import grant.GrantsPage;
|
||||
import org.junit.Assert;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.openqa.selenium.WebElement;
|
||||
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 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 GrantTest extends TestTemplate {
|
||||
private final Map<PageObject, List<String>> navigationHolder = ImmutableMap.of(
|
||||
new GrantsPage(), Arrays.asList("ГРАНТЫ", "/grants/grants"),
|
||||
new GrantPage(), Arrays.asList("РЕДАКТИРОВАНИЕ ГРАНТА", "/grants/grant?id=0"),
|
||||
new GrantsDashboardPage(), Arrays.asList("Гранты", "/grants/dashboard")
|
||||
);
|
||||
|
||||
@Autowired
|
||||
private ApplicationProperties applicationProperties;
|
||||
|
||||
@Test
|
||||
public void aCreateNewGrant() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 1);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
GrantPage grantPage = (GrantPage) getContext().initPage(page.getKey());
|
||||
GrantsPage grantsPage = (GrantsPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 0).getKey());
|
||||
|
||||
String newGrantName = "test grant" + (new Date());
|
||||
grantPage.setTitle(newGrantName);
|
||||
String deadlineDate = new Date().toString();
|
||||
String deadlineDescription = "test deadline description";
|
||||
grantPage.setDeadline(deadlineDate, 0, deadlineDescription);
|
||||
grantPage.setLeader();
|
||||
grantPage.saveGrant();
|
||||
|
||||
Assert.assertTrue(grantsPage.findGrantByTitle(newGrantName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bCreateBlankGrant() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 1);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
GrantPage grantPage = (GrantPage) getContext().initPage(page.getKey());
|
||||
|
||||
grantPage.saveGrant();
|
||||
|
||||
Assert.assertTrue(grantPage.checkBlankFields());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cUpdateGrantTitle() {
|
||||
Map.Entry<PageObject, List<String>> 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 newGrantTitle = "test " + (new Date());
|
||||
grantPage.setTitle(newGrantTitle);
|
||||
grantPage.saveGrant();
|
||||
|
||||
Assert.assertTrue(grantsPage.findGrantByTitle(newGrantTitle));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dAttachPaper() {
|
||||
Map.Entry<PageObject, List<String>> 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();
|
||||
Integer countPapers = grantPage.getAttachedPapers().size();
|
||||
|
||||
Assert.assertEquals(countPapers + 1, grantPage.attachPaper().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void eDeletePaper() {
|
||||
Map.Entry<PageObject, List<String>> 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();
|
||||
Integer oldCountPapers = grantPage.getAttachedPapers().size();
|
||||
if (oldCountPapers == 0) {
|
||||
oldCountPapers = grantPage.attachPaper().size();
|
||||
}
|
||||
|
||||
Assert.assertEquals(oldCountPapers - 1, grantPage.deletePaper().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fAddDeadline() {
|
||||
Map.Entry<PageObject, List<String>> 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 = "08.08.2019";
|
||||
String dateValue = "2019-08-08";
|
||||
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 gDeleteDeadline() {
|
||||
Map.Entry<PageObject, List<String>> 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();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hAddAuthor() {
|
||||
Map.Entry<PageObject, List<String>> 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());
|
||||
|
||||
WebElement grant = grantsPage.getFirstGrantWithoutClick();
|
||||
String grantTitle = grantsPage.getGrantTitle(grant);
|
||||
Integer authorsCount = grantsPage.getAuthorsCount(grant);
|
||||
|
||||
grantsPage.getFirstGrant();
|
||||
grantPage.addAuthor();
|
||||
grantPage.saveGrant();
|
||||
|
||||
grant = grantsPage.getGrantByTitle(grantTitle);
|
||||
Integer newAuthorsCount = grantsPage.getAuthorsCount(grant);
|
||||
|
||||
Assert.assertEquals(authorsCount + 1, (int) newAuthorsCount);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void iDeleteAuthor() {
|
||||
Map.Entry<PageObject, List<String>> 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());
|
||||
|
||||
WebElement grant = grantsPage.getFirstGrantWithoutClick();
|
||||
String grantTitle = grantsPage.getGrantTitle(grant);
|
||||
Integer authorsCount = grantsPage.getAuthorsCount(grant);
|
||||
|
||||
grantsPage.getFirstGrant();
|
||||
grantPage.deleteAuthor();
|
||||
grantPage.saveGrant();
|
||||
|
||||
grant = grantsPage.getGrantByTitle(grantTitle);
|
||||
Integer newAuthorsCount = grantsPage.getAuthorsCount(grant);
|
||||
|
||||
authorsCount = (authorsCount == 0) ? 0 : authorsCount - 1;
|
||||
|
||||
Assert.assertEquals((int) authorsCount, (int) newAuthorsCount);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jUpdateGrantDescription() {
|
||||
Map.Entry<PageObject, List<String>> 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());
|
||||
|
||||
String description = "newDescriptionForGrant";
|
||||
grantsPage.getFirstGrant();
|
||||
String grantId = grantPage.getId();
|
||||
grantPage.setDescription(description);
|
||||
grantPage.saveGrant();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/grants/grant?id=%s", grantId));
|
||||
|
||||
Assert.assertTrue(description.equals(grantPage.getDescription()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void kDeleteGrant() throws InterruptedException {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
GrantsPage grantsPage = (GrantsPage) getContext().initPage(page.getKey());
|
||||
|
||||
Integer size = grantsPage.getGrantsList().size();
|
||||
grantsPage.deleteFirst();
|
||||
Assert.assertEquals(size - 1, grantsPage.getGrantsList().size());
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import core.PageObject;
|
||||
import core.TestTemplate;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import paper.PaperPage;
|
||||
import paper.PapersDashboardPage;
|
||||
import paper.PapersPage;
|
||||
import ru.ulstu.NgTrackerApplication;
|
||||
import ru.ulstu.configuration.ApplicationProperties;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = NgTrackerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||
public class IndexPageTest extends TestTemplate {
|
||||
private final Map<PageObject, List<String>> navigationHolder = ImmutableMap.of(
|
||||
new PapersPage(), Arrays.asList("СТАТЬИ", "/papers/papers"),
|
||||
new PaperPage(), Arrays.asList("РЕДАКТИРОВАНИЕ СТАТЬИ", "/papers/paper?id=0"),
|
||||
new PapersDashboardPage(), Arrays.asList("СТАТЬИ", "/papers/dashboard")
|
||||
);
|
||||
|
||||
@Autowired
|
||||
private ApplicationProperties applicationProperties;
|
||||
|
||||
@Test
|
||||
public void testStartApplication() {
|
||||
getContext().goTo(applicationProperties.getBaseUrl());
|
||||
Assertions
|
||||
.assertThat(getContext().getTitle())
|
||||
.isEqualTo("NG-Tracker");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModulesNavigation() {
|
||||
navigationHolder.entrySet()
|
||||
.stream()
|
||||
.forEach(navigationEntry -> {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + navigationEntry.getValue().get(1));
|
||||
PageObject pageObject = getContext().initPage(navigationEntry.getKey());
|
||||
Assertions
|
||||
.assertThat(pageObject.getSubTitle())
|
||||
.isEqualToIgnoringCase(navigationEntry.getValue().get(0));
|
||||
});
|
||||
}
|
||||
}
|
@ -1,247 +0,0 @@
|
||||
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 paper.PaperPage;
|
||||
import paper.PapersDashboardPage;
|
||||
import paper.PapersPage;
|
||||
import ru.ulstu.NgTrackerApplication;
|
||||
import ru.ulstu.configuration.ApplicationProperties;
|
||||
|
||||
import java.util.Arrays;
|
||||
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 PaperTest extends TestTemplate {
|
||||
private final Map<PageObject, List<String>> navigationHolder = ImmutableMap.of(
|
||||
new PapersPage(), Arrays.asList("СТАТЬИ", "/papers/papers"),
|
||||
new PaperPage(), Arrays.asList("РЕДАКТИРОВАНИЕ СТАТЬИ", "/papers/paper?id=0"),
|
||||
new PapersDashboardPage(), Arrays.asList("СТАТЬИ", "/papers/dashboard")
|
||||
);
|
||||
|
||||
@Autowired
|
||||
private ApplicationProperties applicationProperties;
|
||||
|
||||
private String getPaperPageUrl() {
|
||||
return Iterables.get(navigationHolder.entrySet(), 1).getValue().get(1);
|
||||
}
|
||||
|
||||
private PaperPage getPaperPage() {
|
||||
PaperPage paperPage = (PaperPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
paperPage.initElements();
|
||||
return paperPage;
|
||||
}
|
||||
|
||||
private String getPapersPageUrl() {
|
||||
return Iterables.get(navigationHolder.entrySet(), 0).getValue().get(1);
|
||||
}
|
||||
|
||||
private PapersPage getPapersPage() {
|
||||
PapersPage papersPage = (PapersPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 0).getKey());
|
||||
papersPage.initElements();
|
||||
return papersPage;
|
||||
}
|
||||
|
||||
private String getPapersDashboardPageUrl() {
|
||||
return Iterables.get(navigationHolder.entrySet(), 2).getValue().get(1);
|
||||
}
|
||||
|
||||
private PapersDashboardPage getPapersDashboardPage() {
|
||||
PapersDashboardPage papersDashboardPage = (PapersDashboardPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 2).getKey());
|
||||
papersDashboardPage.initElements();
|
||||
return papersDashboardPage;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createNewPaperTest() {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPaperPageUrl());
|
||||
PaperPage paperPage = getPaperPage();
|
||||
|
||||
String testTitle = "test " + System.currentTimeMillis();
|
||||
fillRequiredFields(paperPage, testTitle);
|
||||
paperPage.clickSaveBtn();
|
||||
|
||||
PapersPage papersPage = getPapersPage();
|
||||
|
||||
Assert.assertTrue(papersPage.havePaperWithTitle(testTitle));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void editPaperTest() {
|
||||
createNewPaper();
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPapersPageUrl());
|
||||
PapersPage papersPage = getPapersPage();
|
||||
papersPage.clickFirstPaper();
|
||||
|
||||
PaperPage paperPage = getPaperPage();
|
||||
String testTitle = "test " + System.currentTimeMillis();
|
||||
paperPage.setTitle(testTitle);
|
||||
paperPage.clickSaveBtn();
|
||||
|
||||
Assert.assertTrue(papersPage.havePaperWithTitle(testTitle));
|
||||
}
|
||||
|
||||
private void createNewPaper() {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPaperPageUrl());
|
||||
PaperPage paperPage = getPaperPage();
|
||||
String testTitle = "test " + System.currentTimeMillis();
|
||||
fillRequiredFields(paperPage, testTitle);
|
||||
paperPage.clickSaveBtn();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addDeadlineTest() {
|
||||
createNewPaper();
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPapersPageUrl());
|
||||
PapersPage papersPage = getPapersPage();
|
||||
papersPage.clickFirstPaper();
|
||||
|
||||
PaperPage paperPage = getPaperPage();
|
||||
papersPage.clickAddDeadline();
|
||||
String testDate = "01.01.2019";
|
||||
String testDateResult = "2019-01-01";
|
||||
String testDesc = "desc";
|
||||
Integer deadlineNumber = 2;
|
||||
paperPage.setDeadlineDate(deadlineNumber, testDate);
|
||||
paperPage.setDeadlineDescription(deadlineNumber, testDesc);
|
||||
String paperId = paperPage.getId();
|
||||
paperPage.clickSaveBtn();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/papers/paper?id=%s", paperId));
|
||||
|
||||
Assert.assertTrue(paperPage.deadlineExist(testDesc, testDateResult));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noDeadlinesValidationTest() {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPaperPageUrl());
|
||||
PaperPage paperPage = getPaperPage();
|
||||
|
||||
String testTitle = "test " + System.currentTimeMillis();
|
||||
paperPage.setTitle(testTitle);
|
||||
paperPage.clickSaveBtn();
|
||||
|
||||
Assert.assertTrue(paperPage.hasAlert("Не может быть пустым"));
|
||||
}
|
||||
|
||||
private void fillRequiredFields(PaperPage paperPage, String title) {
|
||||
paperPage.setTitle(title);
|
||||
String testDate = "01.01.2019";
|
||||
String testDesc = "desc";
|
||||
Integer deadlineNumber = 1;
|
||||
paperPage.setDeadlineDate(deadlineNumber, testDate);
|
||||
paperPage.setDeadlineDescription(deadlineNumber, testDesc);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addReferenceTest() {
|
||||
createNewPaper();
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPapersPageUrl());
|
||||
PapersPage papersPage = getPapersPage();
|
||||
papersPage.clickFirstPaper();
|
||||
|
||||
PaperPage paperPage = getPaperPage();
|
||||
fillRequiredFields(paperPage, "test " + System.currentTimeMillis());
|
||||
paperPage.clickReferenceTab();
|
||||
paperPage.clickAddReferenceButton();
|
||||
|
||||
paperPage.clickReferenceTab();
|
||||
paperPage.showFirstReference();
|
||||
String authors = "testAuthors";
|
||||
paperPage.setFirstReferenceAuthors(authors);
|
||||
|
||||
String paperId = paperPage.getId();
|
||||
paperPage.clickSaveBtn();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/papers/paper?id=%s", paperId));
|
||||
|
||||
Assert.assertTrue(paperPage.authorsExists(authors));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void referencesFormatTest() {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPaperPageUrl());
|
||||
|
||||
PaperPage paperPage = getPaperPage();
|
||||
paperPage.setTitle("test");
|
||||
paperPage.clickReferenceTab();
|
||||
paperPage.clickAddReferenceButton();
|
||||
|
||||
paperPage.clickReferenceTab();
|
||||
paperPage.showFirstReference();
|
||||
paperPage.setFirstReferenceAuthors("authors");
|
||||
paperPage.setFirstReferencePublicationTitle("title");
|
||||
paperPage.setFirstReferencePublicationYear("2010");
|
||||
paperPage.setFirstReferencePublisher("publisher");
|
||||
paperPage.setFirstReferencePages("200");
|
||||
paperPage.setFirstReferenceJournalOrCollectionTitle("journal");
|
||||
paperPage.setFormatStandardSpringer();
|
||||
paperPage.clickFormatButton();
|
||||
|
||||
Assert.assertEquals("authors (2010) title. journal, publisher, pp 200", paperPage.getFormatString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dashboardLinkTest() {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPaperPageUrl());
|
||||
PaperPage paperPage = getPaperPage();
|
||||
|
||||
fillRequiredFields(paperPage, "test " + System.currentTimeMillis());
|
||||
String testLink = "http://test.com/";
|
||||
paperPage.setUrl(testLink);
|
||||
paperPage.clickSaveBtn();
|
||||
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPapersDashboardPageUrl());
|
||||
PapersDashboardPage papersDashboardPage = getPapersDashboardPage();
|
||||
|
||||
Assert.assertTrue(papersDashboardPage.externalLinkExists(testLink));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deletePaperTest() {
|
||||
createNewPaper();
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPapersPageUrl());
|
||||
PapersPage papersPage = getPapersPage();
|
||||
|
||||
int size = papersPage.getPapersCount();
|
||||
papersPage.clickRemoveFirstPaperButton();
|
||||
papersPage.clickConfirmDeleteButton();
|
||||
|
||||
Assert.assertEquals(size - 1, papersPage.getPapersCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void latexValidationTest() {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPaperPageUrl());
|
||||
|
||||
PaperPage paperPage = getPaperPage();
|
||||
paperPage.setTitle("test");
|
||||
paperPage.clickLatexTab();
|
||||
paperPage.setLatexText("test");
|
||||
paperPage.clickPdfButton();
|
||||
|
||||
Assert.assertTrue(paperPage.dangerMessageExist("Ошибка при создании PDF"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void titleValidationTest() {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPaperPageUrl());
|
||||
PaperPage paperPage = getPaperPage();
|
||||
|
||||
paperPage.clickSaveBtn();
|
||||
|
||||
Assert.assertTrue(paperPage.hasAlert("не может быть пусто"));
|
||||
}
|
||||
|
||||
}
|
@ -1,174 +0,0 @@
|
||||
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 project.ProjectDashboard;
|
||||
import project.ProjectPage;
|
||||
import project.ProjectsPage;
|
||||
import ru.ulstu.NgTrackerApplication;
|
||||
import ru.ulstu.configuration.ApplicationProperties;
|
||||
|
||||
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 ProjectTest extends TestTemplate {
|
||||
private final Map<PageObject, List<String>> navigationHolder = ImmutableMap.of(
|
||||
new ProjectPage(), Arrays.asList("ПРОЕКТЫ", "/projects/projects"),
|
||||
new ProjectsPage(), Arrays.asList("РЕДАКТИРОВАНИЕ ПРОЕКТА", "/projects/project?id=0"),
|
||||
new ProjectDashboard(), Arrays.asList("ПРОЕКТЫ", "/projects/dashboard")
|
||||
);
|
||||
|
||||
@Autowired
|
||||
private ApplicationProperties applicationProperties;
|
||||
|
||||
@Test
|
||||
public void testACreateNewProject() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 1);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ProjectsPage projectsPage = (ProjectsPage) getContext().initPage(page.getKey());
|
||||
ProjectPage projectPage = (ProjectPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 0).getKey());
|
||||
String name = "Project " + (new Date()).getTime();
|
||||
String date = "01.01.2019";
|
||||
Integer deadNum = projectPage.getDeadlineCount();
|
||||
projectPage.setName(name);
|
||||
projectPage.clickAddDeadline();
|
||||
projectPage.addDeadlineDate(date, deadNum);
|
||||
projectPage.clickSave();
|
||||
Assert.assertTrue(projectsPage.checkNameInList(name));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBChangeNameAndSave() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ProjectPage projectPage = (ProjectPage) getContext().initPage(page.getKey());
|
||||
ProjectsPage projectsPage = (ProjectsPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
projectsPage.getFirstProject();
|
||||
String name = "Project " + (new Date()).getTime();
|
||||
projectPage.clearName();
|
||||
projectPage.setName(name);
|
||||
projectPage.clickSave();
|
||||
Assert.assertTrue(projectsPage.checkNameInList(name));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCChangeDeadlineAndSave() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ProjectPage projectPage = (ProjectPage) getContext().initPage(page.getKey());
|
||||
ProjectsPage projectsPage = (ProjectsPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
projectsPage.getFirstProject();
|
||||
String name = projectPage.getName();
|
||||
String date = "01.01.2019";
|
||||
Integer deadNum = projectPage.getDeadlineCount();
|
||||
projectPage.addDeadlineDate(date, deadNum);
|
||||
projectPage.clickSave();
|
||||
Assert.assertTrue(projectsPage.checkNameInList(name));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDSetStatusAndSave() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ProjectPage projectPage = (ProjectPage) getContext().initPage(page.getKey());
|
||||
ProjectsPage projectsPage = (ProjectsPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
projectsPage.getFirstProject();
|
||||
String name = projectPage.getName();
|
||||
projectPage.setStatus();
|
||||
projectPage.clickSave();
|
||||
Assert.assertTrue(projectsPage.checkNameInList(name));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEAddDescriptionAndSave() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ProjectPage projectPage = (ProjectPage) getContext().initPage(page.getKey());
|
||||
ProjectsPage projectsPage = (ProjectsPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
projectsPage.getFirstProject();
|
||||
String name = projectPage.getName();
|
||||
String description = "Description " + (new Date()).getTime();
|
||||
projectPage.addDescription(description);
|
||||
projectPage.clickSave();
|
||||
Assert.assertTrue(projectsPage.checkNameInList(name));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFAddLinkAndSave() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ProjectPage projectPage = (ProjectPage) getContext().initPage(page.getKey());
|
||||
ProjectsPage projectsPage = (ProjectsPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
projectsPage.getFirstProject();
|
||||
String name = projectPage.getName();
|
||||
String link = "Link " + (new Date()).getTime();
|
||||
projectPage.addLink(link);
|
||||
projectPage.clickSave();
|
||||
Assert.assertTrue(projectsPage.checkNameInList(name));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGAddDeadlineDescriptionAndSave() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ProjectPage projectPage = (ProjectPage) getContext().initPage(page.getKey());
|
||||
ProjectsPage projectsPage = (ProjectsPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
projectsPage.getFirstProject();
|
||||
String name = projectPage.getName();
|
||||
String deadDesc = "Description " + (new Date()).getTime();
|
||||
projectPage.addDeadlineDescription(deadDesc);
|
||||
projectPage.clickSave();
|
||||
Assert.assertTrue(projectsPage.checkNameInList(name));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHSetDeadlineCompletionAndSave() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ProjectPage projectPage = (ProjectPage) getContext().initPage(page.getKey());
|
||||
ProjectsPage projectsPage = (ProjectsPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
projectsPage.getFirstProject();
|
||||
String name = projectPage.getName();
|
||||
projectPage.setDeadlineCompletion();
|
||||
projectPage.clickSave();
|
||||
Assert.assertTrue(projectsPage.checkNameInList(name));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIDeleteDeadline() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ProjectPage projectPage = (ProjectPage) getContext().initPage(page.getKey());
|
||||
ProjectsPage projectsPage = (ProjectsPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
projectsPage.getFirstProject();
|
||||
projectPage.clickDeleteDeadline();
|
||||
Assert.assertTrue(projectPage.getDeadlineCount() == 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJDeleteProject() {
|
||||
Map.Entry<PageObject, List<String>> page = Iterables.get(navigationHolder.entrySet(), 0);
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + page.getValue().get(1));
|
||||
ProjectPage projectPage = (ProjectPage) getContext().initPage(page.getKey());
|
||||
ProjectsPage projectsPage = (ProjectsPage) getContext().initPage(Iterables.get(navigationHolder.entrySet(), 1).getKey());
|
||||
projectsPage.getFirstProject();
|
||||
String name = projectPage.getName();
|
||||
projectPage.clickSave();
|
||||
projectsPage.deleteFirst();
|
||||
projectsPage.clickConfirm();
|
||||
Assert.assertFalse(projectsPage.checkNameInList(name));
|
||||
}
|
||||
}
|
@ -1,214 +0,0 @@
|
||||
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 StudentTaskTest 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());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
package conference;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConferencePage extends PageObject {
|
||||
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h3")).getText();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return driver.findElement(By.id("id")).getAttribute("value");
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
driver.findElement(By.id("title")).sendKeys(name);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return driver.findElement(By.id("title")).getAttribute("value");
|
||||
}
|
||||
|
||||
public void clearName() {
|
||||
driver.findElement(By.id("title")).clear();
|
||||
}
|
||||
|
||||
public void clickSaveBut() {
|
||||
driver.findElement(By.id("send-message-button")).click();
|
||||
}
|
||||
|
||||
public void clickAddDeadlineBut() {
|
||||
driver.findElement(By.id("addDeadline")).click();
|
||||
}
|
||||
|
||||
private List<WebElement> getDeadlineList() {
|
||||
return driver.findElements(By.className("deadline"));
|
||||
}
|
||||
|
||||
public Integer getDeadlineCount() {
|
||||
return driver.findElements(By.className("deadline")).size();
|
||||
}
|
||||
|
||||
public void setDeadlineDescription(String description, Integer i) {
|
||||
driver.findElement(By.id(String.format("deadlines%d.description", i))).sendKeys(description);
|
||||
}
|
||||
|
||||
public void setDeadlineDate(String date, Integer i) {
|
||||
driver.findElement(By.id(String.format("deadlines%d.date", i))).sendKeys(date);
|
||||
}
|
||||
|
||||
public void clickTakePartBut() {
|
||||
driver.findElement(By.id("take-part")).click();
|
||||
}
|
||||
|
||||
public Boolean isTakePartButDisabledValueTrue() {
|
||||
return driver.findElement(By.id("take-part")).getAttribute("disabled").equals("true");
|
||||
}
|
||||
|
||||
public Integer getMemberCount() {
|
||||
return driver.findElements(By.className("member")).size();
|
||||
}
|
||||
|
||||
public void clickDeleteDeadlineBut() {
|
||||
driver.findElement(By.xpath("//*[@id=\"deadlines\"]/div/input[4]")).click();
|
||||
}
|
||||
|
||||
public void showAllowToAttachArticles() {
|
||||
driver.findElement(By.cssSelector("button[data-id=\"paperIds\"]")).click();
|
||||
}
|
||||
|
||||
public void clickAddPaperBut() {
|
||||
driver.findElement(By.id("add-paper")).click();
|
||||
}
|
||||
|
||||
|
||||
public List<WebElement> getArticles() {
|
||||
return driver.findElements(By.className("paper"));
|
||||
}
|
||||
|
||||
public Integer getArticlesCount() {
|
||||
return driver.findElements(By.className("paper")).size();
|
||||
}
|
||||
|
||||
public WebElement selectArticle() {
|
||||
WebElement webElement = driver.findElement(By.xpath("//*[@id=\"conference-form\"]/div/div[2]/div[5]/div/div/div[2]/ul/li[1]/a"));
|
||||
webElement.click();
|
||||
return webElement;
|
||||
}
|
||||
|
||||
public void clickUndockArticleBut() {
|
||||
driver.findElement(By.name("removePaper")).click();
|
||||
}
|
||||
|
||||
public boolean checkDeadline(String description, String dateValue) {
|
||||
return getDeadlineList()
|
||||
.stream()
|
||||
.anyMatch(webElement -> {
|
||||
return webElement.findElement(By.className("deadline-text")).getAttribute("value").equals(description)
|
||||
&& webElement.findElement(By.cssSelector("input[type=\"date\"]")).getAttribute("value").equals(dateValue);
|
||||
});
|
||||
}
|
||||
|
||||
public boolean checkArticle(String paperName) {
|
||||
return getArticles()
|
||||
.stream()
|
||||
.anyMatch(webElement -> webElement
|
||||
.findElements(By.tagName("input"))
|
||||
.get(1).getAttribute("value")
|
||||
.equals(paperName));
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package conference;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
|
||||
public class ConferencesDashboardPage extends PageObject {
|
||||
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h2")).getText();
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package conference;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConferencesPage extends PageObject {
|
||||
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h3")).getText();
|
||||
}
|
||||
|
||||
public List<WebElement> getConferencesList() {
|
||||
return driver.findElements(By.cssSelector("span.h6.float-left.m-2"));
|
||||
}
|
||||
|
||||
public void getFirstConference() {
|
||||
driver.findElement(By.xpath("//*[@id=\"conferences\"]/div/div[2]/div[1]/div[1]/div/a")).click();
|
||||
}
|
||||
|
||||
public void selectMember() {
|
||||
driver.findElements(By.className("bootstrap-select")).get(0).findElement(By.className("btn")).click();
|
||||
driver.findElements(By.className("bootstrap-select")).get(0).findElements(By.className("dropdown-item")).get(1).click();
|
||||
}
|
||||
|
||||
public void selectYear() {
|
||||
driver.findElements(By.className("bootstrap-select")).get(1).findElement(By.className("btn")).click();
|
||||
driver.findElements(By.className("bootstrap-select")).get(1).findElements(By.className("dropdown-item")).get(1).click();
|
||||
}
|
||||
|
||||
public void deleteFirst() {
|
||||
js.executeScript("$('input[data-confirm]').click();");
|
||||
}
|
||||
|
||||
public void clickConfirm() {
|
||||
driver.findElement(By.id("deleteConference")).click();
|
||||
}
|
||||
|
||||
|
||||
public boolean checkNameInList(String newConferenceName) {
|
||||
return getConferencesList()
|
||||
.stream()
|
||||
.anyMatch(webElement -> webElement.getText().equals(newConferenceName));
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package context;
|
||||
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.chrome.ChromeOptions;
|
||||
|
||||
public class ChromeContext extends Context {
|
||||
private final static String WINDOWS_DRIVER = "chromedriver.exe";
|
||||
private final static String LINUX_DRIVER = "chromedriver";
|
||||
private final static String DRIVER_TYPE = "webdriver.chrome.driver";
|
||||
|
||||
@Override
|
||||
protected void createDriver() {
|
||||
final ChromeOptions chromeOptions = new ChromeOptions();
|
||||
chromeOptions.addArguments("--headless");
|
||||
driver = new ChromeDriver(chromeOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverExecutable(boolean isWindows) {
|
||||
return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverType() {
|
||||
return DRIVER_TYPE;
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package context;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.Dimension;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public abstract class Context {
|
||||
private final static String DRIVER_LOCATION = "drivers/%s";
|
||||
|
||||
WebDriver driver;
|
||||
|
||||
private WebDriver getDriver() {
|
||||
if (driver != null) {
|
||||
return driver;
|
||||
}
|
||||
throw new IllegalStateException("WebDriver is not initialized");
|
||||
}
|
||||
|
||||
public void start() {
|
||||
System.setProperty(getDriverType(), getDriverExecutablePath());
|
||||
|
||||
createDriver();
|
||||
// это плохая инструкция для автотестов, т.к. лучше задавать для конкретного элемента или кейса
|
||||
getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (driver != null) {
|
||||
driver.quit();
|
||||
}
|
||||
}
|
||||
|
||||
public void goTo(String url) {
|
||||
getDriver().get(url);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return getDriver().getTitle();
|
||||
}
|
||||
|
||||
public <T extends PageObject> PageObject initPage(T pageObject) {
|
||||
return pageObject.setDriver(getDriver());
|
||||
}
|
||||
|
||||
protected abstract void createDriver();
|
||||
|
||||
protected abstract String getDriverType();
|
||||
|
||||
protected abstract String getDriverExecutable(boolean windows);
|
||||
|
||||
private String getDriverExecutablePath() {
|
||||
return Context.class.getClassLoader().getResource(
|
||||
String.format(DRIVER_LOCATION, getDriverExecutable(isWindows()))).getFile();
|
||||
}
|
||||
|
||||
private boolean isWindows() {
|
||||
return System.getProperty("os.name").toLowerCase().contains("windows");
|
||||
}
|
||||
|
||||
public void setSize(Dimension dimension) {
|
||||
driver.manage().window().setSize(dimension);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package context;
|
||||
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
|
||||
public class FirefoxContext extends Context {
|
||||
private final static String WINDOWS_DRIVER = "geckodriver.exe";
|
||||
private final static String LINUX_DRIVER = "geckodriver";
|
||||
private final static String DRIVER_TYPE = "webdriver.gecko.driver";
|
||||
|
||||
@Override
|
||||
protected void createDriver() {
|
||||
driver = new FirefoxDriver();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverExecutable(boolean isWindows) {
|
||||
return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverType() {
|
||||
return DRIVER_TYPE;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package core;
|
||||
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
public abstract class PageObject {
|
||||
protected WebDriver driver;
|
||||
protected JavascriptExecutor js;
|
||||
protected WebDriverWait waiter;
|
||||
|
||||
public abstract String getSubTitle();
|
||||
|
||||
public PageObject setDriver(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
js = (JavascriptExecutor) driver;
|
||||
waiter = new WebDriverWait(driver, 10);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void initElements() {
|
||||
PageFactory.initElements(driver, this);
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package core;
|
||||
|
||||
import context.ChromeContext;
|
||||
import context.Context;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.openqa.selenium.Dimension;
|
||||
|
||||
public abstract class TestTemplate {
|
||||
private static Context context;
|
||||
|
||||
protected static Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
context = new ChromeContext();
|
||||
context.start();
|
||||
context.setSize(new Dimension(1600, 900));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void quit() {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
package grant;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.ui.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GrantPage extends PageObject {
|
||||
@Override
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h2")).getText();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return driver.findElement(By.id("grantId")).getAttribute("value");
|
||||
}
|
||||
|
||||
public void setTitle(String name) {
|
||||
driver.findElement(By.id("title")).clear();
|
||||
driver.findElement(By.id("title")).sendKeys(name);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return driver.findElement(By.id("title")).getAttribute("value");
|
||||
}
|
||||
|
||||
public void setDeadline(String date, Integer i, String description) {
|
||||
driver.findElement(By.id(String.format("deadlines%d.date", i))).sendKeys(date);
|
||||
driver.findElement(By.id(String.format("deadlines%d.description", i))).sendKeys(description);
|
||||
}
|
||||
|
||||
public void setLeader() {
|
||||
WebElement webElement = driver.findElement(By.id("leaderId"));
|
||||
Select selectLeader = new Select(webElement);
|
||||
selectLeader.selectByVisibleText("Романов");
|
||||
}
|
||||
|
||||
public void saveGrant() {
|
||||
driver.findElement(By.id("sendMessageButton")).click();
|
||||
}
|
||||
|
||||
public boolean checkBlankFields() {
|
||||
return driver.findElements(By.className("alert-danger")).size() > 0;
|
||||
}
|
||||
|
||||
public List<WebElement> getAttachedPapers() {
|
||||
try {
|
||||
return driver.findElement(By.className("div-selected-papers")).findElements(By.tagName("div"));
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<WebElement> attachPaper() {
|
||||
WebElement selectPapers = driver.findElement(By.id("allPapers"));
|
||||
Select select = new Select(selectPapers);
|
||||
List<WebElement> selectedOptions = select.getAllSelectedOptions();
|
||||
List<WebElement> allOptions = select.getOptions();
|
||||
if (selectedOptions.size() >= allOptions.size()) {
|
||||
for (int i = 0; i < allOptions.size(); i++) {
|
||||
if (!allOptions.get(i).equals(selectedOptions.get(i))) {
|
||||
select.selectByVisibleText(allOptions.get(i).getText());
|
||||
selectedOptions.add(allOptions.get(i));
|
||||
return selectedOptions;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
select.selectByVisibleText(allOptions.get(0).getText());
|
||||
selectedOptions.add(allOptions.get(0));
|
||||
return selectedOptions;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<WebElement> deletePaper() {
|
||||
WebElement selectPapers = driver.findElement(By.id("allPapers"));
|
||||
Select select = new Select(selectPapers);
|
||||
select.deselectByVisibleText(select.getFirstSelectedOption().getText());
|
||||
return select.getAllSelectedOptions();
|
||||
}
|
||||
|
||||
private List<WebElement> 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();
|
||||
}
|
||||
|
||||
public List<WebElement> addAuthor() {
|
||||
WebElement selectAuthors = driver.findElement(By.id("authors"));
|
||||
Select select = new Select(selectAuthors);
|
||||
List<WebElement> selectedOptions = select.getAllSelectedOptions();
|
||||
List<WebElement> allOptions = select.getOptions();
|
||||
int i = 0;
|
||||
while (i < selectedOptions.size()) {
|
||||
if (!allOptions.get(i).equals(selectedOptions.get(i))) {
|
||||
select.selectByVisibleText(allOptions.get(i).getText());
|
||||
selectedOptions.add(allOptions.get(i));
|
||||
return selectedOptions;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (selectedOptions.size() != allOptions.size()) {
|
||||
select.selectByVisibleText(allOptions.get(i).getText());
|
||||
selectedOptions.add(allOptions.get(i));
|
||||
}
|
||||
return selectedOptions;
|
||||
}
|
||||
|
||||
public void deleteAuthor() {
|
||||
WebElement selectAuthors = driver.findElement(By.id("authors"));
|
||||
Select select = new Select(selectAuthors);
|
||||
List<WebElement> selectedOptions = select.getAllSelectedOptions();
|
||||
if (selectedOptions.size() != 0) {
|
||||
select.deselectByVisibleText(selectedOptions.get(0).getText());
|
||||
}
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
driver.findElement(By.id("comment")).clear();
|
||||
driver.findElement(By.id("comment")).sendKeys(description);
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return driver.findElement(By.id("comment")).getText();
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package grant;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
|
||||
public class GrantsDashboardPage extends PageObject {
|
||||
@Override
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h2")).getText();
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
package grant;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GrantsPage extends PageObject {
|
||||
@Override
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h2")).getText();
|
||||
}
|
||||
|
||||
public List<WebElement> getGrantsList() {
|
||||
return driver.findElements(By.className("grant-row"));
|
||||
}
|
||||
|
||||
public boolean findGrantByTitle(String grantTitle) {
|
||||
return getGrantsList()
|
||||
.stream()
|
||||
.map(el -> el.findElement(By.cssSelector("span.h6")))
|
||||
.anyMatch(webElement -> webElement.getText().equals(grantTitle));
|
||||
}
|
||||
|
||||
public void deleteFirst() throws InterruptedException {
|
||||
WebElement findDeleteButton = driver.findElement(By.xpath("//*[@id=\"grants\"]/div/div[2]/div[1]/div[1]/div"));
|
||||
findDeleteButton.click();
|
||||
Thread.sleep(3000);
|
||||
WebElement grant = driver.findElement(By.xpath("//*[@id=\"grants\"]/div/div[2]/div[1]/div[1]/div/a[2]"));
|
||||
grant.click();
|
||||
WebElement ok = driver.findElement(By.id("dataConfirmOK"));
|
||||
ok.click();
|
||||
}
|
||||
|
||||
public void getFirstGrant() {
|
||||
driver.findElement(By.xpath("//*[@id=\"grants\"]/div/div[2]/div[1]/div[1]/div/a[1]")).click();
|
||||
}
|
||||
|
||||
public WebElement getFirstGrantWithoutClick() {
|
||||
return driver.findElement(By.xpath("//*[@id=\"grants\"]/div/div[2]/div[1]/div[1]"));
|
||||
}
|
||||
|
||||
public String getGrantTitle(WebElement webElement) {
|
||||
return webElement.findElement(By.cssSelector("span.h6")).getText();
|
||||
}
|
||||
|
||||
public WebElement getGrantByTitle(String title) {
|
||||
List<WebElement> list = getGrantsList();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (getGrantTitle(list.get(i)).equals(title)) {
|
||||
return list.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Integer getAuthorsCount(WebElement webElement) {
|
||||
String authors = webElement.findElement(By.className("text-muted")).getText();
|
||||
if (!authors.equals("")) {
|
||||
String[] mas = authors.split(",");
|
||||
return mas.length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package grant;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
|
||||
public class KiasPage extends PageObject {
|
||||
@Override
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h1")).getText();
|
||||
}
|
||||
}
|
@ -1,217 +0,0 @@
|
||||
package paper;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PaperPage extends PageObject {
|
||||
|
||||
@FindBy(id = "title")
|
||||
private WebElement titleInput;
|
||||
|
||||
@FindBy(id = "sendMessageButton")
|
||||
private WebElement sendMessageButton;
|
||||
|
||||
@FindBy(id = "id")
|
||||
private WebElement idInput;
|
||||
|
||||
@FindBy(css = "#messages .alert-danger span")
|
||||
private WebElement dangerMessage;
|
||||
|
||||
@FindBy(className = "deadline")
|
||||
private List<WebElement> deadlines;
|
||||
|
||||
@FindBy(className = "deadline-date")
|
||||
private List<WebElement> deadlineDates;
|
||||
|
||||
@FindBy(className = "deadline-desc")
|
||||
private List<WebElement> deadlineDescs;
|
||||
|
||||
@FindBy(css = ".alert.alert-danger")
|
||||
private List<WebElement> dangerAlerts;
|
||||
|
||||
@FindBy(className = "collapse-heading")
|
||||
private WebElement firstCollapsedLink;
|
||||
|
||||
@FindBy(id = "nav-references-tab")
|
||||
private WebElement referenceTab;
|
||||
|
||||
@FindBy(id = "nav-latex-tab")
|
||||
private WebElement latexTab;
|
||||
|
||||
@FindBy(id = "latex-text")
|
||||
private WebElement latexTextarea;
|
||||
|
||||
@FindBy(id = "addReference")
|
||||
private WebElement addReferenceButton;
|
||||
|
||||
@FindBy(css = "input.author ")
|
||||
private WebElement firstAuthorInput;
|
||||
|
||||
@FindBy(css = "input.publicationTitle")
|
||||
private WebElement firstPublicationTitleInput;
|
||||
|
||||
@FindBy(css = "input.publicationYear")
|
||||
private WebElement firstPublicationYearInput;
|
||||
|
||||
@FindBy(css = "input.publisher")
|
||||
private WebElement firstPublisherInput;
|
||||
|
||||
@FindBy(css = "input.pages")
|
||||
private WebElement firstPagesInput;
|
||||
|
||||
@FindBy(css = "input.journalOrCollectionTitle")
|
||||
private WebElement firstJournalOrCollectionTitleInput;
|
||||
|
||||
@FindBy(id = "formatBtn")
|
||||
private WebElement formatButton;
|
||||
|
||||
@FindBy(id = "formattedReferencesArea")
|
||||
private WebElement formatArea;
|
||||
|
||||
@FindBy(id = "url")
|
||||
private WebElement urlInput;
|
||||
|
||||
@FindBy(id = "pdfBtn")
|
||||
private WebElement pdfButton;
|
||||
|
||||
@FindBy(css = "input.author ")
|
||||
private List<WebElement> authorInputs;
|
||||
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h2")).getText();
|
||||
}
|
||||
|
||||
public void clickReferenceTab() {
|
||||
js.executeScript("document.getElementById('nav-references-tab').scrollIntoView(false);");
|
||||
referenceTab.click();
|
||||
}
|
||||
|
||||
public void clickLatexTab() {
|
||||
latexTab.click();
|
||||
}
|
||||
|
||||
public void showFirstReference() {
|
||||
waiter.until(ExpectedConditions.elementToBeClickable(firstCollapsedLink));
|
||||
firstCollapsedLink.click();
|
||||
}
|
||||
|
||||
public void clickAddReferenceButton() {
|
||||
js.executeScript("arguments[0].click()", addReferenceButton);
|
||||
}
|
||||
|
||||
public void clickFormatButton() {
|
||||
formatButton.click();
|
||||
}
|
||||
|
||||
public void clickPdfButton() {
|
||||
pdfButton.click();
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
titleInput.clear();
|
||||
titleInput.sendKeys(title);
|
||||
}
|
||||
|
||||
public void setLatexText(String text) {
|
||||
waiter.until(ExpectedConditions.visibilityOf(latexTextarea));
|
||||
latexTextarea.clear();
|
||||
latexTextarea.sendKeys(text);
|
||||
}
|
||||
|
||||
public void setFirstReferenceAuthors(String authors) {
|
||||
waiter.until(ExpectedConditions.visibilityOf(firstAuthorInput));
|
||||
|
||||
firstAuthorInput.clear();
|
||||
firstAuthorInput.sendKeys(authors);
|
||||
}
|
||||
|
||||
public void setFirstReferencePublicationTitle(String title) {
|
||||
firstPublicationTitleInput.clear();
|
||||
firstPublicationTitleInput.sendKeys(title);
|
||||
}
|
||||
|
||||
public void setFirstReferencePublicationYear(String year) {
|
||||
firstPublicationYearInput.clear();
|
||||
firstPublicationYearInput.sendKeys(year);
|
||||
}
|
||||
|
||||
public void setFirstReferencePublisher(String publisher) {
|
||||
firstPublisherInput.clear();
|
||||
firstPublisherInput.sendKeys(publisher);
|
||||
}
|
||||
|
||||
public void setFirstReferencePages(String pages) {
|
||||
firstPagesInput.clear();
|
||||
firstPagesInput.sendKeys(pages);
|
||||
}
|
||||
|
||||
public void setFirstReferenceJournalOrCollectionTitle(String journal) {
|
||||
firstJournalOrCollectionTitleInput.clear();
|
||||
firstJournalOrCollectionTitleInput.sendKeys(journal);
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
urlInput.clear();
|
||||
urlInput.sendKeys(url);
|
||||
}
|
||||
|
||||
public void setFormatStandardSpringer() {
|
||||
Select standards = new Select(driver.findElement(By.id("formatStandard")));
|
||||
standards.selectByValue("SPRINGER");
|
||||
}
|
||||
|
||||
public void setDeadlineDate(Integer deadlineNumber, String date) {
|
||||
deadlineDates.get(deadlineNumber - 1).sendKeys(date);
|
||||
}
|
||||
|
||||
public void setDeadlineDescription(Integer deadlineNumber, String desc) {
|
||||
deadlineDescs.get(deadlineNumber - 1).clear();
|
||||
deadlineDescs.get(deadlineNumber - 1).sendKeys(desc);
|
||||
}
|
||||
|
||||
public boolean hasAlert(String alertMessage) {
|
||||
return dangerAlerts
|
||||
.stream()
|
||||
.anyMatch(
|
||||
webElement -> webElement.getText().contains(alertMessage));
|
||||
}
|
||||
|
||||
public void clickSaveBtn() {
|
||||
sendMessageButton.click();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return idInput.getAttribute("value");
|
||||
}
|
||||
|
||||
public String getFormatString() {
|
||||
waiter.until(ExpectedConditions.attributeToBeNotEmpty(formatArea, "value"));
|
||||
return formatArea.getAttribute("value");
|
||||
}
|
||||
|
||||
public boolean deadlineExist(String desc, String date) {
|
||||
return deadlines
|
||||
.stream()
|
||||
.anyMatch(
|
||||
webElement -> webElement.findElement(By.className("deadline-desc")).getAttribute("value").equals(desc)
|
||||
&& webElement.findElement(By.className("deadline-date")).getAttribute("value").equals(date));
|
||||
}
|
||||
|
||||
public boolean authorsExists(String authors) {
|
||||
return authorInputs
|
||||
.stream()
|
||||
.anyMatch(
|
||||
webElement -> webElement.getAttribute("value").equals(authors));
|
||||
}
|
||||
|
||||
public boolean dangerMessageExist(String message) {
|
||||
waiter.until(ExpectedConditions.visibilityOf(dangerMessage));
|
||||
return dangerMessage.getText().equals(message);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package paper;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PapersDashboardPage extends PageObject {
|
||||
@FindBy(className = "externalLink")
|
||||
private List<WebElement> externalLinks;
|
||||
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h2")).getText();
|
||||
}
|
||||
|
||||
public boolean externalLinkExists(String link) {
|
||||
return externalLinks
|
||||
.stream()
|
||||
.anyMatch(
|
||||
webElement -> webElement.getAttribute("href").equals(link));
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package paper;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PapersPage extends PageObject {
|
||||
@FindBy(css = ".paper-row .h6")
|
||||
private List<WebElement> paperTitles;
|
||||
|
||||
@FindBy(className = "paper-row")
|
||||
private List<WebElement> paperItems;
|
||||
|
||||
@FindBy(className = "remove-paper")
|
||||
private WebElement removeFirstPaperButton;
|
||||
|
||||
@FindBy(id = "dataConfirmOK")
|
||||
private WebElement confirmDeleteButton;
|
||||
|
||||
@FindBy(id = "addDeadline")
|
||||
private WebElement addDeadlineButton;
|
||||
|
||||
@FindBy(css = ".paper-row a:nth-child(2)")
|
||||
private WebElement firstPaper;
|
||||
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h2")).getText();
|
||||
}
|
||||
|
||||
public void clickFirstPaper() {
|
||||
firstPaper.click();
|
||||
}
|
||||
|
||||
public void clickAddDeadline() {
|
||||
addDeadlineButton.click();
|
||||
}
|
||||
|
||||
public void clickRemoveFirstPaperButton() {
|
||||
js.executeScript("arguments[0].click()", removeFirstPaperButton);
|
||||
}
|
||||
|
||||
public void clickConfirmDeleteButton() {
|
||||
waiter.until(ExpectedConditions.visibilityOf(confirmDeleteButton));
|
||||
confirmDeleteButton.click();
|
||||
}
|
||||
|
||||
public boolean havePaperWithTitle(String title) {
|
||||
return paperTitles
|
||||
.stream()
|
||||
.anyMatch(webElement -> webElement.getText().equals(title));
|
||||
}
|
||||
|
||||
public int getPapersCount() {
|
||||
return paperItems.size();
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package project;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
|
||||
public class ProjectDashboard extends PageObject {
|
||||
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h2")).getText();
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
package project;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectPage extends PageObject {
|
||||
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h3")).getText();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return driver.findElement(By.id("id")).getAttribute("value");
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
driver.findElement(By.id("title")).sendKeys(name);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return driver.findElement(By.id("title")).getAttribute("value");
|
||||
}
|
||||
|
||||
public void clearName() {
|
||||
driver.findElement(By.id("title")).clear();
|
||||
}
|
||||
|
||||
public void clickSave() {
|
||||
driver.findElement(By.id("sendMessageButton")).click();
|
||||
}
|
||||
|
||||
public void clickAddDeadline() {
|
||||
driver.findElement(By.id("addDeadline")).click();
|
||||
}
|
||||
|
||||
public void addDeadlineDate(String deadDate, Integer deadNum) {
|
||||
driver.findElement(By.id(String.format("deadlines%d.date", deadNum))).sendKeys(deadDate);
|
||||
}
|
||||
|
||||
public void addDeadlineDescription(String description) {
|
||||
driver.findElement(By.id("deadlines0.description")).sendKeys(description);
|
||||
}
|
||||
|
||||
public void setDeadlineCompletion() {
|
||||
driver.findElement(By.id("deadlines0.done1")).click();
|
||||
}
|
||||
|
||||
public void setStatus() {
|
||||
driver.findElement(By.id("status")).click();
|
||||
getFirstStatus();
|
||||
}
|
||||
|
||||
private void getFirstStatus() {
|
||||
driver.findElement(By.xpath("//*[@id=\"status\"]/option[1]")).click();
|
||||
}
|
||||
|
||||
public void addDescription(String description) {
|
||||
driver.findElement(By.id("description")).sendKeys(description);
|
||||
}
|
||||
|
||||
public void addLink(String link) {
|
||||
driver.findElement(By.id("repository")).sendKeys(link);
|
||||
}
|
||||
|
||||
private List<WebElement> getDeadlineList() {
|
||||
return driver.findElements(By.className("deadline"));
|
||||
}
|
||||
|
||||
public Integer getDeadlineCount() {
|
||||
return driver.findElements(By.className("deadline")).size();
|
||||
}
|
||||
|
||||
public void setExecutors() {
|
||||
driver.findElement(By.id("status")).click();
|
||||
getFirstExecutor();
|
||||
}
|
||||
|
||||
private void getFirstExecutor() {
|
||||
driver.findElement(By.xpath("//*[@id=\"status\"]/option[1]")).click();
|
||||
}
|
||||
|
||||
public void setDeadlineDescription(String description, Integer i) {
|
||||
driver.findElement(By.id(String.format("deadlines%d.description", i))).sendKeys(description);
|
||||
}
|
||||
|
||||
public void setDeadlineDate(String date, Integer i) {
|
||||
driver.findElement(By.id(String.format("deadlines%d.date", i))).sendKeys(date);
|
||||
}
|
||||
|
||||
public Boolean isTakePartButDisabledValueTrue() {
|
||||
return driver.findElement(By.id("take-part")).getAttribute("disabled").equals("true");
|
||||
}
|
||||
|
||||
public Integer getMemberCount() {
|
||||
return driver.findElements(By.className("member")).size();
|
||||
}
|
||||
|
||||
public void clickDeleteDeadline() {
|
||||
driver.findElement(By.className("btn-danger")).click();
|
||||
}
|
||||
|
||||
public void showAllowToAttachArticles() {
|
||||
driver.findElement(By.cssSelector("button[data-id=\"paperIds\"]")).click();
|
||||
}
|
||||
|
||||
public void clickAddPaperBut() {
|
||||
driver.findElement(By.id("add-paper")).click();
|
||||
}
|
||||
|
||||
|
||||
public List<WebElement> getArticles() {
|
||||
return driver.findElements(By.className("paper"));
|
||||
}
|
||||
|
||||
public Integer getArticlesCount() {
|
||||
return driver.findElements(By.className("paper")).size();
|
||||
}
|
||||
|
||||
public WebElement selectArticle() {
|
||||
WebElement webElement = driver.findElement(By.xpath("//*[@id=\"project-form\"]/div/div[2]/div[5]/div/div/div[2]/ul/li[1]/a"));
|
||||
webElement.click();
|
||||
return webElement;
|
||||
}
|
||||
|
||||
public void clickUndockArticleBut() {
|
||||
driver.findElement(By.name("removePaper")).click();
|
||||
}
|
||||
|
||||
public boolean checkDeadline(String description, String dateValue) {
|
||||
return getDeadlineList()
|
||||
.stream()
|
||||
.anyMatch(webElement -> {
|
||||
return webElement.findElement(By.className("deadline-text")).getAttribute("value").equals(description)
|
||||
&& webElement.findElement(By.cssSelector("input[type=\"date\"]")).getAttribute("value").equals(dateValue);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package project;
|
||||
|
||||
import core.PageObject;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectsPage extends PageObject {
|
||||
|
||||
public String getSubTitle() {
|
||||
return driver.findElement(By.tagName("h2")).getText();
|
||||
}
|
||||
|
||||
private List<WebElement> getProjectsList() {
|
||||
return driver.findElements(By.cssSelector("span.h6"));
|
||||
}
|
||||
|
||||
public void getFirstProject() {
|
||||
driver.findElement(By.xpath("//*[@id=\"projects\"]/div/div[2]/div[1]/div[1]/div/a")).click();
|
||||
}
|
||||
|
||||
public void selectMember() {
|
||||
driver.findElements(By.className("bootstrap-select")).get(0).findElement(By.className("btn")).click();
|
||||
driver.findElements(By.className("bootstrap-select")).get(0).findElements(By.className("dropdown-item")).get(1).click();
|
||||
}
|
||||
|
||||
public void deleteFirst() {
|
||||
js.executeScript("$('a[data-confirm]').click();");
|
||||
}
|
||||
|
||||
public void clickConfirm() {
|
||||
driver.findElement(By.id("dataConfirmOK")).click();
|
||||
}
|
||||
|
||||
public boolean checkNameInList(String newProjectName) {
|
||||
return getProjectsList()
|
||||
.stream()
|
||||
.anyMatch(webElement -> webElement.getText().equals(newProjectName));
|
||||
}
|
||||
}
|
@ -1,278 +0,0 @@
|
||||
package ru.ulstu.conference.service;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import ru.ulstu.conference.model.Conference;
|
||||
import ru.ulstu.conference.model.ConferenceDto;
|
||||
import ru.ulstu.conference.model.ConferenceFilterDto;
|
||||
import ru.ulstu.conference.model.ConferenceUser;
|
||||
import ru.ulstu.conference.repository.ConferenceRepository;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.deadline.service.DeadlineService;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.paper.service.PaperService;
|
||||
import ru.ulstu.ping.service.PingService;
|
||||
import ru.ulstu.timeline.service.EventService;
|
||||
import ru.ulstu.user.model.User;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
public class ConferenceServiceTest {
|
||||
|
||||
@Mock
|
||||
ConferenceRepository conferenceRepository;
|
||||
|
||||
@Mock
|
||||
DeadlineService deadlineService;
|
||||
|
||||
@Mock
|
||||
ConferenceUserService conferenceUserService;
|
||||
|
||||
@Mock
|
||||
PaperService paperService;
|
||||
|
||||
@Mock
|
||||
UserService userService;
|
||||
|
||||
@Mock
|
||||
EventService eventService;
|
||||
|
||||
@Mock
|
||||
ConferenceNotificationService conferenceNotificationService;
|
||||
|
||||
@Mock
|
||||
PingService pingService;
|
||||
|
||||
@InjectMocks
|
||||
ConferenceService conferenceService;
|
||||
|
||||
private final static Integer ID = 1;
|
||||
private final static Integer INDEX = 0;
|
||||
private final static String NAME = "Name";
|
||||
private final static String DESCRIPTION = "Desc";
|
||||
private final static boolean TRUE = true;
|
||||
private final static Integer YEAR = 2019;
|
||||
private final static Sort SORT = new Sort(Sort.Direction.DESC, "beginDate");
|
||||
|
||||
private List<Conference> conferences;
|
||||
private List<Deadline> deadlines;
|
||||
private List<Paper> papers;
|
||||
private List<ConferenceUser> conferenceUsers;
|
||||
|
||||
private Conference conferenceWithId;
|
||||
|
||||
private Paper paperWithId;
|
||||
private Paper paperWithoutId;
|
||||
|
||||
private ConferenceDto conferenceDto;
|
||||
private User user;
|
||||
private Deadline deadline;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
conferences = new ArrayList<>();
|
||||
conferenceWithId = new Conference();
|
||||
|
||||
conferenceWithId.setId(ID);
|
||||
conferenceWithId.setTitle(NAME);
|
||||
conferenceWithId.setDescription(DESCRIPTION);
|
||||
|
||||
paperWithId = new Paper();
|
||||
paperWithId.setId(1);
|
||||
paperWithId.setTitle(NAME);
|
||||
|
||||
paperWithoutId = new Paper();
|
||||
paperWithoutId.setTitle(NAME);
|
||||
|
||||
papers = new ArrayList<>();
|
||||
papers.add(paperWithId);
|
||||
papers.add(paperWithoutId);
|
||||
|
||||
deadlines = new ArrayList<>();
|
||||
deadline = new Deadline(new Date(), DESCRIPTION);
|
||||
deadline.setId(ID);
|
||||
deadlines.add(deadline);
|
||||
|
||||
ConferenceUser conferenceUser = new ConferenceUser();
|
||||
conferenceUser.setDeposit(ConferenceUser.Deposit.ARTICLE);
|
||||
conferenceUser.setParticipation(ConferenceUser.Participation.INTRAMURAL);
|
||||
user = new User();
|
||||
user.setFirstName(NAME);
|
||||
conferenceUser.setUser(user);
|
||||
|
||||
conferenceUsers = new ArrayList<>();
|
||||
conferenceUsers.add(conferenceUser);
|
||||
|
||||
conferences.add(conferenceWithId);
|
||||
conferenceDto = new ConferenceDto(conferenceWithId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getExistConferenceById() {
|
||||
when(conferenceRepository.getOne(ID)).thenReturn(conferenceWithId);
|
||||
when(paperService.findAllNotSelect(new ArrayList<>())).thenReturn(papers);
|
||||
when(userService.getCurrentUser()).thenReturn(user);
|
||||
|
||||
ConferenceDto newConferenceDto = new ConferenceDto(conferenceWithId);
|
||||
newConferenceDto.setNotSelectedPapers(papers);
|
||||
newConferenceDto.setDisabledTakePart(!TRUE);
|
||||
ConferenceDto result = conferenceService.getExistConferenceById(ID);
|
||||
|
||||
assertEquals(newConferenceDto.getId(), result.getId());
|
||||
assertEquals(newConferenceDto.getNotSelectedPapers(), result.getNotSelectedPapers());
|
||||
assertEquals(newConferenceDto.isDisabledTakePart(), result.isDisabledTakePart());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNewConference() {
|
||||
when(paperService.findAllNotSelect(new ArrayList<>())).thenReturn(papers);
|
||||
|
||||
ConferenceDto newConferenceDto = new ConferenceDto();
|
||||
newConferenceDto.setNotSelectedPapers(papers);
|
||||
ConferenceDto result = conferenceService.getNewConference();
|
||||
|
||||
assertEquals(newConferenceDto.getId(), result.getId());
|
||||
assertEquals(newConferenceDto.getNotSelectedPapers(), result.getNotSelectedPapers());
|
||||
assertEquals(newConferenceDto.isDisabledTakePart(), result.isDisabledTakePart());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAll() {
|
||||
when(conferenceRepository.findAll(SORT)).thenReturn(conferences);
|
||||
|
||||
assertEquals(Collections.singletonList(conferenceWithId), conferenceService.findAll());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void create() throws IOException {
|
||||
when(paperService.findPaperById(ID)).thenReturn(paperWithId);
|
||||
when(paperService.create(new Paper())).thenReturn(paperWithoutId);
|
||||
when(deadlineService.saveOrCreate(new ArrayList<>())).thenReturn(deadlines);
|
||||
when(conferenceUserService.saveOrCreate(new ArrayList<>())).thenReturn(conferenceUsers);
|
||||
when(conferenceRepository.save(new Conference())).thenReturn(conferenceWithId);
|
||||
|
||||
conferenceDto.setPapers(papers);
|
||||
conferenceDto.setDeadlines(deadlines);
|
||||
conferenceDto.setUsers(conferenceUsers);
|
||||
conferenceDto.getPaperIds().add(ID);
|
||||
|
||||
Conference newConference = new Conference();
|
||||
newConference.setId(ID);
|
||||
newConference.setTitle(NAME);
|
||||
newConference.setDescription(DESCRIPTION);
|
||||
newConference.setPapers(papers);
|
||||
newConference.getPapers().add(paperWithId);
|
||||
newConference.setDeadlines(deadlines);
|
||||
newConference.setUsers(conferenceUsers);
|
||||
|
||||
assertEquals(newConference, conferenceService.create(conferenceDto));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void delete() {
|
||||
when(conferenceRepository.existsById(ID)).thenReturn(true);
|
||||
when(conferenceRepository.getOne(ID)).thenReturn(conferenceWithId);
|
||||
assertTrue(conferenceService.delete(ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addDeadline() {
|
||||
ConferenceDto newConferenceDto = new ConferenceDto();
|
||||
newConferenceDto.getDeadlines().add(new Deadline());
|
||||
conferenceDto.getDeadlines().clear();
|
||||
|
||||
assertEquals(newConferenceDto.getDeadlines().get(0), conferenceService.addDeadline(conferenceDto).getDeadlines().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeDeadline() throws IOException {
|
||||
ConferenceDto newConferenceDto = new ConferenceDto();
|
||||
newConferenceDto.getRemovedDeadlineIds().add(ID);
|
||||
conferenceDto.getDeadlines().add(deadline);
|
||||
ConferenceDto result = conferenceService.removeDeadline(conferenceDto, INDEX);
|
||||
|
||||
assertEquals(newConferenceDto.getDeadlines(), result.getDeadlines());
|
||||
assertEquals(newConferenceDto.getRemovedDeadlineIds(), result.getRemovedDeadlineIds());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addPaper() {
|
||||
when(userService.getCurrentUser()).thenReturn(user);
|
||||
|
||||
ConferenceDto newConferenceDto = new ConferenceDto();
|
||||
newConferenceDto.getPapers().add(paperWithoutId);
|
||||
conferenceDto.getPapers().clear();
|
||||
ConferenceDto result = conferenceService.addPaper(conferenceDto);
|
||||
result.getPapers().get(INDEX).setTitle(NAME); // приходится вручную назначать название, т.е. название зависит от даты
|
||||
|
||||
assertEquals(newConferenceDto.getPapers(), result.getPapers());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removePaper() throws IOException {
|
||||
ConferenceDto newConferenceDto = new ConferenceDto();
|
||||
newConferenceDto.getNotSelectedPapers().add(paperWithId);
|
||||
newConferenceDto.getPapers().add(paperWithoutId);
|
||||
conferenceDto.getPapers().add(paperWithId);
|
||||
conferenceDto.getPapers().add(paperWithoutId);
|
||||
ConferenceDto result = conferenceService.removePaper(conferenceDto, INDEX);
|
||||
|
||||
assertEquals(newConferenceDto.getPapers(), result.getPapers());
|
||||
assertEquals(newConferenceDto.getNotSelectedPapers(), result.getNotSelectedPapers());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void takePart() throws IOException {
|
||||
when(userService.getCurrentUser()).thenReturn(user);
|
||||
|
||||
ConferenceDto newConferenceDto = new ConferenceDto();
|
||||
newConferenceDto.setUsers(conferenceUsers);
|
||||
newConferenceDto.setDisabledTakePart(TRUE);
|
||||
conferenceDto.getPapers().clear();
|
||||
ConferenceDto result = conferenceService.takePart(conferenceDto);
|
||||
|
||||
assertEquals(newConferenceDto.getUsers(), result.getUsers());
|
||||
assertEquals(newConferenceDto.isDisabledTakePart(), result.isDisabledTakePart());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllUsers() {
|
||||
List<User> users = Collections.singletonList(user);
|
||||
when(userService.findAll()).thenReturn(users);
|
||||
assertEquals(users, conferenceService.getAllUsers());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filter() {
|
||||
when(userService.findById(ID)).thenReturn(user);
|
||||
when(conferenceRepository.findByUserAndYear(user, YEAR)).thenReturn(conferences);
|
||||
|
||||
ConferenceFilterDto conferenceFilterDto = new ConferenceFilterDto();
|
||||
conferenceFilterDto.setFilterUserId(ID);
|
||||
conferenceFilterDto.setYear(YEAR);
|
||||
|
||||
assertEquals(Collections.singletonList(conferenceDto), conferenceService.filter(conferenceFilterDto));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAttachedToConference() {
|
||||
when(conferenceRepository.isPaperAttached(ID)).thenReturn(TRUE);
|
||||
|
||||
assertTrue(conferenceService.isAttachedToConference(ID));
|
||||
}
|
||||
}
|
@ -1,223 +0,0 @@
|
||||
package ru.ulstu.grant.service;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.deadline.service.DeadlineService;
|
||||
import ru.ulstu.grant.model.Grant;
|
||||
import ru.ulstu.grant.model.GrantDto;
|
||||
import ru.ulstu.grant.repository.GrantRepository;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.paper.model.PaperDto;
|
||||
import ru.ulstu.paper.service.PaperService;
|
||||
import ru.ulstu.timeline.service.EventService;
|
||||
import ru.ulstu.user.model.User;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
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 java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
public class GrantServiceTest {
|
||||
|
||||
@Mock
|
||||
GrantRepository grantRepository;
|
||||
|
||||
@Mock
|
||||
DeadlineService deadlineService;
|
||||
|
||||
@Mock
|
||||
PaperService paperService;
|
||||
|
||||
@Mock
|
||||
UserService userService;
|
||||
|
||||
@Mock
|
||||
EventService eventService;
|
||||
|
||||
@Mock
|
||||
GrantNotificationService grantNotificationService;
|
||||
|
||||
@InjectMocks
|
||||
GrantService grantService;
|
||||
|
||||
private final static Integer ID = 1;
|
||||
private final static Integer INDEX = 0;
|
||||
private final static String TITLE = "Title";
|
||||
private final static String COMMENT = "Comment";
|
||||
private final static boolean TRUE = true;
|
||||
private final static Integer YEAR = 2019;
|
||||
private final static Integer MAX_DISPLAY_SIZE = 50;
|
||||
|
||||
private List<Grant> grants;
|
||||
private List<Deadline> deadlines;
|
||||
private List<PaperDto> paperDtos;
|
||||
private GrantDto grantDto;
|
||||
private Deadline deadline;
|
||||
private User leader;
|
||||
|
||||
private Grant grantWithId;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
grants = new ArrayList<>();
|
||||
paperDtos = new ArrayList<>();
|
||||
grantWithId = new Grant();
|
||||
|
||||
deadlines = new ArrayList<>();
|
||||
deadline = new Deadline(new Date(), COMMENT);
|
||||
deadline.setId(ID);
|
||||
deadlines.add(deadline);
|
||||
|
||||
leader = Mockito.mock(User.class);
|
||||
|
||||
List<Paper> papers = new ArrayList<>();
|
||||
Paper paperWithId = new Paper();
|
||||
paperWithId.setId(ID);
|
||||
paperWithId.setTitle(TITLE);
|
||||
papers.add(paperWithId);
|
||||
PaperDto paperDto = new PaperDto(paperWithId);
|
||||
paperDtos.add(paperDto);
|
||||
|
||||
Set<User> authors = new HashSet<>();
|
||||
User author = leader;
|
||||
authors.add(author);
|
||||
|
||||
grantWithId.setId(ID);
|
||||
grantWithId.setTitle(TITLE);
|
||||
grantWithId.setComment(COMMENT);
|
||||
grantWithId.setDeadlines(deadlines);
|
||||
grantWithId.setLeader(leader);
|
||||
grantWithId.setPapers(papers);
|
||||
grantWithId.setAuthors(authors);
|
||||
|
||||
grants.add(grantWithId);
|
||||
grantDto = new GrantDto(grantWithId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getExistGrantById() {
|
||||
when(grantRepository.getOne(ID)).thenReturn(grantWithId);
|
||||
|
||||
GrantDto newGrantDto = new GrantDto(grantWithId);
|
||||
GrantDto result = grantService.getExistGrantById(ID);
|
||||
|
||||
assertEquals(newGrantDto.getId(), result.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAll() {
|
||||
when(grantRepository.findAll()).thenReturn(grants);
|
||||
|
||||
assertEquals(Collections.singletonList(grantWithId), grantService.findAll());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void create() throws IOException {
|
||||
when(deadlineService.saveOrCreate(new ArrayList<>())).thenReturn(deadlines);
|
||||
when(userService.getUserByLogin("admin")).thenReturn(leader);
|
||||
when(grantRepository.save(new Grant())).thenReturn(grantWithId);
|
||||
|
||||
Grant newGrant = new Grant();
|
||||
newGrant.setId(ID);
|
||||
newGrant.setTitle(TITLE);
|
||||
newGrant.setComment(COMMENT);
|
||||
newGrant.setDeadlines(deadlines);
|
||||
newGrant.setLeader(leader);
|
||||
|
||||
assertEquals(newGrant, grantService.create(grantDto));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getGrantStatuses() {
|
||||
assertEquals(Arrays.asList(Grant.GrantStatus.values()), grantService.getGrantStatuses());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getGrantPapers() {
|
||||
when(paperService.findAllSelect(Collections.singletonList(ID))).thenReturn(paperDtos);
|
||||
|
||||
assertEquals(paperDtos, grantService.getGrantPapers(Collections.singletonList(ID)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllUncompletedPapers() {
|
||||
when(paperService.findAllNotCompleted()).thenReturn(paperDtos);
|
||||
paperDtos.stream()
|
||||
.forEach(paperDto -> {
|
||||
paperDto.setTitle(StringUtils.abbreviate(paperDto.getTitle(), MAX_DISPLAY_SIZE));
|
||||
});
|
||||
|
||||
assertEquals(paperDtos, grantService.getAllUncompletedPapers());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void delete() throws IOException {
|
||||
when(grantRepository.getOne(ID)).thenReturn(grantWithId);
|
||||
assertTrue(grantService.delete(grantWithId.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeDeadline() {
|
||||
GrantDto newGrantDto = new GrantDto();
|
||||
newGrantDto.getRemovedDeadlineIds().add(ID);
|
||||
grantDto.getDeadlines().add(deadline);
|
||||
GrantDto result = grantService.removeDeadline(grantDto, INDEX);
|
||||
|
||||
assertEquals(newGrantDto.getRemovedDeadlineIds(), result.getRemovedDeadlineIds());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findById() {
|
||||
when(grantRepository.getOne(ID)).thenReturn(grantWithId);
|
||||
Grant findGrant = grantService.findById(ID);
|
||||
|
||||
assertEquals(grantWithId.getId(), findGrant.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void attachPaper() {
|
||||
when(grantRepository.getOne(ID)).thenReturn(grantWithId);
|
||||
when(paperService.findAllSelect(Collections.singletonList(ID))).thenReturn(paperDtos);
|
||||
GrantDto newGrantDto = new GrantDto(grantWithId);
|
||||
|
||||
if (!newGrantDto.getPaperIds().isEmpty()) {
|
||||
newGrantDto.getPapers().clear();
|
||||
newGrantDto.setPapers(paperDtos);
|
||||
} else {
|
||||
newGrantDto.getPapers().clear();
|
||||
}
|
||||
|
||||
assertEquals(newGrantDto.getPapers(), grantService.attachPaper(grantDto));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterEmptyDeadlines() {
|
||||
when(grantRepository.getOne(ID)).thenReturn(grantWithId);
|
||||
GrantDto newGrantDto = new GrantDto(grantWithId);
|
||||
|
||||
newGrantDto.setDeadlines(newGrantDto.getDeadlines().stream()
|
||||
.filter(dto -> dto.getDate() != null || !StringUtils.isEmpty(dto.getDescription()))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
assertEquals(newGrantDto.getDeadlines(), grantService.filterEmptyDeadlines(grantDto));
|
||||
}
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
package ru.ulstu.project.service;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.deadline.service.DeadlineService;
|
||||
import ru.ulstu.file.model.FileData;
|
||||
import ru.ulstu.file.service.FileService;
|
||||
import ru.ulstu.grant.model.GrantDto;
|
||||
import ru.ulstu.grant.service.GrantService;
|
||||
import ru.ulstu.project.model.Project;
|
||||
import ru.ulstu.project.model.ProjectDto;
|
||||
import ru.ulstu.project.repository.ProjectRepository;
|
||||
import ru.ulstu.timeline.service.EventService;
|
||||
import ru.ulstu.user.model.User;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
public class ProjectServiceTest {
|
||||
|
||||
@Mock
|
||||
ProjectRepository projectRepository;
|
||||
|
||||
@Mock
|
||||
DeadlineService deadlineService;
|
||||
|
||||
@Mock
|
||||
EventService eventService;
|
||||
|
||||
@Mock
|
||||
FileService fileService;
|
||||
|
||||
@Mock
|
||||
UserService userService;
|
||||
|
||||
@Mock
|
||||
GrantService grantService;
|
||||
|
||||
@InjectMocks
|
||||
ProjectService projectService;
|
||||
|
||||
private final static String TITLE = "title";
|
||||
private final static String DESCR = "descr";
|
||||
private final static Integer ID = 1;
|
||||
private final static Integer INDEX = 0;
|
||||
private final static String NAME = "name";
|
||||
|
||||
private List<Project> projects;
|
||||
private Project project;
|
||||
private ProjectDto projectDto;
|
||||
private Deadline deadline;
|
||||
private List<Deadline> deadlines;
|
||||
private FileData file;
|
||||
private List<FileData> files;
|
||||
private User user;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
projects = new ArrayList<>();
|
||||
project = new Project();
|
||||
|
||||
projects.add(project);
|
||||
projectDto = new ProjectDto(project);
|
||||
|
||||
deadlines = new ArrayList<>();
|
||||
deadline = new Deadline(new Date(), DESCR);
|
||||
deadline.setId(ID);
|
||||
deadlines.add(deadline);
|
||||
|
||||
user = new User();
|
||||
user.setFirstName(NAME);
|
||||
|
||||
List<GrantDto> grants = new ArrayList<>();
|
||||
GrantDto grant = new GrantDto();
|
||||
grant.setId(ID);
|
||||
grants.add(grant);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAll() {
|
||||
when(projectRepository.findAll()).thenReturn(projects);
|
||||
assertEquals(projects, projectService.findAll());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void create() throws IOException {
|
||||
when(deadlineService.saveOrCreate(new ArrayList<>())).thenReturn(deadlines);
|
||||
when(projectRepository.save(new Project())).thenReturn(project);
|
||||
eventService.createFromObject(new Project(), Collections.emptyList(), false, "проекта");
|
||||
|
||||
projectDto.setTitle(TITLE);
|
||||
projectDto.setDeadlines(deadlines);
|
||||
|
||||
project.setId(ID);
|
||||
project.setTitle(TITLE);
|
||||
project.setDescription(DESCR);
|
||||
project.setDeadlines(deadlines);
|
||||
project.setFiles(files);
|
||||
|
||||
assertEquals(project.getId(), (projectService.create(projectDto)).getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void delete() throws IOException {
|
||||
when(projectRepository.existsById(ID)).thenReturn(true);
|
||||
when(projectRepository.getOne(ID)).thenReturn(project);
|
||||
|
||||
assertTrue(projectService.delete(ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getProjectExecutors() {
|
||||
List<User> executors = Collections.singletonList(user);
|
||||
when(userService.findAll()).thenReturn(executors);
|
||||
|
||||
assertEquals(executors, projectService.getProjectExecutors(projectDto));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findById() {
|
||||
when(projectRepository.getOne(ID)).thenReturn(project);
|
||||
assertEquals(project, projectService.findById(ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeDeadline() throws IOException {
|
||||
ProjectDto newProjectDto = new ProjectDto();
|
||||
newProjectDto.getRemovedDeadlineIds().add(INDEX);
|
||||
projectDto.getDeadlines().add(deadline);
|
||||
ProjectDto result = projectService.removeDeadline(projectDto, INDEX);
|
||||
|
||||
assertEquals(newProjectDto.getDeadlines(), result.getDeadlines());
|
||||
assertEquals(newProjectDto.getRemovedDeadlineIds(), result.getRemovedDeadlineIds());
|
||||
}
|
||||
}
|
@ -1,215 +0,0 @@
|
||||
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.springframework.data.domain.Sort;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
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(SpringRunner.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.createFromObject(new Task(), Collections.emptyList(), true, "задачи");
|
||||
|
||||
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.existsById(ID)).thenReturn(true);
|
||||
when(taskRepository.getOne(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));
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
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();
|
||||
}
|
||||
|
||||
private 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package students;
|
||||
|
||||
import core.PageObject;
|
||||
|
||||
public class TasksDashboardPage extends PageObject {
|
||||
@Override
|
||||
public String getSubTitle() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
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"));
|
||||
}
|
||||
|
||||
private 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
Block a user