diff --git a/.gitignore b/.gitignore index a1defcef..b02282f5 100644 --- a/.gitignore +++ b/.gitignore @@ -424,6 +424,8 @@ target/test-reports/plain/TEST-functional-cucumber-Visit.txt .idea/* +target/test-reports/* + target/test-reports/TEST-functional-cucumber-orientations.xml target/test-reports/html/11_orientations.html @@ -441,3 +443,5 @@ target/test-reports/plain/TEST-functional-cucumber-orientations-err.txt target/test-reports/plain/TEST-functional-cucumber-orientations-out.txt target/test-reports/plain/TEST-functional-cucumber-orientations.txt + + diff --git a/chromedrivers/chromedriverwindows.exe b/chromedrivers/chromedriverwindows.exe index 89fea89c..c6c7761c 100755 Binary files a/chromedrivers/chromedriverwindows.exe and b/chromedrivers/chromedriverwindows.exe differ diff --git a/grails-app/conf/Config.groovy b/grails-app/conf/Config.groovy index e9655d34..067b7c20 100644 --- a/grails-app/conf/Config.groovy +++ b/grails-app/conf/Config.groovy @@ -15,7 +15,7 @@ grails { port = 465 //TODO: Before running, make sure that your email login and password appear below //TODO: Before committing, make sure that the strings "LOGIN" and "PASSWORD" appear in place of your login and password - username = "LOGIN" + username = "USERNAME" password = "PASSWORD" props = ["mail.smtp.auth": "true", "mail.smtp.socketFactory.port": "465", diff --git a/grails-app/controllers/rgms/publication/BookChapterController.groovy b/grails-app/controllers/rgms/publication/BookChapterController.groovy index 4de21197..4e2dd855 100644 --- a/grails-app/controllers/rgms/publication/BookChapterController.groovy +++ b/grails-app/controllers/rgms/publication/BookChapterController.groovy @@ -96,4 +96,6 @@ class BookChapterController { def bookChapterInstance = BookChapter.get(id) aux.delete(id, bookChapterInstance, 'bookChapter.label', 'BookChapter'); } + + } diff --git a/grails-app/domain/rgms/member/Orientation.groovy b/grails-app/domain/rgms/member/Orientation.groovy index 587ee3c7..c53f5713 100644 --- a/grails-app/domain/rgms/member/Orientation.groovy +++ b/grails-app/domain/rgms/member/Orientation.groovy @@ -10,13 +10,15 @@ class Orientation { String instituicao String curso + static constraints = { tipo(nullable: false, blank: false, inList: ["Mestrado","Doutorado","Iniciação Científica"]) orientando(nullable: false) orientador(nullable: false) - tituloTese(nullable: false, blank: false) - anoPublicacao(nullable: false) + tituloTese(nullable: false, blank: false, unique: true) + anoPublicacao(nullable: false, min: 0) instituicao(nullable: false, blank: false) + curso(nullable: true) } boolean Equals(Orientation other) diff --git a/grails-app/domain/rgms/publication/BookChapter.groovy b/grails-app/domain/rgms/publication/BookChapter.groovy index d9b8d5b6..db15afa2 100644 --- a/grails-app/domain/rgms/publication/BookChapter.groovy +++ b/grails-app/domain/rgms/publication/BookChapter.groovy @@ -7,7 +7,7 @@ class BookChapter extends Publication { int chapter static constraints = { - publisher nullable: false, blank: false + publisher nullable: false, blank: false, unique: ['title','file','chapter'] chapter nullable: false, blank: false, min: 1 } diff --git a/test/cucumber/BookChapter.feature b/test/cucumber/BookChapter.feature index f50456ba..e5482eb6 100644 --- a/test/cucumber/BookChapter.feature +++ b/test/cucumber/BookChapter.feature @@ -21,7 +21,7 @@ Feature: BookChapter Scenario: register book chapter with invalid data Given I am at the book chapter page - And I select the Novo BookChapter option at the book chapter page + And I select the new book chapter option at the book chapter page And I fill only the title field with the value "Next Generation Software Product Line Engineering" Then A failure message is displayed And I still on the book chapter create page @@ -29,16 +29,25 @@ Feature: BookChapter Scenario: new book chapter web Given I am at the book chapter page And the system has no book chapter entitled "Next Generation Software Product Line Engineering" - When I go to NewBookChapter page + When I go to new book chapter page And I use the webpage to create the book chapter "Next Generation Software Product Line Engineering" with file name "Ngs.pdf" Then the book chapter "Next Generation Software Product Line Engineering" was stored by the system And it is shown in the book chapter list with title "Next Generation Software Product Line Engineering" + #4 + Scenario: new duplicate book chapter web + Given I am at the book chapter page + And the system has a book chapter entitled "Next Generation Software Product Line Engineering" with file name "Ngs.pdf" + When I go to new book chapter page + And I use the webpage to create the book chapter "Next Generation Software Product Line Engineering" with file name "Ngs.pdf" + Then the book chapter "Next Generation Software Product Line Engineering" is not stored twice + And the system shows an error message + #if ($contextualInformation) Scenario: new book chapter filled with user data by default Given I am at the book chapter page - And I select the Novo BookChapter option at the book chapter page + And I select the new book chapter option at the book chapter page Then I see my user listed as a member of book chapter by default #end diff --git a/test/cucumber/Orientation.feature b/test/cucumber/Orientation.feature index 8ac4fb5c..850da8e8 100644 --- a/test/cucumber/Orientation.feature +++ b/test/cucumber/Orientation.feature @@ -5,37 +5,78 @@ Feature: orientations so that I can generate web pages and reports containing these orientations Scenario: new orientation - Given the system has no orientations entitled "The Book is on the table 2" - When I create a orientation for the thesis "The Book is on the table 2" - Then the orientation "The Book is on the table 2" is properly stored by the system + Given the system has no orientations entitled "The Book is on the table" + When I create a new orientation entitled "The Book is on the table" + Then the orientation "The Book is on the table" is properly stored by the system Scenario: remove existing orientation - Given the system has thesis entitled "The Book is on the table" supervised for someone + Given the system has an orientation entitled "The Book is on the table" supervised by someone When I delete the orientation for "The Book is on the table" Then the orientation for "The Book is on the table" is properly removed by the system Scenario: create orientation web Given I am at the create orientation page - When I fill the orientation title with "The Book is on the table" - Then I am on the orientation show page + When I fill the orientation title with "The Book of Web Software" + And I select the list orientation option + Then the orientation "The Book of Web Software" is properly stored by the system Scenario: edit existing orientation web - Given I am at the orientation page and the orientation "The Book is on the table" is stored in the system + Given I am at the orientation page + And the orientation "The Book of Software Engineering" is stored in the system + When I select to view orientation "The Book of Software Engineering" in resulting list + And I change the orientation title to "Hexa" + And I select the change option at the orientation edit page + Then the edited orientation "Hexa" is properly stored by the system + + #1 This scenario test are not working well, please check they implementation before undo the comment + + #Scenario: new orientation with registered member orientated + # Given the system has no orientations entitled "The Book is on the table 2" + # And Exists a member "Rubens Lopes" with username "rlfs" that has been an registered member + #When I create a orientation for the thesis "The Book is on the table 2" with registered member "rlfs" + #Then the orientation "The Book is on the table 2" is properly stored by the system + + + #2 + Scenario: duplicate orientation + Given the system has an orientation entitled "The Book is on the table" supervised by someone + When I create a new orientation entitled "The Book is on the table" + Then the orientation for the thesis "The Book is on the table" is not stored twice + + #3 + Scenario: create orientation web with invalid year + Given I am at the create orientation page + When I fill the orientation title with "The Book is on the table" and the year with -1 + Then I am still on the create orientation page with an error message + + #5 + Scenario: edit existing orientation web with invalid year + Given I am at the orientation page + And the orientation "The Book is on the table" is stored in the system When I select to view orientation "The Book is on the table" in resulting list - And I change the orientation tituloTese to "Hexa" - And I select the "Alterar" option - Then I am on the orientation show page - -#if ($XMLUpload) - Scenario: upload orientation with a file - Given the system has some orientations stored - When I upload a new orientation "testelattes.xml" - Then the system has more orientations now - - Scenario: upload orientations with a file - Given I am at the publications menu - When I select the "Orientation" option at the program menu - And I select the upload button at the orientations page - Then I'm still on orientations page - And the orientations are not stored by the system -#end + And I change the orientation title to "Hexa" + And I fill the orientation publication year with -1 + And I select the change option at the orientation edit page + Then I am still on the change orientation page with an error message + + #9 extra + Scenario: remove orientation web + Given I am at the orientation page + And the orientation "Hexa2" is stored in the system + When I select to view "Hexa2" in the list of orientations + And I select the option remove at the orientation show page + Then The orientation "Hexa2" is properly removed by the system + + #if ($XMLUpload) + Scenario: upload orientation with a file + Given the system has some orientations stored + When I upload a new orientation "testelattes.xml" + Then the system has more orientations now + + Scenario: upload orientations with a file + Given I am at the publications menu + When I select the "Orientation" option at the program menu + And I select the upload button at the orientations page + Then I'm still on orientations page + And the orientations are not stored by the system + #end \ No newline at end of file diff --git a/test/cucumber/Thesis.feature b/test/cucumber/Thesis.feature index 86921073..2d8d2ffb 100644 --- a/test/cucumber/Thesis.feature +++ b/test/cucumber/Thesis.feature @@ -2,17 +2,23 @@ Feature: Thesis Tests As a member of a research group I want to add, remove and modify theses I have added - + Scenario: new thesis duplicated Given The thesis "Thesis duplicated" is stored in the system with file name "Thesisduplicated.txt" When I create the thesis "Thesis duplicated" with file name "Thesisduplicated2.txt" and school "UFPE" Then The thesis "Thesis duplicated" is not stored twice - + Scenario: new thesis Given The system has no thesis entitled "New thesis" When I create the thesis "New thesis" with file name "Newthesis.txt" and school "UFPE" Then The thesis "New thesis" is properly stored by the system + #6 + Scenario: remove existing thesis + Given the system has thesis entitled "New thesis2" + When I delete the thesis "New thesis2" + Then the thesis "New thesis2" is properly removed by the system + Scenario: create thesis web Given I am at the create thesis page When I fill the thesis details with "Software Engineering", "10", "8", "1998", "UFPE" and "Recife" @@ -24,6 +30,13 @@ Feature: Thesis Tests When I fill some thesis details with "Tese002", "10", "8", "1998", "UFPE" and "Recife" Then I am still on the create thesis page with the error message + #7 + Scenario: remove existing thesis web + Given I am at the thesis page and the thesis "Software Enginnering2" is stored in the system + When I select to view thesis "Software Enginnering2" in resulting list + And I select the remover option at the thesis show page + Then the thesis "Software Enginnering2" is removed from the system + #if ($contextualInformation) Scenario: Add a new thesis with user data already filled by default Given I am at the publications menu diff --git a/test/cucumber/steps/BookChapterSteps.groovy b/test/cucumber/steps/BookChapterSteps.groovy index a6daf95b..4c1e5f46 100644 --- a/test/cucumber/steps/BookChapterSteps.groovy +++ b/test/cucumber/steps/BookChapterSteps.groovy @@ -41,12 +41,12 @@ Then(~'^the book chapter "([^"]*)" is properly removed by the system$') { String checkIfExists(title) } -When(~'^I select the Novo BookChapter option at the book chapter page$') {-> +When(~'^I select the new book chapter option at the book chapter page$') { -> at BookChapterPage page.selectNewBookChapter() } -Given(~'^I am at the book chapter page$') {-> +Given(~'^I am at the book chapter page$') { -> to LoginPage at LoginPage page.fillLoginData("admin", "adminadmin") @@ -60,20 +60,20 @@ And(~'^I fill only the title field with the value "([^"]*)"$') { String title -> page.fillTitle(title) } -Then(~'^A failure message is displayed$') {-> - assert ( page.readFlashMessage() != null ) +Then(~'^A failure message is displayed$') { -> + assert (page.readFlashMessage() != null) } -And(~'^I still on the book chapter create page$'){-> +And(~'^I still on the book chapter create page$') { -> at BookChapterCreatePage } -Then(~'^I see my user listed as a member of book chapter by default$') {-> +Then(~'^I see my user listed as a member of book chapter by default$') { -> at BookChapterCreatePage assert TestDataAndOperationsPublication.containsUser(page.selectedMembers()) } -When(~'^I view the book chapter list$') {-> +When(~'^I view the book chapter list$') { -> to BookChapterPage } @@ -82,7 +82,7 @@ Then(~'my book chapter list contains "([^"]*)"$') { String title -> bookChapterList = BookChapter.findAll() assert BookChapterTestDataAndOperations.containsBookChapter(title, bookChapterList) } -And(~'^the book chapter "([^"]*)" with file name "([^"]*)" was created before$'){ String title, filename -> +And(~'^the book chapter "([^"]*)" with file name "([^"]*)" was created before$') { String title, filename -> page.selectNewBookChapter() to BookChapterCreatePage at BookChapterCreatePage @@ -95,30 +95,30 @@ Then(~'My resulting book chapter list contains "([^"]*)"$') { String title -> at BookChapterPage page.checkBookChapterAtList(title, 0) } -When(~'^I go to NewBookChapter page$'){-> - to BookChapterPage +When(~'^I go to new book chapter page$') { -> +// to BookChapterPage at BookChapterPage page.selectNewBookChapter() at BookChapterCreatePage } -And(~'^I use the webpage to create the book chapter "([^"]*)" with file name "([^"]*)"$'){ String title, filename -> +And(~'^I use the webpage to create the book chapter "([^"]*)" with file name "([^"]*)"$') { String title, filename -> at BookChapterCreatePage createAndCheckBookOnBrowser(title, filename) to BookChapterPage at BookChapterPage } -Then(~'^the book chapter "([^"]*)" was stored by the system$'){String title -> +Then(~'^the book chapter "([^"]*)" was stored by the system$') { String title -> book = BookChapter.findByTitle(title) assert book != null to BookChapterPage at BookChapterPage } -And(~'^it is shown in the book chapter list with title "([^"]*)"$'){ String title -> +And(~'^it is shown in the book chapter list with title "([^"]*)"$') { String title -> to BookChapterPage at BookChapterPage page.checkBookChapterAtList(title, 0) } -Given(~'^the system has some book chapters stored$') {-> +Given(~'^the system has some book chapters stored$') { -> initialSize = BookChapter.findAll().size() } When(~'^I upload the book chapters of "([^"]*)"$') { filename -> @@ -128,7 +128,7 @@ When(~'^I upload the book chapters of "([^"]*)"$') { filename -> finalSize = BookChapter.findAll().size() assert initialSize < finalSize } -Then(~'^the system has all the book chapters of the xml file$') {-> +Then(~'^the system has all the book chapters of the xml file$') { -> assert BookChapter.findByTitle("Refinement of Concurrent Object Oriented Programs") != null assert BookChapter.findByTitle("A RUP-Based Software Process Supporting Progressive Implementation") != null assert BookChapter.findByTitle("Transformation Laws for Sequential Object-Oriented Programming") != null @@ -137,26 +137,47 @@ Then(~'^the system has all the book chapters of the xml file$') {-> assert BookChapter.findByTitle("An Introduction to Software Product Line Refactoring") != null } -And(~'^I select the upload button at the book chapter page$') {-> + +And(~'^I select the upload button at the book chapter page$') { -> at BookChapterPage page.uploadWithoutFile() } -Then(~'^I\'m still on book chapter page$') {-> +Then(~'^I\'m still on book chapter page$') { -> at BookChapterPage } -And(~'^the book chapters are not stored by the system$') {-> +And(~'^the book chapters are not stored by the system$') { -> at BookChapterPage page.checkIfBookChapterListIsEmpty() } -def createAndCheckBookOnBrowser(String title, String filename){ +And(~'^the system has a book chapter entitled "([^"]*)" with file name "([^"]*)"$') { String title, String filename -> + book = BookChapter.findByTitle(title) + if (book == null) { + BookChapterTestDataAndOperations.createBookChapter(title, filename) + } +} + +Then(~'^the book chapter "([^"]*)" was not stored twice$') { String entitled -> + bookChapter = BookChapter.findAllByPublisher(entitled) + assert bookChapter.size() < 2 +} + +And(~'^the system shows an error message$') { -> + at BookChapterPage + //assert page.readFlashMessage() + //Thread.sleep(100000) + assert page.hasErrorUploadFile() +} + + +def createAndCheckBookOnBrowser(String title, String filename) { page.fillBookChapterDetails(title, filename) page.clickSaveBookChapter() book = BookChapter.findByTitle(title) assert book != null } -def checkIfExists(String title){ +def checkIfExists(String title) { bookChapter = BookChapter.findByTitle(title) assert bookChapter == null } diff --git a/test/cucumber/steps/MemberSteps.groovy b/test/cucumber/steps/MemberSteps.groovy index cb32c257..450d060e 100644 --- a/test/cucumber/steps/MemberSteps.groovy +++ b/test/cucumber/steps/MemberSteps.groovy @@ -35,7 +35,7 @@ Then(~'^the system has no member with a username "([^"]*)"$') { String username assert member == null } -Given(~'^I am at the login page$') {-> +Given(~'^I am at the login page$') { -> to LoginPage at LoginPage //assert (page.flashmessage?.size() == 0) @@ -46,12 +46,12 @@ When(~'^I fill username and password with "([^"]*)" and "([^"]*)"$') { String lo page.fillLoginData(login, password) } -Then(~'^I am still on the login page with an error message$') {-> +Then(~'^I am still on the login page with an error message$') { -> at LoginPage assert page.readFlashMessage() != null } -Given(~'^I am at the register page$') {-> +Given(~'^I am at the register page$') { -> to RegisterPage at RegisterPage } @@ -61,7 +61,7 @@ When(~'^I fill the user details with a name, username, passoword1, password2, em page.fillUserDetails(name, username, password1, password2, email, university, status) } -Then(~'^I am still on the register page with the message user created$') {-> +Then(~'^I am still on the register page with the message user created$') { -> at RegisterPage } @@ -99,7 +99,7 @@ Then(~'^the member "([^"]*)" is not registered$') { String username -> assert users.size() == 1 } -Given(~'^I am at the create member page$') {-> +Given(~'^I am at the create member page$') { -> to LoginPage at LoginPage page.fillLoginData("admin", "adminadmin") @@ -115,7 +115,7 @@ When(~'^I fill some user details with "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)"$') page.fillSomeMemberDetails(name, username, email, university) } -Then(~'^I am on the member show page$') {-> +Then(~'^I am on the member show page$') { -> at MemberViewPage } @@ -129,7 +129,7 @@ Then(~'^I am on the member show page$') {-> page.fillMemberDetails(name, username, email, university) }*/ -Then(~'^I am still on the create member page with the error message$') {-> +Then(~'^I am still on the create member page with the error message$') { -> at MemberCreatePage //assert mensagem != null @@ -143,7 +143,7 @@ When(~'^I fill user details with "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)"$') { St page.fillSomeMemberDetails(name, username, email, university) } -When(~"^I view the member list\$") {-> +When(~"^I view the member list\$") { -> members = Member.findAll() assert members != null } @@ -159,15 +159,15 @@ Then(~'the member with username "([^"]*)" is created$') { String username -> assert member != null } -Then(~'^I see default data filled on create form$'){ -> +Then(~'^I see default data filled on create form$') { -> at MemberCreatePage - defaultUniversity = "Federal University of Pernambuco" - defaultCity = "Recife" + defaultUniversity = "Federal University of Pernambuco" + defaultCity = "Recife" assert page.compareMemberUniversity(defaultUniversity) && page.compareMemberCity(defaultCity) } -Then(~'^I see default data filled on register form$'){ -> +Then(~'^I see default data filled on register form$') { -> at RegisterPage - defaultUniversity = "Federal University of Pernambuco" + defaultUniversity = "Federal University of Pernambuco" assert page.compareMemberUniversity(defaultUniversity) } \ No newline at end of file diff --git a/test/cucumber/steps/OrientationSteps.groovy b/test/cucumber/steps/OrientationSteps.groovy index d812400e..77eac1d1 100644 --- a/test/cucumber/steps/OrientationSteps.groovy +++ b/test/cucumber/steps/OrientationSteps.groovy @@ -1,9 +1,9 @@ import pages.OrientationPages.* import pages.* +import rgms.authentication.User +import rgms.member.Member import rgms.member.Orientation -import rgms.publication.Periodico -import rgms.tool.FacebookTool -import rgms.tool.TwitterTool +import steps.MemberTestDataAndOperations import steps.OrientationTestDataAndOperations import org.apache.shiro.util.ThreadContext @@ -19,115 +19,137 @@ Given(~'^the system has no orientations entitled "([^"]*)"$') { String tituloTes assert orientation == null } -When(~'^I create a orientation for the thesis "([^"]*)"$') { String tituloTese -> +When(~'^I create a new orientation entitled "([^"]*)"$') { String tituloTese -> // Express the Regexp above with the code you wish you had OrientationTestDataAndOperations.createOrientation(tituloTese) } -Then(~'^the orientation "([^"]*)" is properly stored by the system$') { String tituloTese -> - // Express the Regexp above with the code you wish you had - orientation = Orientation.findByTituloTese(tituloTese) - assert OrientationTestDataAndOperations.OrientationCompatibleTo(orientation, tituloTese) +Then(~'^the orientation "([^"]*)" is properly stored by the system$') { String title -> + orientation = Orientation.findByTituloTese(title) + assert orientation != null } - //delete -Given(~'^the system has thesis entitled "([^"]*)" supervised for someone$') { String tituloTese -> - - OrientationTestDataAndOperations.createOrientation(tituloTese) - orientation = OrientationTestDataAndOperations.findOrientationByTitle(tituloTese) +Given(~'^the system has an orientation entitled "([^"]*)" supervised by someone$') { String title -> + OrientationTestDataAndOperations.createOrientation(title) + orientation = OrientationTestDataAndOperations.findOrientationByTitle(title) assert orientation != null - } -When(~'^I delete the orientation for "([^"]*)"$') { String tituloTese -> - OrientationTestDataAndOperations.removeOrientation(tituloTese) +When(~'^I delete the orientation for "([^"]*)"$') { String title -> + OrientationTestDataAndOperations.removeOrientation(title) } -Then(~'^the orientation for "([^"]*)" is properly removed by the system$') { String tituloTese -> - orientation = Orientation.findByTituloTese(tituloTese) +Then(~'^the orientation for "([^"]*)" is properly removed by the system$') { String title -> + orientation = Orientation.findByTituloTese(title) assert orientation == null } //create web -Given(~'^I am at the create orientation page$') {-> +Given(~'^I am at the create orientation page$') { -> Login() - to OrientationCreatePage - at OrientationCreatePage + to PublicationsPage + at PublicationsPage + page.select("Orientation") -} + at OrientationsPage + page.selectNewOrientation() + + at OrientationCreatePage +} When(~'^I fill the orientation title with "([^"]*)"$') { String title -> page.fillOrientationDetails(title) page.selectCreateOrientation() + + at OrientationShowPage + + } -Then(~'^I am on the orientation show page$') {-> +And(~'^I select the list orientation option$'){ -> at OrientationShowPage + page.showList() + + at OrientationsPage } + //edit web -Given(~'^I am at the orientation page and the orientation "([^"]*)" is stored in the system$') { String title -> +Given(~'^I am at the orientation page$') { -> Login() + + to PublicationsPage at PublicationsPage page.select("Orientation") + at OrientationsPage +} + +And (~'^the orientation "([^"]*)" is stored in the system$'){ String title -> page.selectNewOrientation() at OrientationCreatePage - page.fillOrientationDetails() + page.fillOrientationDetails(title) page.selectCreateOrientation() - orientation = Orientation.findByTituloTese(title) - assert orientation != null - to OrientationsPage - at OrientationsPage + at OrientationShowPage + page.showList() + at OrientationsPage + orientation = Orientation.findByTituloTese(title) + assert orientation != null } + When(~'^I select to view orientation "([^"]*)" in resulting list$') { String oldtitle -> at OrientationsPage page.selectViewOrientation(oldtitle) - to OrientationShowPage at OrientationShowPage - page.select() + page.edit() + at OrientationEditPage } -When(~'^I change the orientation tituloTese to "([^"]*)"$') { String newtitle -> +When(~'^I change the orientation title to "([^"]*)"$') { String newtitle -> + page.editTituloTese(newtitle) +} - at OrientationEditPage - page.edit(newtitle) +When(~'^I select the change option at the orientation edit page$') { -> + page.confirmEdit() } -When(~'^I select the "([^"]*)" option$') { String option -> - at OrientationEditPage - page.select(option) +Then(~'^the edited orientation "([^"]*)" is properly stored by the system$'){ String title -> + at OrientationShowPage + orientation = Orientation.findByTituloTese(title) + assert orientation != null } -Given(~'^the system has some orientations stored$') {-> + +Given(~'^the system has some orientations stored$') { -> // save old metaclass def registry = GroovySystem.metaClassRegistry this.oldMetaClass = registry.getMetaClass(SecurityUtils) registry.removeMetaClass(SecurityUtils) // Mock login - def subject = [getPrincipal: {"admin"}, - isAuthenticated: {true} - ]as Subject + def subject = [getPrincipal: { "admin" }, + isAuthenticated: { true } + ] as Subject ThreadContext.put(ThreadContext.SECURITY_MANAGER_KEY, - [getSubject: {subject} as SecurityManager]) - SecurityUtils.metaClass.static.getSubject = {subject} + [getSubject: { subject } as SecurityManager]) + SecurityUtils.metaClass.static.getSubject = { subject } initialSize = Orientation.findAll().size() } + When(~'^I upload a new orientation "([^"]*)"$') { filename -> inicialSize = Orientation.findAll().size() def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator @@ -135,27 +157,111 @@ When(~'^I upload a new orientation "([^"]*)"$') { filename -> finalSize = Orientation.findAll().size() assert inicialSize < finalSize } -Then(~'the system has more orientations now$') {-> + +Then(~'the system has more orientations now$') { -> // restore metaclass GroovySystem.metaClassRegistry.setMetaClass(SecurityUtils, this.oldMetaClass) finalSize = Orientation.findAll().size() } -And(~'^I select the upload button at the orientations page$') {-> +And(~'^I select the upload button at the orientations page$') { -> at OrientationsPage page.uploadWithoutFile() } -Then(~'^I\'m still on orientations page$') {-> + +Then(~'^I\'m still on orientations page$') { -> at OrientationsPage } -And(~'^the orientations are not stored by the system$') {-> + +And(~'^the orientations are not stored by the system$') { -> at OrientationsPage page.checkIfOrientationListIsEmpty() } +//create web with invalid year +/** + * @author bss3 + */ +When(~'^I fill the orientation title with "([^"]*)" and the year with (-?\\d+)$') { title, year -> + page.fillOrientationDetailsWithGivenYear(title, year) + page.selectCreateOrientation() +} + +Then(~'^I am still on the create orientation page with an error message$') { -> + at OrientationCreatePage + assert page.readFlashMessage() != null +} + +//new orientation with registered member orientated +/** + * @author rlfs + */ +Given(~'^Exists a member "([^"]*)" with username "([^"]*)" that has been an registered member$') { String name, String username -> + + MemberTestDataAndOperations.createMember(username,"") + member = Member.findByName(name) + user = User.findByUsernameAndAuthor(username,member) + assert user != null +} +//#1 + +Then(~'^the orientation "([^"]*)" with orientated member "([^"]*)" is properly stored by the system') { String entitled, String username -> + user = User.findByUsername(username) + orientation = Orientation.findByTituloTeseAndOrientador(entitled,user) + assert orientation == null +} + +When(~'I create a orientation for the thesis "([^"]*)" with registered member "([^"]*)"$') { entitled, username -> + member = MemberTestDataAndOperations.findByUsername(username) + OrientationTestDataAndOperations.createOrientationWithMenber(entitled, member) + +} + +Then(~'^the orientation "([^"]*)" was not stored twice$') { entitled -> + orientation = Orientation.findAllByTituloTese(entitled) + assert orientation.size() >= 2 +} + +//#2 +Then(~'^the orientation for the thesis "([^"]*)" is not stored twice$') { entitled -> + orientation = Orientation.findAllByTituloTese(entitled) + assert orientation.size() < 2 +} + +//#5 +And(~'^I fill the orientation publication year with (-?\\d+)$') { anoPublicacao -> + at OrientationEditPage + page.editYear(anoPublicacao) +} + +Then(~'^I am still on the change orientation page with an error message$') { -> + at OrientationEditPage + assert page.readFlashMessage() != null +} + +Then(~'^The orientation "([^"]*)" is properly removed by the system$') { title -> + assert Orientation.findByTituloTese(title) == null +} + +//Remover Orientation Web +When(~'^I select to view "([^"]*)" in the list of orientations$') { title -> + at OrientationsPage + page.selectViewOrientation(title) + + at OrientationShowPage +} + +When(~'^I select the option remove at the orientation show page$') { -> + at OrientationShowPage + page.delete() + +} + //FUNCOES AUXILIARES + + // o problema de duplicação que este método resolve não foi identificado pela ferramenta de detecção de clones -def Login(){ +def Login() { to LoginPage at LoginPage page.fillLoginData("admin", "adminadmin") diff --git a/test/cucumber/steps/ThesisSteps.groovy b/test/cucumber/steps/ThesisSteps.groovy index c3c5e013..aaceb4e6 100644 --- a/test/cucumber/steps/ThesisSteps.groovy +++ b/test/cucumber/steps/ThesisSteps.groovy @@ -1,3 +1,5 @@ +import pages.PublicationsPage +import pages.thesis.ThesisEditPage import rgms.authentication.User import steps.ThesisTestDataAndOperations import pages.LoginPage @@ -11,14 +13,14 @@ import rgms.member.Member import java.io.File import static cucumber.api.groovy.EN.* -import org.codehaus.groovy.grails.web.context.ServletContextHolder +import org.codehaus.groovy.grails.web.context.ServletContextHolder -Given(~'^The system has no thesis entitled "([^"]*)"$') {String title -> +Given(~'^The system has no thesis entitled "([^"]*)"$') { String title -> article = Tese.findByTitle(title) assert article == null } -Given(~'^The thesis "([^"]*)" is stored in the system with file name "([^"]*)"$') { +Given(~'^The thesis "([^"]*)" is stored in the system with file name "([^"]*)"$') { String title, filename -> ThesisTestDataAndOperations.createTese(title, filename, "UFPE") article = Tese.findByTitle(title) @@ -27,7 +29,7 @@ Given(~'^The thesis "([^"]*)" is stored in the system with file name "([^"]*)"$' When(~'^I create the thesis "([^"]*)" with file name "([^"]*)" and school "([^"]*)"$') { String title, filename, school -> - ThesisTestDataAndOperations.createTese(title, filename, school) + ThesisTestDataAndOperations.createTese(title, filename, school) } Then(~'^The thesis "([^"]*)" is not stored twice$') { String title -> @@ -40,7 +42,7 @@ Then(~'^The thesis "([^"]*)" is properly stored by the system$') { String title assert thesis != null } -Given(~'^I am at the create thesis page$') {-> +Given(~'^I am at the create thesis page$') { -> to LoginPage at LoginPage page.fillLoginData("admin", "adminadmin") @@ -50,28 +52,27 @@ Given(~'^I am at the create thesis page$') {-> When(~'^I fill the thesis details with "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)" and "([^"]*)"$') { title, pub_day, pub_month, pub_year, school, address -> - def absolutePath = ServletContextHolder.servletContext.getRealPath("/test/functional/steps/NewthesisGUI.txt") - absolutePath = absolutePath.replace("\\", "/").replaceAll("/web-app", "") - page.fillThesisDetails(title, pub_day, pub_month, pub_year, school, address, absolutePath) + def absolutePath = ServletContextHolder.servletContext.getRealPath("/test/functional/steps/NewthesisGUI.txt") + absolutePath = absolutePath.replace("\\", "/").replaceAll("/web-app", "") + page.fillThesisDetails(title, pub_day, pub_month, pub_year, school, address, absolutePath) } When(~'^I fill some thesis details with "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)" and "([^"]*)"$') { title, pub_day, pub_month, pub_year, school, address -> - page.fillSomeThesisDetails(title, pub_day, pub_month, pub_year, school, address) + page.fillSomeThesisDetails(title, pub_day, pub_month, pub_year, school, address) } -Then(~'^I am on the thesis show page$') {-> +Then(~'^I am on the thesis show page$') { -> at ThesisShowPage } -Then(~'^I am still on the create thesis page with the error message$') {-> +Then(~'^I am still on the create thesis page with the error message$') { -> at ThesisCreatePage } - /** * @author carloscemb */ -When(~'^I select the new thesis option at the thesis page$') {-> +When(~'^I select the new thesis option at the thesis page$') { -> at ThesisPage page.selectNewThesis() at ThesisCreatePage @@ -80,13 +81,90 @@ When(~'^I select the new thesis option at the thesis page$') {-> /** * @author carloscemb */ -Then(~'^I see my user listed as an author member of thesis by default$') {-> +Then(~'^I see my user listed as an author member of thesis by default$') { -> at ThesisCreatePage assert TestDataAndOperationsPublication.containsUser(page.selectedMembers()) } -Then(~'^I see my school name as school of thesis by default$') {-> +Then(~'^I see my school name as school of thesis by default$') { -> at ThesisCreatePage userData = User.findByUsername('admin')?.author?.university assert page.currentSchool() == userData } +/** + * @author bss3 e rlfs + */ + +//#7 +Given(~'^I am at the thesis page and the thesis "([^"]*)" is stored in the system$') { title -> + + Login() + at PublicationsPage + page.select("Tese") + at ThesisPage + + if (Tese.findByTitle(title) == null) { //tese ja existe não e preciso criar denovo + System.out.println("Tese " + title + " não existia, criando-a") + page.selectNewThesis() + at ThesisCreatePage + def absolutePath = ServletContextHolder.servletContext.getRealPath("/test/functional/steps/NewthesisGUI2.txt") + absolutePath = absolutePath.replace("\\", "/").replaceAll("/web-app", "") + page.fillThesisDetails(title, "10", "8", "1998", "UFPE", "Recife", absolutePath) + page.selectCreateThesis() + tese = Tese.findByTitle(title) + assert tese != null + + at ThesisShowPage + } + + to ThesisPage + at ThesisPage +} + +When(~'^I select to view thesis "([^"]*)" in resulting list$') { title -> + at ThesisPage + page.selectViewThesis(title) + + at ThesisShowPage + +} + +When(~'^I select the remover option at the thesis show page$') { -> + at ThesisShowPage + page.delete() + //passo para remover o alert +} + +Then(~'^the thesis "([^"]*)" is removed from the system$') { title -> + at ThesisPage + thesisDoNotExists(title) +} + +// #6 +Given(~'^the system has thesis entitled "([^"]*)"$') { title -> + ThesisTestDataAndOperations.createTese(title, 'teste.txt', 'UFPE') + thesis = Tese.findByTitle(title) + assert thesis != null +} + +When(~'^I delete the thesis "([^"]*)"$') { title -> + ThesisTestDataAndOperations.deleteTeseByTitle(title) +} + +Then(~'^the thesis "([^"]*)" is properly removed by the system$') { title -> + tese = Tese.findByTitle(title) + assert tese == null +} + +//FUNÇÔES AUXILIARES +def thesisDoNotExists(title) { + tese = Tese.findByTitle(title) + assert tese == null +} + + +def Login() { + to LoginPage + at LoginPage + page.fillLoginData("admin", "adminadmin") +} \ No newline at end of file diff --git a/test/functional/pages/BookChapterPage.groovy b/test/functional/pages/BookChapterPage.groovy index 3ef20fbb..0635b897 100644 --- a/test/functional/pages/BookChapterPage.groovy +++ b/test/functional/pages/BookChapterPage.groovy @@ -50,4 +50,9 @@ class BookChapterPage extends Page { assert bookChapterColumns.size() == 0 } + + def hasErrorUploadFile(){ + GetPageTitle gp = new GetPageTitle() + return gp.msg('file.already.exist.message') == $("div", class: "message",role:"status").text() + } } diff --git a/test/functional/pages/BookChapterSavePage.groovy b/test/functional/pages/BookChapterSavePage.groovy new file mode 100644 index 00000000..1f0eeccf --- /dev/null +++ b/test/functional/pages/BookChapterSavePage.groovy @@ -0,0 +1,19 @@ +package pages + +import geb.Page +import rgms.publication.BookChapter + +class BookChapterSavePage extends FormPage { + static url = "bookChapter/save" + + static at = { + //GetPageTitle gp = new GetPageTitle() + title ==~ /Capítulo de livro Listagem/ + } + + static content = { + flashmessage { + $("div", class: "message",role:"status") + } + } +} diff --git a/test/functional/pages/OrientationPages/OrientationCreatePage.groovy b/test/functional/pages/OrientationPages/OrientationCreatePage.groovy index 457aec78..27341e83 100644 --- a/test/functional/pages/OrientationPages/OrientationCreatePage.groovy +++ b/test/functional/pages/OrientationPages/OrientationCreatePage.groovy @@ -8,6 +8,7 @@ class OrientationCreatePage extends Page { static url = "orientation/create" static at = { + //title ==~ /Criar Orientation/ GetPageTitle gp = new GetPageTitle() @@ -15,33 +16,34 @@ class OrientationCreatePage extends Page { def currentTitle = gp.msg("default.create.label", [currentOrientation]) title ==~ currentTitle - tituloTese != null + //tituloTese != null } def fillOrientationDetails() { - //def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "TCS.pdf" fillOrientationDetails("The Book is on the table") } def fillOrientationDetails(title) { - - //def orientador = TestDataAndOperations.members[0] - - $("form").tituloTese = title $("form").tipo = "Mestrado" $("form").orientando = "Tomaz" - //$("form").orientador = orientador + $("form").tituloTese = title $("form").anoPublicacao = 2013 $("form").instituicao = "UFPE" - //selectCreateOrientation() - - + $("form").curso = "Ciencia da Computacao" + } - // Could parametrize, obtaining data from class TestDataAndOperations + def fillOrientationDetailsWithGivenYear(title, year) { + $("form").tipo = "Mestrado" + $("form").orientando = "Tomaz" + $("form").tituloTese = title + $("form").anoPublicacao = year + $("form").instituicao = "UFPE" + $("form").curso = "Ciencia da Computacao" } def selectCreateOrientation() { - $("input", name: "create").click() - + //$("input", name: "create").click() + $("input", name:"create", class:"save").click() } + } diff --git a/test/functional/pages/OrientationPages/OrientationEditPage.groovy b/test/functional/pages/OrientationPages/OrientationEditPage.groovy index 3a9135e2..726de2b2 100644 --- a/test/functional/pages/OrientationPages/OrientationEditPage.groovy +++ b/test/functional/pages/OrientationPages/OrientationEditPage.groovy @@ -7,7 +7,6 @@ class OrientationEditPage extends Page { static url = "orientation/edit/1" static at = { - //title ==~ /Editar Orientation/ GetPageTitle gp = new GetPageTitle() @@ -15,23 +14,34 @@ class OrientationEditPage extends Page { def currentTitle = gp.msg("default.edit.label", [currentOrientation]) title ==~ currentTitle - - - } static content = { + flashmessage { + $("div", class: "message") + } } - - def edit(String novovalor){ - + def editTituloTese(String novovalor){ $("form").tituloTese = novovalor - $("form").save().click() + } + def editYear(String newYear){ + $("form").anoPublicacao = Integer.parseInt(newYear) } + def select(String s) { $("form").find("input", value: s).click() } + + def confirmEdit(){ + $('input', class:'save').click() + } + + + def delete(){ + assert withConfirm(true) { $("form").find('input', class: 'delete').click() } + } + } diff --git a/test/functional/pages/OrientationPages/OrientationShowPage.groovy b/test/functional/pages/OrientationPages/OrientationShowPage.groovy index 71fbcb25..cab39658 100644 --- a/test/functional/pages/OrientationPages/OrientationShowPage.groovy +++ b/test/functional/pages/OrientationPages/OrientationShowPage.groovy @@ -4,9 +4,10 @@ import geb.Page import pages.GetPageTitle class OrientationShowPage extends Page { - static url = "orientation/show/1" + static url = "orientation/show" static at = { + //title ==~ /Ver orientation/ GetPageTitle gp = new GetPageTitle() @@ -17,11 +18,27 @@ class OrientationShowPage extends Page { } static content = { + flashmessage { + $("div", class: "message") + } } def select() { $("form").find('a', class: 'edit').click() } + + def edit(){ + $('a', class: 'edit').click() + } + + def delete() { + assert withConfirm(true) { $("form").find('input', class: 'delete').click() } + } + + def showList(){ + $('a', class:'list').click() + } + //#if ($Twitter) def clickOnTwitteIt(String login, pw) { $("#button_twitter").click() diff --git a/test/functional/pages/OrientationPages/OrientationsPage.groovy b/test/functional/pages/OrientationPages/OrientationsPage.groovy index 9e3fd171..c146a33a 100644 --- a/test/functional/pages/OrientationPages/OrientationsPage.groovy +++ b/test/functional/pages/OrientationPages/OrientationsPage.groovy @@ -9,6 +9,7 @@ class OrientationsPage extends Page { static at = { + //title ==~ /Orientation Listagem/ GetPageTitle gp = new GetPageTitle() @@ -18,33 +19,35 @@ class OrientationsPage extends Page { title ==~ currentTitle } - static content = { - } - + static content = { + flashmessage { + $("div", class: "message") + } + } def selectNewOrientation() { - $('a.create').click() + $('a', class:'create').click() } + def selectViewOrientation(title) { + def id = Orientation.findByTituloTese(title).id + $("a", text: id.toString()).click() - - def getRow(){ - - def listDiv = $('div', id: 'list-orientation') + /*def listDiv = $('div', id: 'list-orientation') def orientationTable = (listDiv.find('table'))[0] - def orientationRow = orientationTable.find('tbody').find('tr') - - return orientationRow - } - - def selectViewOrientation(title) { - getRow() - def showLink = getRow().find('td').find([text:title]) - showLink.click() + def orientationRow = (orientationTable.find('tbody'))[0].find('tr') + System.out.println("------------------------------------") + System.out.println(orientationRow.toString()) + System.out.println("------------------------------------") + def showLink = orientationRow.find('td').find([text:title]) + showLink.click()*/ + + /*def showLink = (getRow().find([text:title]))[0].find('td') + System.out.println("testando "+showLink) + showLink[0].click()*/ } - def checkOrientationAtList(title,row){ def orientationColumns = getRow()[row].find('td') diff --git a/test/functional/pages/ThesisPage.groovy b/test/functional/pages/ThesisPage.groovy index eb1995f0..7a361878 100644 --- a/test/functional/pages/ThesisPage.groovy +++ b/test/functional/pages/ThesisPage.groovy @@ -1,6 +1,7 @@ package pages import geb.Page +import rgms.publication.Tese /** * @author carloscemb @@ -16,7 +17,37 @@ class ThesisPage extends Page { title ==~ currentTitle } + static content = { + flashmessage { + $("div", class: "message") + } + } + def selectNewThesis() { $('a.create').click() } + + def getRow(){ + + def listDiv = $('div', id: 'list-tese') + def thesisTable = (listDiv.find('table'))[0] + def thesisRow = thesisTable.find('tbody').find('tr') + + return thesisRow + } + + def selectViewThesis(title) { + //getRow() + def showLink = getRow().find('td').find([text:title]) + showLink.click() + } + + def checkTeseAtList(title,row){ + def teseColumns = getRow()[row].find('td') + + def testtese = Tese.findByTitle(title) + assert teseColumns[1].text() == testtese.title + assert teseColumns[5].text() == testtese.school + } + } diff --git a/test/functional/pages/thesis/ThesisCreatePage.groovy b/test/functional/pages/thesis/ThesisCreatePage.groovy index 4e065c2e..1b3101f1 100644 --- a/test/functional/pages/thesis/ThesisCreatePage.groovy +++ b/test/functional/pages/thesis/ThesisCreatePage.groovy @@ -38,4 +38,7 @@ class ThesisCreatePage extends FormPage { $("form").school } + def selectCreateThesis() { + $("input", name: "create", class: "save").click() + } } diff --git a/test/functional/pages/thesis/ThesisEditPage.groovy b/test/functional/pages/thesis/ThesisEditPage.groovy new file mode 100644 index 00000000..0c79cccb --- /dev/null +++ b/test/functional/pages/thesis/ThesisEditPage.groovy @@ -0,0 +1,32 @@ +package pages.thesis + +import geb.Page +import pages.GetPageTitle + +/** + * Created by Bruno Soares on 16/01/14. + */ +class ThesisEditPage extends Page{ + static url = "tese/edit/1" + + static at = { + + //title ==~ /Editar Orientation/ + + GetPageTitle gp = new GetPageTitle() + def currentTese = gp.msg("default.tese.label") + def currentTitle = gp.msg("default.edit.label", [currentTese]) + + title ==~ currentTitle + } + + static content = { + flashmessage { + $("div", class: "message") + } + } + + def select(String s) { + $("form").find("input", value: s).click() + } +} diff --git a/test/functional/pages/thesis/ThesisShowPage.groovy b/test/functional/pages/thesis/ThesisShowPage.groovy index 25674b7a..14e7372f 100644 --- a/test/functional/pages/thesis/ThesisShowPage.groovy +++ b/test/functional/pages/thesis/ThesisShowPage.groovy @@ -2,6 +2,7 @@ package pages.thesis import geb.Page import pages.GetPageTitle +import rgms.publication.Tese class ThesisShowPage extends Page { static url = "tese/show" @@ -14,7 +15,14 @@ class ThesisShowPage extends Page { } static content = { + } + + def select() { + $("form").find('a', class: 'edit').click() + } + def delete(){ + assert withConfirm(true) { $("form").find('input', class: 'delete').click() } } -} +} \ No newline at end of file diff --git a/test/functional/steps/MemberTestDataAndOperations.groovy b/test/functional/steps/MemberTestDataAndOperations.groovy index a8cec682..16b0b7de 100644 --- a/test/functional/steps/MemberTestDataAndOperations.groovy +++ b/test/functional/steps/MemberTestDataAndOperations.groovy @@ -19,6 +19,9 @@ class MemberTestDataAndOperations { ], [name: "Rebeca Souza", username: "rebecasouza", email: "rsa2fake@cin.ufpe.br", status: "Graduate Student", university: "UFPE", enabled: true + ], + [name: "Rubens Lopes", username: "rlfs", email: "rlfsfake@cin.ufpe.br", + status: "Graduate Student", university: "UFPE", enabled: true ]] static public def findByUsername(String username) { @@ -44,7 +47,6 @@ class MemberTestDataAndOperations { cont.params << [id: identificador] cont.request.setContent(new byte[1000]) // Could also vary the request content. cont.delete() - //cont.save() cont.response.reset() } static public boolean containsMember(username) { diff --git a/test/functional/steps/NewthesisGUI2.txt b/test/functional/steps/NewthesisGUI2.txt new file mode 100644 index 00000000..eddf3b42 --- /dev/null +++ b/test/functional/steps/NewthesisGUI2.txt @@ -0,0 +1,711 @@ + + + + + +
+ + +