diff --git a/test/cucumber/Article.feature b/test/cucumber/Article.feature index fc8e6601..01606f0d 100644 --- a/test/cucumber/Article.feature +++ b/test/cucumber/Article.feature @@ -125,95 +125,83 @@ Feature: journal article Then I'm still on article page And the articles are not stored by the system -#if($report) - @ignore - Scenario: report existing article - Given the system has article entitled "A theory of software product line refinement" with file name "TCS-1401.pdf" - When the system reports the existing articles - Then the system report contains "A theory of software product line refinement" article +#if($Report) + Scenario: report existing article + Given the system has article entitled "A theory of software product line refinement" with file name "TCS-1401.pdf" + When the system reports the existing articles + Then the system report contains "A theory of software product line refinement" article #end - @ignore - Scenario: list existing articles in alphabetical order of title - Given the system has article entitled "A theory of software product line refinement" with file name "TCS-1401.pdf" - And the system has article entitled "Modularity analysis of use case implementations" with file name "MACI.pdf" - When the system orders the article list by "title" - Then the system article list content is not modified - - @ignore - Scenario: list existing articles ordered by publication date - Given the system has article entitled "A theory of software product line refinement" with file name "TCS-1401.pdf" dated on "22/10/2011" - And the system has article entitled "Modularity analysis of use case implementations" with file name "MACI.pdf" dated on "05/08/2010" - When the system orders the article list by "publication date" - Then the system article list content is not modified - - @ignore - Scenario: new invalid article (title field blank) - Given the all fields from article information are filled except the title field - When the system try to create the article - Then the article with blank title field is not stored by the system - - @ignore - Scenario: filter existing articles by author - Given the system has some articles authored by "Paulo Borba" - When the system filter the articles authored by author "Paulo Borba" - Then the system article list content is not modified - - @ignore - Scenario: remove multiple articles - Given the system has 3 articles entitled "A theory of product line 1", "A theory of product line 2" and "A theory of product line 3" - When I remove the articles "A theory of product line 1" and "A theory of product line 3" - Then the system remove the articles "A theory of product line 1" and "A theory of product line 3" - And the system contains only the "A theory of product line 2" article - -#if($report) - @ignore - Scenario: report existing article web - Given I am at the articles page - And the system has article entitled "A theory of software product line refinement" with file name "TCS-88.pdf" - When I select to view the report of articles - Then my resulting report of articles contains "A theory of software product line refinement" + Scenario: list existing articles in alphabetical order of title + Given the system has article entitled "A theory of software product line refinement" with file name "TCS-1401.pdf" + And the system has article entitled "Modularity analysis of use case implementations" with file name "MACI.pdf" + When the system orders the article list by title + Then the system article list content is not modified + + Scenario: list existing articles ordered by publication date + Given the system has article entitled "A theory of software product line refinement" with file name "TCS-1401.pdf" dated on "22 October 2011" + And the system has article entitled "Modularity analysis of use case implementations" with file name "MACI.pdf" dated on "05 August 2010" + When the system orders the article list by publication date + Then the system article list content is not modified + + Scenario: new invalid article (title field blank) + Given the system has no article without title and with filename "TCS-01.pdf" + When I create the article with filename "TCS-01.pdf" and with the title field blank + Then the article with blank title and with filename "TCS-01.pdf" field is not stored by the system + + Scenario: filter existing articles by author + Given the system has some articles authored by "Paulo Borba" + When the system filter the articles authored by author "Paulo Borba" + Then the system article list content is not modified + + Scenario: remove multiple articles + Given the system has 3 articles entitled "A theory of software product line refinement" with file name "TCS-01.pdf", "Algebraic reasoning for object-oriented programming" with file name "AROOP-02.pdf" and "Modularity analysis of use case implementations" with file name "MACI-03.pdf" + When I remove the articles "A theory of software product line refinement" and "Modularity analysis of use case implementations" + Then the system removes the articles "A theory of software product line refinement" and "Modularity analysis of use case implementations" + And the system contains the "Algebraic reasoning for object-oriented programming" article + +#if($Report) + Scenario: report existing article web + Given I am at the articles page + And the article "A theory of software product line refinement" is stored in the system with file name "TCS-88.pdf" + When I select to view the report of articles + Then my resulting report of articles contains "A theory of software product line refinement" #end - @ignore - Scenario: list existing articles in alphabetical order of title web - Given I am at the articles page - And the system has some articles stored - When I select to view the list of articles - And I select to order the list of articles by "title" - Then my article list shows the articles ordered by "title" - - @ignore - Scenario: list existing articles ordered by publication date - Given I am at the articles page - And the system has some articles stored - When I select to view the list of articles - And I select to order the list of articles by "publication date" - Then my article list shows the articles ordered by "publication date" - - @ignore - Scenario: new invalid article web (title field blank) - Given I am at the new article page - When I fill all article information except the title field - And I select to create the article - Then an error message is showed for the title field - - @ignore - Scenario: filter existing articles by author web - Given I am at the articles page - And the system has some articles authored by "Paulo Borba" - When I select to view the list of articles - And I select to filter the list of articles by author "Paulo Borba" - Then my article list shows only the articles authored by "Paulo Borba" - - @ignore - Scenario: remove multiple articles web - Given I am at the articles page - And the system has 3 articles entitled "A theory of product line 1", "A theory of product line 2" and "A theory of product line 3" - When I am at the articles view list - And I select the articles "A theory of product line 1" and "A theory of product line 3" - And I select to remove the selected articles - Then my article list page contains only the "A theory of product line 2" article - +Scenario: list existing articles in alphabetical order of title web + Given I am at the articles page + And the system has some articles created + When I select to view the list of articles + And I select to order the list of articles by "title" + Then my article list shows the articles ordered by "title" + + Scenario: list existing articles ordered by publication date web + Given I am at the articles page + And the system has some articles created + When I select to view the list of articles + And I select to order the list of articles by "publication date" + Then my article list shows the articles ordered by "publication date" + + Scenario: new invalid article web (title field blank) + Given I am at the new article page + When I fill all article information except the title field + And I select to create the article + Then an error message is showed for the title field + + Scenario: filter existing articles by author web + Given I am at the articles page + And I create some articles authored by "Paulo Borba" + When I select to view the list of articles + And I select to filter the list of articles by author "Paulo Borba" + Then my article list shows only the articles authored by "Paulo Borba" + + Scenario: remove multiple articles web + Given I am at the articles page + And I create 3 articles entitled "A theory of software product line refinement" with file name "TCS-01.pdf", "Modularity analysis of use case implementations" with file name "MACI-03.pdf" and "Algebraic reasoning for object-oriented programming" with file name "AROOP-02.pdf" + When I select to view the list of articles + And I mark multiple articles to be removed + And I select to remove the selected articles + Then my resulting articles list contains "Modularity analysis of use case implementations" + # Paulo Borba: voces podem criar cenários para ordenar a lista, filtrar a lista # Paulo Borba: verificar se alguns campos podem ser opcionais, etc. diff --git a/test/cucumber/steps/ArticleSteps.groovy b/test/cucumber/steps/ArticleSteps.groovy index 9030a33c..1ef4ff03 100644 --- a/test/cucumber/steps/ArticleSteps.groovy +++ b/test/cucumber/steps/ArticleSteps.groovy @@ -1,65 +1,59 @@ -//#if($Article) -import pages.ArticlePages.ArticleCreatePage -import pages.ArticlePages.ArticleEditPage -import pages.ArticlePages.ArticleShowPage -import pages.ArticlePages.ArticlesPage -import pages.LoginPage -import pages.PublicationsPage +import pages.ArticlePages.* +import pages.* import rgms.publication.Periodico import rgms.tool.TwitterTool -import steps.ArticleTestDataAndOperations import steps.TestDataAndOperationsFacebook +import steps.ArticleTestDataAndOperations import steps.TestDataAndOperationsPublication import static cucumber.api.groovy.EN.* Given(~'^the system has no article entitled "([^"]*)"$') { String title -> - assert periodicoNoExist(title) + assert periodicoNoExist(title) } When(~'^I create the article "([^"]*)" with file name "([^"]*)"$') { String title, filename -> - ArticleTestDataAndOperations.createArticle(title, filename) + ArticleTestDataAndOperations.createArticle(title, filename) } Then(~'^the article "([^"]*)" is properly stored by the system$') { String title -> - article = Periodico.findByTitle(title) - assert ArticleTestDataAndOperations.compatibleTo(article, title) + article = Periodico.findByTitle(title) + assert ArticleTestDataAndOperations.compatibleTo(article, title) } When(~'^I create the article "([^"]*)" with file name "([^"]*)" with the "([^"]*)" field blank$') { String title, String filename, String field -> - ArticleTestDataAndOperations.createArticle(title, filename) - def article = ArticleTestDataAndOperations.findArticleByTitle(title) - assert article.{ - field - } == null + ArticleTestDataAndOperations.createArticle(title, filename) + def article = ArticleTestDataAndOperations.findArticleByTitle(title) + assert article.{field} == null } Then(~'^the article "([^"]*)" is not stored by the system because it is invalid$') { String title -> - assert periodicoNoExist(title) + assert periodicoNoExist(title) } Then(~'^the article "([^"]*)" is not stored twice$') { String title -> - articles = Periodico.findAllByTitle(title) - assert articles.size() == 1 - // Should actually check whether elements in articles are not equal except for their filename, - // which is changed by the system during the file upload. + articles = Periodico.findAllByTitle(title) + assert articles.size() == 1 + // Should actually check whether elements in articles are not equal except for their filename, + // which is changed by the system during the file upload. } -When(~'^I select the new article option at the article page$') { -> - selectNewArticleInArticlesPage() +When(~'^I select the new article option at the article page$') {-> + selectNewArticleInArticlesPage() } -Then(~'^I can fill the article details$') { -> - at ArticleCreatePage - page.fillArticleDetails() +Then(~'^I can fill the article details$') {-> + at ArticleCreatePage + page.fillArticleDetails() } + /** * @author Guilherme */ Given(~'^the system has article entitled "([^"]*)" with file name "([^"]*)"$') { String title, String filename -> - ArticleTestDataAndOperations.createArticle(title, filename) - assert Periodico.findByTitle(title) != null + ArticleTestDataAndOperations.createArticle(title, filename) + assert Periodico.findByTitle(title) != null } /** @@ -68,50 +62,50 @@ Given(~'^the system has article entitled "([^"]*)" with file name "([^"]*)"$') { Given(~'^I am at the articles page and the article "([^"]*)" is stored in the system with file name "([^"]*)"$') { String title, filename -> - Login() - at PublicationsPage - page.select("Periodico") - selectNewArticleInArticlesPage() - page.fillArticleDetails(ArticleTestDataAndOperations.path() + filename, title) - page.selectCreateArticle() - assert !periodicoNoExist(title) - to ArticlesPage - at ArticlesPage + Login() + at PublicationsPage + page.select("Periodico") + selectNewArticleInArticlesPage() + page.fillArticleDetails(ArticleTestDataAndOperations.path() + filename, title) + page.selectCreateArticle() + assert !periodicoNoExist(title) + to ArticlesPage + at ArticlesPage } /** * @author Guilherme */ When(~'^I delete the article "([^"]*)"$') { String title -> - def testarticle = Periodico.findByTitle(title) - assert testarticle != null - ArticleTestDataAndOperations.removeArticle(title) - def testDeleteArticle = Periodico.findByTitle(title) - assert testDeleteArticle == null + def testarticle = Periodico.findByTitle(title) + assert testarticle != null + ArticleTestDataAndOperations.removeArticle(title) + def testDeleteArticle = Periodico.findByTitle(title) + assert testDeleteArticle == null } /** * @author Guilherme */ When(~'^I edit the article title from "([^"]*)" to "([^"]*)"$') { String oldtitle, newtitle -> - def updatedArticle = ArticleTestDataAndOperations.editArticle(oldtitle, newtitle) - assert updatedArticle != null + def updatedArticle = ArticleTestDataAndOperations.editArticle(oldtitle, newtitle) + assert updatedArticle != null } /** * @author Guilherme */ -When(~"^I view the article list\$") { -> - articles = Periodico.findAll() - assert articles != null +When(~"^I view the article list\$") {-> + articles = Periodico.findAll() + assert articles != null } /** * @author Guilherme */ When(~'^I select to view "([^"]*)" in resulting list$') { String title -> - page.selectViewArticle(title) - at ArticleShowPage + page.selectViewArticle(title) + at ArticleShowPage } /** @@ -120,48 +114,48 @@ When(~'^I select to view "([^"]*)" in resulting list$') { String title -> When(~'^I change the article title to "([^"]*)"$') { String newtitle -> - page.select('a', 'edit') - at ArticleEditPage - def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator - page.edit(newtitle, path + "TCS-99.pdf") + page.select('a', 'edit') + at ArticleEditPage + def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + page.edit(newtitle, path + "TCS-99.pdf") } /** * @author Guilherme */ Then(~'^the article "([^"]*)" is properly updated by the system$') { String title -> - assert periodicoNoExist(title) + assert periodicoNoExist(title) } /** * @author Guilherme */ Then(~'^the article "([^"]*)" is properly removed by the system$') { String title -> - assert periodicoNoExist(title) + assert periodicoNoExist(title) } /** * @author Guilherme */ Then(~'my article list contains "([^"]*)"$') { String title -> - articles = Periodico.findAll() - assert ArticleTestDataAndOperations.containsArticle(title, articles) + articles = Periodico.findAll() + assert ArticleTestDataAndOperations.containsArticle(title, articles) } /** * @author Guilherme */ Then(~'my resulting articles list contains "([^"]*)"$') { String title -> - at ArticlesPage - page.checkArticleAtList(title, 0) + at ArticlesPage + page.checkArticleAtList(title, 0) } /** * @author Guilherme */ -When(~'I select the option to remove in show page$') { -> - at ArticleShowPage - page.select('input', 'delete') +When(~'I select the option to remove in show page$') {-> + at ArticleShowPage + page.select('input', 'delete') } /** @@ -169,188 +163,391 @@ When(~'I select the option to remove in show page$') { -> */ When(~'I select the "([^"]*)" option in Article Show Page$') { String option -> - at ArticleEditPage - page.select(option) - //on ArticleEditPage + at ArticleEditPage + page.select(option) + //on ArticleEditPage } Then(~'^I am at Article show page$') { -> - at ArticleShowPage + at ArticleShowPage } + //#if( $Twitter ) Given(~'^I am logged as "([^"]*)"$') { String userName -> - to LoginPage - at LoginPage - page.fillLoginData(userName, "adminadmin") + to LoginPage + at LoginPage + page.fillLoginData(userName, "adminadmin") } -Given(~'^I am at the Article Page$') { -> +Given (~'^I am at the Article Page$'){-> - addPage() + addPage() } When(~'^I try to create an article named as "([^"]*)" with filename "([^"]*)"$') { String articleName, String filename -> - selectNewArticleInArticlesPage() - page.fillArticleDetails(ArticleTestDataAndOperations.path() + filename, articleName) - page.selectCreateArticle() + selectNewArticleInArticlesPage() + page.fillArticleDetails(ArticleTestDataAndOperations.path() + filename, articleName) + page.selectCreateArticle() } When(~'^I click on Share it in Twitter with "([^"]*)" and "([^"]*)"$') { String twitterLogin, String twitterPw -> - at ArticleShowPage - page.clickOnTwitteIt(twitterLogin, twitterPw) - at ArticleShowPage + at ArticleShowPage + page.clickOnTwitteIt(twitterLogin, twitterPw) + at ArticleShowPage } Then(~'^A tweet is added to my twitter account regarding the new article "([^"]*)"$') { String articleTitle -> - assert TwitterTool.consult(articleTitle) + assert TwitterTool.consult(articleTitle) } -Then(~'No tweet should be post about "([^"]*)"$') { String article -> - assert !TwitterTool.consult(null) +Then (~'No tweet should be post about "([^"]*)"$'){ String article -> + assert !TwitterTool.consult(null) } Then(~'^No twitte should be post about "([^"]*)"$') { String articleTitle -> - assert !TwitterTool.consult(articleTitle) + assert !TwitterTool.consult(articleTitle) } - //#end //#if( $Facebook ) When(~'^I click on Share on Facebook$') { -> - at ArticleShowPage - page.clickOnShareOnFacebook() - at ArticleShowPage + at ArticleShowPage + page.clickOnShareOnFacebook() + at ArticleShowPage } Then(~'^A facebook message was posted$') { -> - //TODO - assert true + //TODO + assert true } Then(~'^No facebook message was posted$') { -> - //TODO - assert true + //TODO + assert true } -Given(~'^I am at the Add Article Page$') { -> - at PublicationsPage - page.select("Periodico") - to ArticlesPage - def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "TCS.pdf" - println path - def f = new File(path) - println "exist Path?" + f.exists() +Given(~'^I am at the Add Article Page$') { -> + at PublicationsPage + page.select("Periodico") + to ArticlesPage + def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "TCS.pdf" + println path + def f = new File(path) + println "exist Path?" + f.exists() } When(~'^I share the article entitled "([^"]*)" on facebook$') { String title -> - TestDataAndOperationsFacebook.ShareArticleOnFacebook(title) + TestDataAndOperationsFacebook.ShareArticleOnFacebook(title) } - //#end -def selectNewArticleInArticlesPage() { +def selectNewArticleInArticlesPage(){ - at ArticlesPage - page.selectNewArticle() - at ArticleCreatePage + at ArticlesPage + page.selectNewArticle() + at ArticleCreatePage } -def periodicoNoExist(String title) { - return Periodico.findByTitle(title) == null +def periodicoNoExist(String title){ + return Periodico.findByTitle(title) == null } -def Login() { - - to LoginPage - at LoginPage - - page.fillLoginData("admin", "adminadmin") - - +def Login(){ + to LoginPage + at LoginPage + page.fillLoginData("admin", "adminadmin") } /** * @author carloscemb */ -Then(~'^I see my user listed as an author member of article by default$') { -> - at ArticleCreatePage - assert TestDataAndOperationsPublication.containsUser(page.selectedMembers()) +Then(~'^I see my user listed as an author member of article by default$') {-> + at ArticleCreatePage + assert TestDataAndOperationsPublication.containsUser(page.selectedMembers()) } When(~'^I upload the articles of "([^"]*)"$') { String arg1 -> - String path = "test" + File.separator + "functional" + File.separator + "steps" + File.separator + arg1 - initialSize = Periodico.findAll().size() - ArticleTestDataAndOperations.uploadArticle(path) - finalSize = Periodico.findAll().size() - assert initialSize < finalSize -} -Then(~'^the system has all the articles of the xml file$') { -> - assert Periodico.findByTitle("A System For Translating Executable VDM Specifications Into Lazy ML") != null - assert Periodico.findByTitle("From VDM Specifications To Functional Prototypes") != null - assert Periodico.findByTitle("Basic laws of ROOL: an object-oriented language") != null - assert Periodico.findByTitle("Implementing distribution and persistence aspects with AspectJ") != null - assert Periodico.findByTitle("Developing adaptive J2ME applications using AspectJ") != null - assert Periodico.findByTitle("Algebraic reasoning for object-oriented programming") != null - assert Periodico.findByTitle("Refactoring Alloy Specifications") != null - assert Periodico.findByTitle("Systematic development of concurrent object-oriented programs") != null - assert Periodico.findByTitle("Portando Jogos em J2ME: Desafios, Estudo de Caso, e Diretrizes") != null - assert Periodico.findByTitle("AspectH: Uma Extensão Orientada a Aspectos de Haskell") != null - assert Periodico.findByTitle("An Abstract Equivalence Notion for Object Models") != null - assert Periodico.findByTitle("Distribution and Persistence as Aspects") != null - assert Periodico.findByTitle("A Static Semantics for Alloy and its Impact in Refactorings") != null - assert Periodico.findByTitle("Extracting and Evolving Code in Product Lines with Aspect-Oriented Programming") != null - assert Periodico.findByTitle("A Framework for Establishing Formal Conformance between Object Models and Object-Oriented Programs") != null - assert Periodico.findByTitle("Refactorings for introducing Alloy idioms (aceito para publicação)") != null - assert Periodico.findByTitle("Algebraic Laws for Feature Models") != null - assert Periodico.findByTitle("Estimating manual test execution effort and capacity based on execution points") != null - assert Periodico.findByTitle("Automatically Checking Feature Model Refactorings") != null - assert Periodico.findByTitle("An Approach to Invariant-based Program Refactoring") != null - assert Periodico.findByTitle("Modularity analysis of use case implementations") != null - assert Periodico.findByTitle("A Theory of Software Product Line Refinement") != null - assert Periodico.findByTitle("The Crosscutting Impact of the AOSD Brazilian Research Community (accepted)") != null -} -And(~'^I select the upload button at the article page$') { -> - at ArticlesPage - page.uploadWithoutFile() -} -Then(~'^I\'m still on article page$') { -> - at ArticlesPage -} -And(~'^the articles are not stored by the system$') { -> - at ArticlesPage - page.checkIfArticlesListIsEmpty() -} -Given(~'^the system has some articles stored$') { -> - initialSize = Periodico.findAll().size() + String path = "test" + File.separator + "functional" + File.separator + "steps" + File.separator + arg1 + initialSize = Periodico.findAll().size() + ArticleTestDataAndOperations.uploadArticle(path) + finalSize = Periodico.findAll().size() + assert initialSize < finalSize +} +Then(~'^the system has all the articles of the xml file$') {-> + assert Periodico.findByTitle("A System For Translating Executable VDM Specifications Into Lazy ML") != null + assert Periodico.findByTitle("From VDM Specifications To Functional Prototypes") != null + assert Periodico.findByTitle("Basic laws of ROOL: an object-oriented language") != null + assert Periodico.findByTitle("Implementing distribution and persistence aspects with AspectJ") != null + assert Periodico.findByTitle("Developing adaptive J2ME applications using AspectJ") != null + assert Periodico.findByTitle("Algebraic reasoning for object-oriented programming") != null + assert Periodico.findByTitle("Refactoring Alloy Specifications") != null + assert Periodico.findByTitle("Systematic development of concurrent object-oriented programs") != null + assert Periodico.findByTitle("Portando Jogos em J2ME: Desafios, Estudo de Caso, e Diretrizes") != null + assert Periodico.findByTitle("AspectH: Uma Extensão Orientada a Aspectos de Haskell") != null + assert Periodico.findByTitle("An Abstract Equivalence Notion for Object Models") != null + assert Periodico.findByTitle("Distribution and Persistence as Aspects") != null + assert Periodico.findByTitle("A Static Semantics for Alloy and its Impact in Refactorings") != null + assert Periodico.findByTitle("Extracting and Evolving Code in Product Lines with Aspect-Oriented Programming") != null + assert Periodico.findByTitle("A Framework for Establishing Formal Conformance between Object Models and Object-Oriented Programs") != null + assert Periodico.findByTitle("Refactorings for introducing Alloy idioms (aceito para publicação)") != null + assert Periodico.findByTitle("Algebraic Laws for Feature Models") != null + assert Periodico.findByTitle("Estimating manual test execution effort and capacity based on execution points") != null + assert Periodico.findByTitle("Automatically Checking Feature Model Refactorings") != null + assert Periodico.findByTitle("An Approach to Invariant-based Program Refactoring") != null + assert Periodico.findByTitle("Modularity analysis of use case implementations") != null + assert Periodico.findByTitle("A Theory of Software Product Line Refinement") != null + assert Periodico.findByTitle("The Crosscutting Impact of the AOSD Brazilian Research Community (accepted)") != null +} +And(~'^I select the upload button at the article page$') {-> + at ArticlesPage + page.uploadWithoutFile() +} +Then(~'^I\'m still on article page$') {-> + at ArticlesPage +} +And(~'^the articles are not stored by the system$') {-> + at ArticlesPage + page.checkIfArticlesListIsEmpty() +} +Given(~'^the system has some articles stored$') {-> + initialSize = Periodico.findAll().size() +} + + +Given(~'^I am at the articles page$'){-> + Login() + at PublicationsPage + page.select("Periodico") + at ArticlesPage +} + +And(~'^the article "([^"]*)" is stored in the system with file name "([^"]*)"$') { String title, filename -> + at ArticlesPage + page.selectNewArticle() + at ArticleCreatePage + page.fillArticleDetails(ArticleTestDataAndOperations.path() + filename, title) + page.selectCreateArticle() + assert !periodicoNoExist(title) } //#if($Report) -When(~"^I view the report of articles\$") { -> - articles = Periodico.findAll() - assert articles != null +When(~'^the system reports the existing articles$') {-> + articles = ArticleTestDataAndOperations.reportArticles() + assert articles != null } -Then(~'the report of articles contains "([^"]*)"$') { String title -> - articles = Periodico.findAll() - assert ArticleTestDataAndOperations.containsArticle(title, articles) +Then(~'^the system report contains "([^"]*)" article$') { String title -> + articles = ArticleTestDataAndOperations.reportArticles() + assert ArticleTestDataAndOperations.containsArticle(title, articles) +} + +When(~'^I select to view the report of articles$') {-> + to ArticlesPage + at ArticlesPage + page.selectViewReports() +} + +Then(~'^my resulting report of articles contains "([^"]*)"$') { String title -> + at ArticlesReportPage + page.checkArticleAtReport(title,0) } //#end +Given(~'^the system has article entitled "([^"]*)" with file name "([^"]*)" dated on "([^"]*)"$'){String title, filename, date-> + ArticleTestDataAndOperations.createArticle(title, filename, date, null) + assert Periodico.findByTitle(title) != null +} + +When(~'^the system orders the article list by title$') {-> + articlesSorted = Periodico.listOrderByTitle(order: "asc") + assert ArticleTestDataAndOperations.isSorted(articlesSorted, "title") + +} + +When(~'^the system orders the article list by publication date$') {-> + articlesSorted = Periodico.listOrderByPublicationDate(order: "asc") + assert ArticleTestDataAndOperations.isSorted(articlesSorted, "publication date") +} + +Then(~'^the system article list content is not modified$') {-> + assert Periodico.findAll().size() == 2 + assert !periodicoNoExist('Modularity analysis of use case implementations') + assert !periodicoNoExist('A theory of software product line refinement') +} + +Given(~'^the system has some articles created$'){-> + at ArticlesPage + page.selectNewArticle() + at ArticleCreatePage + page.fillArticleDetails(ArticleTestDataAndOperations.path() + 'MACI.pdf', 'Modularity analysis of use case implementations',"17","10","2013") + page.selectCreateArticle() + assert !periodicoNoExist('Modularity analysis of use case implementations') + to ArticlesPage + page.selectNewArticle() + at ArticleCreatePage + page.fillArticleDetails(ArticleTestDataAndOperations.path() + 'TCS-1401.pdf', 'A theory of software product line refinement',"12","11","2012") + page.selectCreateArticle() + assert !periodicoNoExist('A theory of software product line refinement') + to ArticlesPage +} + +When(~'^I select to view the list of articles$') {-> + at ArticlesPage + page.selectViewArticleList() +} + +And(~'^I select to order the list of articles by "([^"]*)"$') {String sortType-> + at ArticlesPage + page.selectOrderBy(sortType) +} + +Then(~'^my article list shows the articles ordered by "([^"]*)"$') {String sortType-> + at ArticlesPage + page.checkOrderedBy(sortType); +} + +Given(~'^the system has some articles authored by "([^"]*)"$'){String authorName-> + ArticleTestDataAndOperations.createArticle('A theory of software product line refinement', 'TCSOS.pdf', null, 'Paulo Borba') + ArticleTestDataAndOperations.createArticle('Modularity analysis of use case implementations', 'MACI.pdf') + assert (!periodicoNoExist('A theory of software product line refinement') && !periodicoNoExist('Modularity analysis of use case implementations')) +} + +When(~'^the system filter the articles authored by author "([^"]*)"$') {String authorName-> + articlesFiltered = ArticleTestDataAndOperations.findAllByAuthor(authorName) + assert ArticleTestDataAndOperations.isFiltered(articlesFiltered,authorName) +} + +And(~'^I create some articles authored by "([^"]*)"$') {String authorName-> + at ArticlesPage + page.selectNewArticle() + at ArticleCreatePage + page.fillArticleDetails(ArticleTestDataAndOperations.path() + 'MACI.pdf', 'Modularity analysis of use case implementations', authorName) + page.selectCreateArticle() + assert !periodicoNoExist('Modularity analysis of use case implementations') + to ArticlesPage + page.selectNewArticle() + at ArticleCreatePage + page.fillArticleDetails(ArticleTestDataAndOperations.path() + 'TCS-1401.pdf', 'A theory of software product line refinement') + page.selectCreateArticle() + assert !periodicoNoExist('A theory of software product line refinement') + to ArticlesPage +} + +And(~'^I select to filter the list of articles by author "([^"]*)"$') {String authorName-> + at ArticlesPage + page.fillAndSelectFilter(authorName) +} + +Then(~'^my article list shows only the articles authored by "([^"]*)"$') {String authorName-> + at ArticlesPage + assert page.checkFilteredBy(authorName); +} + //Funcoes Auxiliares -def addPage() { - Login() - at PublicationsPage - page.select("Periodico") - to ArticlesPage - def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "TCS.pdf" - println path - def f = new File(path) - println "exist Path?" + f.exists() -} -//#end \ No newline at end of file +def addPage(){ + Login() + at PublicationsPage + page.select("Periodico") + to ArticlesPage + def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "TCS.pdf" + println path + def f = new File(path) + println "exist Path?" + f.exists() +} + + +def addNewArticleWeb(title, filename){ + selectNewArticleInArticlesPage() + page.fillArticleDetails(ArticleTestDataAndOperations.path() + filename, title) + page.selectCreateArticle() + assert !periodicoNoExist(title) + to ArticlesPage + at ArticlesPage +} + +Given(~'^the system has 3 articles entitled "([^"]*)" with file name "([^"]*)", "([^"]*)" with file name "([^"]*)" and "([^"]*)" with file name "([^"]*)"$') {String title1, filename1, title2, filename2, title3, filename3 -> + ArticleTestDataAndOperations.createArticle(title1, filename1,null,null) + ArticleTestDataAndOperations.createArticle(title2, filename2,null,null) + ArticleTestDataAndOperations.createArticle(title3, filename3,null,null) + assert Periodico.findByTitle(title1) != null + assert Periodico.findByTitle(title2) != null + assert Periodico.findByTitle(title3) != null +} + +When(~'^I remove the articles "([^"]*)" and "([^"]*)"$') { String title1, title2 -> + + ArticleTestDataAndOperations.removeMultiplesArticles(title1, title2) + + def testDeleteArticle1 = Periodico.findByTitle(title1) + def testDeleteArticle2 = Periodico.findByTitle(title2) + assert testDeleteArticle1 == null + assert testDeleteArticle2 == null +} + +Then(~'^the system removes the articles "([^"]*)" and "([^"]*)"$') { String title1, title2 -> + assert periodicoNoExist(title1) + assert periodicoNoExist(title2) +} + +And(~'^the system contains the "([^"]*)" article$') { String title1 -> + assert Periodico.findByTitle(title1) != null +} + +And(~'^I create 3 articles entitled "([^"]*)" with file name "([^"]*)", "([^"]*)" with file name "([^"]*)" and "([^"]*)" with file name "([^"]*)"$') { String title1, filename1, title2, filename2, title3, filename3 -> + addNewArticleWeb(title1, filename1) + addNewArticleWeb(title2, filename2) + addNewArticleWeb(title3, filename3) +} + +And(~'I select to remove the selected articles$') {-> + at ArticlesPage + page.selectRemoveMultipleArticles() +} + +Given(~'^I am at the new article page$'){-> + Login() + at PublicationsPage + page.select("Periodico") + selectNewArticleInArticlesPage() +} + +When(~'^I fill all article information except the title field$') {-> + at ArticleCreatePage + page.fillArticleDetailsExceptTitle() +} + +And(~'^I select to create the article$') {-> + at ArticleCreatePage + page.selectCreateArticle() +} + +When(~'^I create the article with filename "([^"]*)" and with the title field blank$') {String filename -> + ArticleTestDataAndOperations.createArticleWithoutTitle(filename) + def article = ArticleTestDataAndOperations.findArticleByFilename(filename) + assert article.{title} == null +} + +Given(~'^the system has no article without title and with filename "([^"]*)"$') {String filename -> + def article = Periodico.findByFile(filename) + assert article == null +} + +Then(~'^the article with blank title and with filename "([^"]*)" field is not stored by the system$') {String filename -> + def article = Periodico.findByFile(filename) + assert article == null +} + +Then(~'^an error message is showed for the title field$') { -> + assert (page.readFlashMessage() != null) +} + +And(~'^I mark multiple articles to be removed$') {-> + at ArticlesPage + page.markArticles() +} diff --git a/test/functional/pages/ArticlePages/ArticleCreatePage.groovy b/test/functional/pages/ArticlePages/ArticleCreatePage.groovy index 15598839..f6e459c8 100644 --- a/test/functional/pages/ArticlePages/ArticleCreatePage.groovy +++ b/test/functional/pages/ArticlePages/ArticleCreatePage.groovy @@ -1,40 +1,69 @@ -//#if($Article) package pages.ArticlePages import pages.FormPage import pages.GetPageTitle class ArticleCreatePage extends FormPage { - static url = "periodico/create" - - static at = { - //title ==~ /Criar Peri�dico/ - GetPageTitle gp = new GetPageTitle() - def currentPeriodico = gp.msg("default.periodico.label") - def currentTitle = gp.msg("default.create.label", [currentPeriodico]) - title ==~ currentTitle - journal != null - } - - static content = { journal { $("input", id: "journal") } } - - def fillArticleDetails() { - def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "TCS.pdf" - fillArticleDetails(path, "A theory of software product line refinement") - } - - def fillArticleDetails(filename, title) { - $("form").title = title - $("form").journal = "Theoretical Computer Science" - $("form").file = filename - $("form").volume = 455 - $("form").number = 1 - $("form").pages = "2-30" - // Could parametrize, obtaining data from class TestDataAndOperations - } - - def selectCreateArticle() { - $("input", name: "create").click() - } + static url = "periodico/create" + + static at = { + //title ==~ /Criar Periódico/ + GetPageTitle gp = new GetPageTitle() + def currentPeriodico = gp.msg("default.periodico.label") + def currentTitle = gp.msg("default.create.label", [currentPeriodico]) + title ==~ currentTitle + journal != null + } + + static content = { journal { $("input", id: "journal") } } + + def fillArticleDetails() { + def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "TCS.pdf" + fillArticleDetails(path, "A theory of software product line refinement") + } + + def fillArticleDetails(filename, title) { + $("form").title = title + $("form").journal = "Theoretical Computer Science" + $("form").file = filename + $("form").volume = 455 + $("form").number = 1 + $("form").pages = "2-30" + // Could parametrize, obtaining data from class TestDataAndOperations + } + + def fillArticleDetails(filename, title, day, month, year) { + $("form").title = title + $("form").publicationDate_day = day + $("form").publicationDate_month = month + $("form").publicationDate_year = year + $("form").journal = "Theoretical Computer Science" + $("form").file = filename + $("form").volume = 455 + $("form").number = 1 + $("form").pages = "2-30" + + } + + def fillArticleDetails(filename, title, authorName) { + $("form").title = title + $("form").journal = "Theoretical Computer Science" + $("form").authors = authorName + $("form").file = filename + $("form").volume = 455 + $("form").number = 1 + $("form").pages = "2-30" + } + + def fillArticleDetailsExceptTitle() { + $("form").journal = "Theoretical Computer Science" + $("form").file = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "TCS.pdf" + $("form").volume = 455 + $("form").number = 1 + $("form").pages = "2-30" + } + + def selectCreateArticle() { + $("input", name: "create").click() + } } -//#end diff --git a/test/functional/pages/ArticlePages/ArticlesPage.groovy b/test/functional/pages/ArticlePages/ArticlesPage.groovy index cc9c64b1..43f4a3ef 100644 --- a/test/functional/pages/ArticlePages/ArticlesPage.groovy +++ b/test/functional/pages/ArticlePages/ArticlesPage.groovy @@ -1,67 +1,134 @@ -//#if($Article) -package pages.ArticlePages - -import geb.Page -import pages.GetPageTitle -import rgms.publication.Periodico - -class ArticlesPage extends Page { - static url = "periodico/list" - - - static at = { - //title ==~ /Periodico Listagem/ - GetPageTitle gp = new GetPageTitle() - def currentPeriodico = gp.msg("default.periodico.label") - def currentTitle = gp.msg("default.list.label", [currentPeriodico]) - - title ==~ currentTitle - } - - static content = { - } - - def uploadWithoutFile() { - $('input.save').click() - } - - def selectNewArticle() { - $('a.create').click() - } - - def checkIfArticlesListIsEmpty() { - def listDiv = $('div', id: 'list-periodico') - def articleTable = (listDiv.find('table'))[0] - def articleRows = articleTable.find('tbody').find('tr') - def articleColumns = articleRows[0].find('td') - - assert articleColumns.size() < 23 - } - - /** - * @author Guilherme - */ - def selectViewArticle(title) { - def listDiv = $('div', id: 'list-periodico') - def articleTable = (listDiv.find('table'))[0] - def articleRow = articleTable.find('tbody').find('tr') - def showLink = articleRow.find('td').find([text: title]) - showLink.click() - } - - /** - * @author Guilherme - */ - def checkArticleAtList(title, row) { - def listDiv = $('div', id: 'list-periodico') - def articleTable = (listDiv.find('table'))[0] - def articleRows = articleTable.find('tbody').find('tr') - def articleColumns = articleRows[row].find('td') - - def testarticle = Periodico.findByTitle(title) - assert articleColumns[0].text() == testarticle.title - assert articleColumns[2].text() == testarticle.file - assert articleColumns[5].text() == testarticle.journal - } -} -//#end +package pages.ArticlePages + +import geb.Page +import pages.GetPageTitle +import rgms.publication.Periodico + +class ArticlesPage extends Page { + static url = "periodico/list" + + + static at = { + //title ==~ /Periodico Listagem/ + GetPageTitle gp = new GetPageTitle() + def currentPeriodico = gp.msg("default.periodico.label") + def currentTitle = gp.msg("default.list.label", [currentPeriodico]) + + title ==~ currentTitle + } + + static content = { + } + + def uploadWithoutFile() { + $('input.save').click() + } + + def selectNewArticle() { + $('a.create').click() + } + + def selectViewReports() { + def listAnchors = $('a.list') + def reportAnchor = listAnchors[1] + reportAnchor.click() + } + + def checkIfArticlesListIsEmpty() { + def listDiv = $('div', id: 'list-periodico') + def articleTable = (listDiv.find('table'))[0] + def articleRows = articleTable.find('tbody').find('tr') + def articleColumns = articleRows[0].find('td') + + assert articleColumns.size() < 23 + } + + /** + * @author Guilherme + */ + def selectViewArticle(title) { + def listDiv = $('div', id: 'list-periodico') + def articleTable = (listDiv.find('table'))[0] + def articleRow = articleTable.find('tbody').find('tr') + def showLink = articleRow.find('td').find([text: title]) + showLink.click() + } + + /** + * @author Guilherme + */ + def checkArticleAtList(title, row) { + def articleColumns = this.getArticleColumns(row) + def testarticle = Periodico.findByTitle(title) + assert articleColumns[1].text() == testarticle.title + assert articleColumns[3].text() == testarticle.file + assert articleColumns[6].text() == testarticle.journal + } + + def selectOrderBy(sortType){ + switch (sortType) { + case 'title': + $('a[href="/rgms/periodico/list?sort=title&max=10&order=asc"]').click() + break + case 'publication date': + $('a[href="/rgms/periodico/list?sort=publicationDate&max=10&order=asc"]').click() + break + } + } + + def checkOrderedBy(sortType){ + def firstArticleColumns = this.getArticleColumns(0) + def secondArticleColumns = this.getArticleColumns(1) + switch (sortType) { + case 'title': + assert firstArticleColumns[0].text().compareTo(secondArticleColumns[0].text()) < 0 + break + case 'publication date': + assert firstArticleColumns[1].text().compareTo(secondArticleColumns[1].text()) < 0 + break + } + } + + def getArticleColumns(row){ + def listDiv = $('div', id: 'list-periodico') + def articleTable = (listDiv.find('table'))[0] + def articleRows = articleTable.find('tbody').find('tr') + def articleColumns = articleRows[row].find('td') + return articleColumns + } + + def selectViewArticleList() { + def listAnchors = $('a.list') + def listAnchor = listAnchors[0] + listAnchor.click() + } + + def fillAndSelectFilter(authorName){ + $("form").authorName = authorName + $("input", name: "buttonFilterByAuthor").click() + } + + def checkFilteredBy(authorName){ + def listDiv = $('div', id: 'list-periodico') + def articleTable = (listDiv.find('table'))[0] + def articleRows = articleTable.find('tbody').find('tr') + for (row in articleRows) { + def articleColumns = row.find('td') + if(!articleColumns[5].text().contains(authorName)) + return false + } + return true + } + + def selectRemoveMultipleArticles() { + assert withConfirm(true) { + $("input", id: "removeMultiple").click() + } + } + + def markArticles(){ + def listcheckbox = $('input', type:'checkbox') + listcheckbox[0].click() + listcheckbox[2].click() + } +} diff --git a/test/functional/steps/ArticleTestDataAndOperations.groovy b/test/functional/steps/ArticleTestDataAndOperations.groovy index 1d1427f5..390bd57f 100644 --- a/test/functional/steps/ArticleTestDataAndOperations.groovy +++ b/test/functional/steps/ArticleTestDataAndOperations.groovy @@ -1,4 +1,3 @@ -//#if($Article) package steps import rgms.publication.Periodico @@ -14,85 +13,156 @@ import rgms.publication.XMLController */ class ArticleTestDataAndOperations { - static articles = [ - [journal: "Theoretical Computer Science", volume: 455, number: 1, pages: "2-30", - title: "A theory of software product line refinement", - publicationDate: (new Date("12 October 2012"))], - [journal: "Science of Computer Programming", volume: 455, pages: "2-30", - title: "Algebraic reasoning for object-oriented programming", - publicationDate: (new Date("12 October 2012"))] - ] - - static public def findArticleByTitle(String title) { - articles.find { article -> - article.title == title - } - } - - static public void uploadArticle(filename) { - def cont = new XMLController() - def xml = new File(filename); - def records = new XmlParser() - cont.saveJournals(records.parse(xml)) - cont.response.reset() - } - - static public boolean compatibleTo(article, title) { - def testarticle = findArticleByTitle(title) - def compatible = false - if (testarticle == null && article == null) { - compatible = true - } else if (testarticle != null && article != null) { - compatible = true - testarticle.each { key, data -> - compatible = compatible && (article."$key" == data) - } - } - return compatible - } - - static public void createArticle(String title, filename) { - def cont = new PeriodicoController() - cont.params << ArticleTestDataAndOperations.findArticleByTitle(title) << [file: filename] - cont.request.setContent(new byte[1000]) // Could also vary the request content. - cont.create() - cont.save() - cont.response.reset() - } - - static void clearArticles() { - Periodico.findAll()*.delete flush: true // Could also delete the created files. - } - - static public void removeArticle(String title) { - def testarticle = Periodico.findByTitle(title) - def cont = new PeriodicoController() - def date = new Date() - cont.params << [id: testarticle.id] - cont.delete() - } - - static public boolean containsArticle(title, articles) { - def testarticle = Periodico.findByTitle(title) - def cont = new PeriodicoController() - def result = cont.list().periodicoInstanceList - return result.contains(testarticle) - } - - static public Periodico editArticle(oldtitle, newtitle) { - def article = Periodico.findByTitle(oldtitle) - article.setTitle(newtitle) - def cont = new PeriodicoController() - cont.params << article.properties - cont.update() - - def updatedarticle = Periodico.findByTitle(newtitle) - return updatedarticle - } - - static public def path() { - return new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator - } + static articles = [ + [journal: "Theoretical Computer Science", volume: 455, number: 1, pages: "2-30", + title: "A theory of software product line refinement", + publicationDate: (new Date("12 October 2012"))], + [journal: "Science of Computer Programming", volume: 455, pages: "2-30", + title: "Algebraic reasoning for object-oriented programming", + publicationDate: (new Date("12 October 2012"))], + [journal: "Science of Computer Programming", volume: 300, pages: "50-70", + title: "Modularity analysis of use case implementations", + publicationDate: (new Date("12 October 2012"))], + [journal: "Science of Computer Programming", volume: 255, pages: "30-50", + filename: "TCS-01.pdf", publicationDate: (new Date("12 October 2012"))] + ] + + static public def findArticleByTitle(String title) { + articles.find { article -> + article.title == title + } + } + + static public void uploadArticle(filename) { + def cont = new XMLController() + def xml = new File(filename); + def records = new XmlParser() + cont.saveJournals(records.parse(xml)) + cont.response.reset() + } + + static public boolean compatibleTo(article, title) { + def testarticle = findArticleByTitle(title) + def compatible = false + if (testarticle == null && article == null) { + compatible = true + } else if (testarticle != null && article != null) { + compatible = true + testarticle.each { key, data -> + compatible = compatible && (article."$key" == data) + } + } + return compatible + } + + static public void createArticle(String title, filename) { + createArticle(title,filename, null,null) + } + + static public void createArticle(String title, filename, date, authorName) { + def cont = new PeriodicoController() + cont.params << ArticleTestDataAndOperations.findArticleByTitle(title) << [file: filename] + if(date!=null){ + cont.params["publicationDate"] = new Date(date) + } + if(authorName!=null){ + cont.params["authors"] = authorName + + } + cont.request.setContent(new byte[1000]) // Could also vary the request content. + cont.create() + cont.save() + cont.response.reset() + } + + static public void createArticleWithoutTitle(filename) { + def cont = new PeriodicoController() + cont.params << ArticleTestDataAndOperations.findArticleByFilename(filename) + cont.request.setContent(new byte[1000]) // Could also vary the request content. + cont.create() + cont.save() + cont.response.reset() + } + + static void clearArticles() { + Periodico.findAll()*.delete flush: true // Could also delete the created files. + } + + static public void removeArticle(String title) { + def testarticle = Periodico.findByTitle(title) + def cont = new PeriodicoController() + def date = new Date() + cont.params << [id: testarticle.id] + cont.delete() + } + + static public boolean containsArticle(title, articles) { + def testarticle = Periodico.findByTitle(title) + def cont = new PeriodicoController() + def result = cont.list().periodicoInstanceList + return result.contains(testarticle) + } + + static public Periodico editArticle(oldtitle, newtitle) { + def article = Periodico.findByTitle(oldtitle) + article.setTitle(newtitle) + def cont = new PeriodicoController() + cont.params << article.properties + cont.update() + + def updatedarticle = Periodico.findByTitle(newtitle) + return updatedarticle + } + + static public def path(){ + return new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + } + + static public def isSorted(articles,sortType) { + def isSorted = false + switch (sortType) { + case 'title': + isSorted = (articles.size() < 2 || (1.. + article.filename == filename + } + } + + static public List reportArticles() { + def cont = new PeriodicoController() + return cont.report().periodicoInstanceList + } + + static public List findAllByAuthor(authorName) { + def cont = new PeriodicoController() + cont.params << [authorName: authorName] + cont.filterByAuthor() + return cont.modelAndView.model.periodicoInstanceList + } + + static public void removeMultiplesArticles(String... titles) { + def ids = [] + titles.each {ids.add(String.valueOf(Periodico.findByTitle(it).id))} + def cont = new PeriodicoController() + cont.params << [check: ids] + cont.deleteMultiples() + } } -//#end