#103 add sort and filter test, fixed delete conference, if it has fk with event

This commit is contained in:
Nightblade73 2019-05-10 21:15:49 +04:00
parent 4e4e7ae194
commit 6edcf8f594
5 changed files with 71 additions and 17 deletions

View File

@ -127,6 +127,7 @@ public class ConferenceService {
@Transactional
public void delete(Integer conferenceId) {
if (conferenceRepository.exists(conferenceId)) {
eventService.removeConferencesEvent(conferenceRepository.findOne(conferenceId));
conferenceRepository.delete(conferenceId);
}
}

View File

@ -203,4 +203,9 @@ public class EventService {
eventRepository.delete(eventRepository.findAllByGrant(grant));
createFromGrant(grant);
}
public void removeConferencesEvent(Conference conference) {
List<Event> eventList = eventRepository.findAllByConference(conference);
eventList.forEach(event -> eventRepository.delete(event.getId()));
}
}

View File

@ -159,22 +159,22 @@ public class IndexConferenceTest extends TestTemplate {
conferencesPage.getConferenceFirst();
String conferenceId = conferencePage.getId();
Integer paperCount = conferencePage.getPaperCount();
Integer paperCount = conferencePage.getArticlesCount();
conferencePage.showAllowToAttachArticles();
WebElement paper = conferencePage.selectPaper();
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.getPaperCount()
&& conferencePage.getPapers()
Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount()
&& conferencePage.getArticles()
.stream()
.anyMatch(webElement -> webElement
.findElement(By.className("paper-name"))
.findElements(By.tagName("span"))
.get(1).getText().equals(paperName)));
.findElements(By.tagName("input"))
.get(1).getAttribute("value")
.equals(paperName)));
}
@Test
@ -187,17 +187,17 @@ public class IndexConferenceTest extends TestTemplate {
conferencesPage.getConferenceFirst();
String conferenceId = conferencePage.getId();
Integer paperCount = conferencePage.getPaperCount();
Integer paperCount = conferencePage.getArticlesCount();
conferencePage.clickAddPaperBut();
List<WebElement> webElements = conferencePage.getPapers();
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.getPaperCount()
&& conferencePage.getPapers()
Assert.assertTrue(paperCount + 1 == conferencePage.getArticlesCount()
&& conferencePage.getArticles()
.stream()
.anyMatch(webElement -> webElement
.findElements(By.tagName("input"))
@ -215,11 +215,44 @@ public class IndexConferenceTest extends TestTemplate {
conferencesPage.getConferenceFirst();
WebElement paper = conferencePage.getPapers().get(0);
WebElement paper = conferencePage.getArticles().get(0);
String paperName = paper.findElements(By.tagName("input")).get(1).getAttribute("value");
paper.findElement(By.tagName("a")).click();
Assertions.assertThat(conferencePage.getName())
.isEqualTo(paperName);
}
@Test
public void testUndockArticle() {
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.getConferenceFirst();
String conferenceId = conferencePage.getId();
Integer paperCount = conferencePage.getArticlesCount();
conferencePage.clickUndockArticleBut();
conferencePage.clickSaveBut();
getContext().goTo(applicationProperties.getBaseUrl() + String.format("/conferences/conference?id=%s", conferenceId));
Assert.assertTrue(paperCount - 1 == conferencePage.getArticlesCount());
}
@Test
public void testSortAndFilterConferenceList() {
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());
}
}

View File

@ -72,21 +72,26 @@ public class ConferencePage extends PageObject {
driver.findElement(By.cssSelector("button[data-id=\"paperIds\"]")).click();
}
public List<WebElement> getPapers() {
public void clickAddPaperBut() {
driver.findElement(By.id("add-paper")).click();
}
public List<WebElement> getArticles() {
return driver.findElements(By.className("paper"));
}
public Integer getPaperCount() {
public Integer getArticlesCount() {
return driver.findElements(By.className("paper")).size();
}
public WebElement selectPaper() {
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 clickAddPaperBut() {
driver.findElement(By.id("add-paper")).click();
public void clickUndockArticleBut() {
driver.findElement(By.name("removePaper")).click();
}
}

View File

@ -19,4 +19,14 @@ public class ConferencesPage extends PageObject {
public void getConferenceFirst() {
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();
}
}