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/controllers/rgms/publication/BookChapterController.groovy b/grails-app/controllers/rgms/publication/BookChapterController.groovy index 4de21197..78b5e5f1 100644 --- a/grails-app/controllers/rgms/publication/BookChapterController.groovy +++ b/grails-app/controllers/rgms/publication/BookChapterController.groovy @@ -1,19 +1,10 @@ package rgms.publication - -import org.apache.shiro.SecurityUtils -import org.springframework.dao.DataIntegrityViolationException //#if($XMLUpload && $BookChapter) -import rgms.XMLService //#end -import org.xml.sax.SAXParseException -import rgms.authentication.User -import rgms.member.Member - - class BookChapterController { static allowedMethods = [save: "POST", update: "POST", delete: "POST"] - AuxiliarController aux = new AuxiliarController() + AuxiliarController aux = new AuxiliarController() def index() { redirect(action: "list", params: params) @@ -34,7 +25,7 @@ class BookChapterController { def save() { def bookChapterInstance = new BookChapter(params) - PublicationController pb = new PublicationController() + PublicationController pb = new PublicationController() if (!pb.upload(bookChapterInstance) || !bookChapterInstance.save(flush: true)) { render(view: "create", model: [bookChapterInstance: bookChapterInstance]) return @@ -47,10 +38,11 @@ class BookChapterController { flash.message = message(code: 'default.created.message', args: [message(code: 'bookChapter.label', default: 'BookChapter'), bookChapterInstance.id]) redirect(action: "show", id: bookChapterInstance.id) } + def accessBookChapter(Long id) { def bookChapterInstance = BookChapter.get(id) boolean isReturned = aux.check(id, bookChapterInstance, 'bookChapter.label', 'BookChapter'); - if(!isReturned){ + if (!isReturned) { [bookChapterInstance: bookChapterInstance] } } @@ -66,10 +58,10 @@ class BookChapterController { def update(Long id, Long version) { def bookChapterInstance = BookChapter.get(id) boolean isReturned = aux.check(id, bookChapterInstance, 'bookChapter.label', 'BookChapter') - if(!isReturned){ + if (!isReturned) { if (version != null && bookChapterInstance.version > version) { outdatedVersionError((BookChapter) bookChapterInstance) - }else{ + } else { saveUpdate((BookChapter) bookChapterInstance) } } @@ -82,7 +74,7 @@ class BookChapterController { render(view: "edit", model: [bookChapterInstance: bookChapterInstance]) } - def saveUpdate(BookChapter bookChapterInstance){ + def saveUpdate(BookChapter bookChapterInstance) { bookChapterInstance.properties = params if (!bookChapterInstance.save(flush: true)) { render(view: "edit", model: [bookChapterInstance: bookChapterInstance]) @@ -92,8 +84,10 @@ class BookChapterController { } } - def delete(Long id) { - def bookChapterInstance = BookChapter.get(id) - aux.delete(id, bookChapterInstance, 'bookChapter.label', 'BookChapter'); - } + def delete(Long id) { + 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 2411a5b3..f4235b3a 100644 --- a/grails-app/domain/rgms/member/Orientation.groovy +++ b/grails-app/domain/rgms/member/Orientation.groovy @@ -10,22 +10,23 @@ class Orientation { String instituicao String curso + static constraints = { - tipo(nullable: false, blank: false, inList: ["Mestrado","Doutorado","Iniciação Científica"]) + tipo(nullable: false, blank: false, inList: ["Mestrado", "Doutorado", "Iniciação Científica"]) orientando(nullable: false) orientador(nullable: false) - tituloTese(nullable: false, blank: false,unique: true) - 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) - { + boolean Equals(Orientation other) { return (other != null && this.anoPublicacao == other.anoPublicacao - && this.orientador == other.orientador - && this.orientando == other.orientando - && this.tipo == other.tipo - && this.tituloTese == other.tituloTese) + && this.orientador == other.orientador + && this.orientando == other.orientando + && this.tipo == other.tipo + && this.tituloTese == other.tituloTese) } } -//#end \ No newline at end of file +//#end diff --git a/grails-app/domain/rgms/publication/BookChapter.groovy b/grails-app/domain/rgms/publication/BookChapter.groovy index d9b8d5b6..6fa832ff 100644 --- a/grails-app/domain/rgms/publication/BookChapter.groovy +++ b/grails-app/domain/rgms/publication/BookChapter.groovy @@ -4,11 +4,11 @@ package rgms.publication class BookChapter extends Publication { String publisher - int chapter - + int chapter + static constraints = { - publisher nullable: false, blank: false - chapter nullable: false, blank: false, min: 1 + publisher nullable: false, blank: false, unique: ['title', 'file', 'chapter'] + chapter nullable: false, blank: false, min: 1 } //#if($Bibtex) 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 7994da79..a1f9d5ee 100644 --- a/test/cucumber/Orientation.feature +++ b/test/cucumber/Orientation.feature @@ -5,44 +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 an 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 by 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 - 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 + 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 - Scenario: create duplicated orientation + #3 + Scenario: create orientation web with invalid year Given I am at the create orientation page - And the system has thesis entitled "The Book is on the table" supervised by someone - When I fill the orientation title with "The Book is on the table" - Then I am on the orientation show page with the error message - -#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 + 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 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 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..f628b9b9 100644 --- a/test/cucumber/steps/BookChapterSteps.groovy +++ b/test/cucumber/steps/BookChapterSteps.groovy @@ -1,11 +1,10 @@ -import pages.* -import cucumber.runtime.PendingException -import rgms.member.Member +import pages.BookChapterCreatePage +import pages.BookChapterPage +import pages.LoginPage +import pages.PublicationsPage import rgms.publication.BookChapter -import rgms.publication.Periodico -import steps.TestDataAndOperations -import steps.TestDataAndOperationsPublication import steps.BookChapterTestDataAndOperations +import steps.TestDataAndOperationsPublication import static cucumber.api.groovy.EN.* @@ -41,12 +40,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 +59,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 +81,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 +94,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 +127,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 +136,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 a337e70f..b8b1b230 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,6 +61,9 @@ 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$') { -> + at RegisterPage +} Given(~'^the system has member with username "([^"]*)"$') { String username -> @@ -103,7 +106,7 @@ Then(~'^the member named "([^"]*)" is not registered$') { String name -> } -Given(~'^I am at the create member page$') {-> +Given(~'^I am at the create member page$') { -> to LoginPage at LoginPage page.fillLoginData("admin", "adminadmin") @@ -119,7 +122,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 } @@ -134,7 +137,7 @@ Then(~'^I am on the member show page$') {-> }*/ //TODO verificação teria que ser específica, bem menos parcial do que a abaixo -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 @@ -148,7 +151,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 } @@ -164,22 +167,22 @@ 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) } Given(~'^the system has member with email "([^"]*)"$') { String email -> String name = "Rodolfo" - MemberTestDataAndOperations.createMemberWithEmail(name,email) + MemberTestDataAndOperations.createMemberWithEmail(name, email) member = Member.findByEmail(email) assert member.name == name } @@ -188,5 +191,4 @@ When(~'^I try to create the member "([^"]*)" with email "([^"]*)"$') { String na MemberTestDataAndOperations.createMemberWithEmail(name, email) //member = Member.findByEmail(email) //assert member.name == name -} - +} \ No newline at end of file diff --git a/test/cucumber/steps/OrientationSteps.groovy b/test/cucumber/steps/OrientationSteps.groovy index f6508230..eca4e4f3 100644 --- a/test/cucumber/steps/OrientationSteps.groovy +++ b/test/cucumber/steps/OrientationSteps.groovy @@ -1,16 +1,18 @@ -import cucumber.runtime.PendingException -import pages.OrientationPages.* -import pages.* +import org.apache.shiro.SecurityUtils +import org.apache.shiro.subject.Subject +import org.apache.shiro.util.ThreadContext +import pages.LoginPage +import pages.OrientationPages.OrientationCreatePage +import pages.OrientationPages.OrientationEditPage +import pages.OrientationPages.OrientationShowPage +import pages.OrientationPages.OrientationsPage +import pages.PublicationsPage +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 -import org.apache.shiro.subject.Subject -import org.apache.shiro.SecurityUtils - import static cucumber.api.groovy.EN.* // create @@ -20,115 +22,136 @@ Given(~'^the system has no orientations entitled "([^"]*)"$') { String tituloTes assert orientation == null } -When(~'^I create an 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 by 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 @@ -136,34 +159,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") } - -Then(~'^I am on the orientation show page with the error message$') { -> - at OrientationShowPage - //assert (new GetPageTitle()).msg("orientation.tituloTese.unique") == page.readFlashMessage() - assert page.readFlashMessage() != null -} \ No newline at end of file diff --git a/test/cucumber/steps/ThesisSteps.groovy b/test/cucumber/steps/ThesisSteps.groovy index c3c5e013..e1c270fc 100644 --- a/test/cucumber/steps/ThesisSteps.groovy +++ b/test/cucumber/steps/ThesisSteps.groovy @@ -1,33 +1,31 @@ -import rgms.authentication.User -import steps.ThesisTestDataAndOperations +import org.codehaus.groovy.grails.web.context.ServletContextHolder import pages.LoginPage +import pages.PublicationsPage +import pages.ThesisPage import pages.thesis.ThesisCreatePage import pages.thesis.ThesisShowPage +import rgms.authentication.User import rgms.publication.Tese import steps.TestDataAndOperationsPublication -import pages.ThesisPage -import rgms.member.Member - -import java.io.File +import steps.ThesisTestDataAndOperations import static cucumber.api.groovy.EN.* -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) - assert article != null + ThesisTestDataAndOperations.createTese(title, filename, "UFPE") + article = Tese.findByTitle(title) + assert article != null } 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 +38,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 +48,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 +77,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..1700fba8 100644 --- a/test/functional/pages/BookChapterPage.groovy +++ b/test/functional/pages/BookChapterPage.groovy @@ -24,10 +24,10 @@ class BookChapterPage extends Page { $('a.create').click() } - def checkBookChapterAtList(title,row){ + def checkBookChapterAtList(title, row) { def listDiv = $('div', id: 'list-bookChapter') def bookTable = (listDiv.find('table'))[0] - def bookRows = bookTable.find('tbody').find('tr') + def bookRows = bookTable.find('tbody').find('tr') def bookColumns = bookRows[row].find('td') def testarbook = BookChapter.findByTitle(title) @@ -38,16 +38,21 @@ class BookChapterPage extends Page { assert bookColumns[4].text() == testarbook.publisher } - def uploadWithoutFile(){ + def uploadWithoutFile() { $('input.save').click() } - def checkIfBookChapterListIsEmpty(){ + def checkIfBookChapterListIsEmpty() { def listDiv = $('div', id: 'list-bookchapter') def bookChapterTable = (listDiv.find('table'))[0] - def bookChapterRows = bookChapterTable.find('tbody').find('tr') + def bookChapterRows = bookChapterTable.find('tbody').find('tr') def bookChapterColumns = bookChapterRows[0].find('td') 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..b8896894 --- /dev/null +++ b/test/functional/pages/BookChapterSavePage.groovy @@ -0,0 +1,16 @@ +package pages + +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..4099a4d9 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..4d7de4d1 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 editTituloTese(String novovalor) { + $("form").tituloTese = novovalor } - static content = { + def editYear(String newYear) { + $("form").anoPublicacao = Integer.parseInt(newYear) } - def edit(String novovalor){ + def select(String s) { + $("form").find("input", value: s).click() + } + + def confirmEdit() { + $('input', class: 'save').click() + } - $("form").tituloTese = novovalor - $("form").save().click() + def delete() { + assert withConfirm(true) { $("form").find('input', class: 'delete').click() } } - - def select(String s) { - $("form").find("input", value: s).click() - } + } diff --git a/test/functional/pages/OrientationPages/OrientationShowPage.groovy b/test/functional/pages/OrientationPages/OrientationShowPage.groovy index eddb902c..7f680fea 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,12 +18,27 @@ class OrientationShowPage extends Page { } static content = { - readFlashMessage(){ $("div .message").text() } + 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..0d8c91f8 100644 --- a/test/functional/pages/OrientationPages/OrientationsPage.groovy +++ b/test/functional/pages/OrientationPages/OrientationsPage.groovy @@ -8,59 +8,62 @@ class OrientationsPage extends Page { static url = "orientation/list" - static at = { - //title ==~ /Orientation Listagem/ + static at = { - GetPageTitle gp = new GetPageTitle() - def currentOrientation = gp.msg("default.orientation.label") - def currentTitle = gp.msg("default.list.label", [currentOrientation]) - - title ==~ currentTitle - } - - static content = { - } + //title ==~ /Orientation Listagem/ + GetPageTitle gp = new GetPageTitle() + def currentOrientation = gp.msg("default.orientation.label") + def currentTitle = gp.msg("default.list.label", [currentOrientation]) - def selectNewOrientation() { - $('a.create').click() - } + title ==~ currentTitle + } + static content = { + flashmessage { + $("div", class: "message") + } + } + def selectNewOrientation() { + $('a', class: 'create').click() + } + def selectViewOrientation(title) { - def getRow(){ + def id = Orientation.findByTituloTese(title).id + $("a", text: id.toString()).click() - 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 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 selectViewOrientation(title) { - getRow() - def showLink = getRow().find('td').find([text:title]) - showLink.click() - } - - - def checkOrientationAtList(title,row){ + def checkOrientationAtList(title, row) { def orientationColumns = getRow()[row].find('td') def testorientation = Orientation.findByTituloTese(title) - assert orientationColumns[1].text() == testorientation.tipo - assert orientationColumns[2].text() == testorientation.orientando - assert orientationColumns[4].text() == testorientation.tituloTese - } + assert orientationColumns[1].text() == testorientation.tipo + assert orientationColumns[2].text() == testorientation.orientando + assert orientationColumns[4].text() == testorientation.tituloTese + } - def checkIfOrientationListIsEmpty(){ + def checkIfOrientationListIsEmpty() { def conferenciaColumns = getRow()[0].find('td') assert conferenciaColumns.size() < 8 } - def uploadWithoutFile(){ + def uploadWithoutFile() { $('input.save').click() } } diff --git a/test/functional/pages/ThesisPage.groovy b/test/functional/pages/ThesisPage.groovy index eb1995f0..61eca4bb 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..de6563b0 100644 --- a/test/functional/pages/thesis/ThesisCreatePage.groovy +++ b/test/functional/pages/thesis/ThesisCreatePage.groovy @@ -1,32 +1,32 @@ package pages.thesis -import pages.GetPageTitle import pages.FormPage +import pages.GetPageTitle class ThesisCreatePage extends FormPage { - static url = "tese/create" + static url = "tese/create" - static at = { + static at = { GetPageTitle gp = new GetPageTitle() def currentTese = gp.msg("default.tese.label") def currentTitle = gp.msg("default.create.label", [currentTese]) title ==~ currentTitle - } + } - static content = { - /*journal { - $("input", id: "journal") - }*/ - } + static content = { + /*journal { + $("input", id: "journal") + }*/ + } - def fillThesisDetails(title, pub_day, pub_month, pub_year, school, address, path) { + def fillThesisDetails(title, pub_day, pub_month, pub_year, school, address, path) { $("form").file = path fillSomeThesisDetails(title, pub_day, pub_month, pub_year, school, address) } def fillSomeThesisDetails(title, pub_day, pub_month, pub_year, school, address) { $("form").title = title - $("form").publicationDate_day = pub_day + $("form").publicationDate_day = pub_day $("form").publicationDate_month = pub_month $("form").publicationDate_year = pub_year $("form").school = school @@ -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..75da2a0b --- /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..ef66f6b1 100644 --- a/test/functional/pages/thesis/ThesisShowPage.groovy +++ b/test/functional/pages/thesis/ThesisShowPage.groovy @@ -11,10 +11,17 @@ class ThesisShowPage extends Page { def currentTese = gp.msg("default.tese.label") def currentTitle = gp.msg("default.show.label", [currentTese]) title ==~ currentTitle - } - + } + 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 de72082c..01345ddb 100644 --- a/test/functional/steps/MemberTestDataAndOperations.groovy +++ b/test/functional/steps/MemberTestDataAndOperations.groovy @@ -20,6 +20,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) { @@ -40,7 +43,7 @@ class MemberTestDataAndOperations { def cont = new MemberController() if (phone.equals("")) { cont.params << findByUsername(username) - }else{ + } else { cont.params << [username: username, phone: phone] } cont.create() @@ -63,17 +66,16 @@ 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) { def cont = new MemberController() def result = cont.list().userMemberInstanceList - for(i in result){ - if(i.user.username == username && i.member != null) + for (i in result) { + if (i.user.username == username && i.member != null) return true; } return false; } -} \ No newline at end of file +} 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 @@ + + + + + + + + + rgms/test/functional/steps/NewthesisGUI.txt at master · macenas/rgms + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+ + + + + +
+ + + + + +
+ + +
+
+ + + + + +
+ + This repository + + +
+
+ +
+ + +
This repository
+
+ +
+ + +
All repositories
+
+ +
+
+
+ + + + + + + + +
+ +
+ + + + + + + + + + + + +
+
+ + + + + + + + +
+ +
+
+ + +
    + +
  • +
    + +
    + + + + + Unwatch + + + +
    +
    +
    + Notification status + +
    + +
    + +
    + +
    + +

    Not watching

    + You only receive notifications for discussions in which you participate or are @mentioned. + + + Watch + +
    +
    + +
    + +
    + +

    Watching

    + You receive notifications for all discussions in this repository. + + + Unwatch + +
    +
    + +
    + +
    + +

    Ignoring

    + You do not receive any notifications for discussions in this repository. + + + Stop ignoring + +
    +
    + +
    + +
    +
    +
    + +
    +
  • + +
  • + + + +
  • + + +
  • + + Fork + + +
  • + + +
+ +

+ public + + + /rgms + + + Octocat-spinner-32 + + + + forked from spgroup/rgms + +

+
+
+ +
+ +
+ +
+ + + + +
+ + + + +
+

HTTPS clone URL

+ + + + +
+ + + +
+

SSH clone URL

+ + + + +
+ + + +
+

Subversion checkout URL

+ + + + +
+ + + +

You can clone with + HTTPS, + SSH, + Subversion, + and other methods. +

+ + + + + Clone in Desktop + + + + + Download ZIP + +
+
+ +
+ + + + + + + + +Show File Finder + +
+ + + +
+ + + branch: + master + + +
+ +
+
+ Switch branches/tags + +
+ +
+
+ +
+
+ +
+
+ +
+ +
+ + +
+ + master +
+
+ +
+ +
+

Create branch:

+ from ‘master’ +
+ + + +
+ +
+ +
+
+ + +
+ +
Nothing to show
+
+ +
+
+
+ + +
+ + +
+ Fetching contributors… + +
+

Octocat-spinner-32-eaf2f5

+

Cannot retrieve contributors at this time

+
+
+ +
+
+
+
+ + file + 25 lines (20 sloc) + 1.017 kb +
+ + +
+
+ + + + + +
+ 1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 + + +
@i9n
Feature: Thesis Tests
  As a member of a research group
  I want to add, remove and modify theses I have added

  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
    
  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: create thesis web
    Given I am at the create thesis page
    When I fill the thesis details
    Then I am on the thesis show page

  Scenario: create thesis web with partial information
    Given I am at the create thesis page
    When I fill some thesis details
    Then I am still on the create thesis page with the error message
+
+
+ +
+
+ + + + +
+ +
+ +
+
+ + +
+ +
+ +
+ + +
+
+
+ +
+
+
+
+
+
+
+ + + + + + +
+
+ + + +
+ + + Something went wrong with that request. Please try again. +
+ + + + + diff --git a/test/functional/steps/OrientationTestDataAndOperations.groovy b/test/functional/steps/OrientationTestDataAndOperations.groovy index 337e478e..ea5a3ee1 100644 --- a/test/functional/steps/OrientationTestDataAndOperations.groovy +++ b/test/functional/steps/OrientationTestDataAndOperations.groovy @@ -1,6 +1,7 @@ package steps import rgms.member.Member +import rgms.member.Orientation import rgms.member.OrientationController import rgms.publication.XMLController @@ -8,7 +9,7 @@ import rgms.publication.XMLController * Created with IntelliJ IDEA. * User: tasj * Date: 30/08/13 - * Time: 15:31 + * Time: 15:3 * To change this template use File | Settings | File Templates. */ class OrientationTestDataAndOperations { @@ -19,6 +20,9 @@ class OrientationTestDataAndOperations { ], [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 orientations = [ @@ -34,16 +38,29 @@ class OrientationTestDataAndOperations { static public void createOrientation(String tituloTese) { def cont = new OrientationController() - cont.params << [tipo: "Mestrado", orientando: "Tomaz", tituloTese: tituloTese, anoPublicacao: 2013, instituicao: "UFPE", orientador: (new Member(members[0]))] + def memberCreater = new Member(members[0]) + memberCreater.create() + memberCreater.save() + def member = Member.findByName(memberCreater.name) + cont.params << [tipo: "Mestrado", orientando: "Tomaz", tituloTese: tituloTese, anoPublicacao: 2013, instituicao: "UFPE", orientador: member] cont.request.setContent(new byte[1000]) // Could also vary the request content. cont.create() cont.save() cont.response.reset() } - static public void removeOrientation(String tituloTese) { + static public void createOrientationWithMenber(String tituloTese, member) { - def testOrientation = OrientationTestDataAndOperations.findOrientationByTitle(tituloTese) + def cont = new OrientationController() + cont.params << [tipo: "Mestrado", orientando: "Tomaz", tituloTese: tituloTese, anoPublicacao: 2013, instituicao: "UFPE", orientador: new Member(member)] + cont.request.setContent(new byte[1000]) // Could also vary the request content. + cont.create() + cont.save() + cont.response.reset() + } + + static public void removeOrientation(String tituloTese) { + def testOrientation = Orientation.findByTituloTese(tituloTese) def cont = new OrientationController() cont.params << [id: testOrientation.id] cont.delete() diff --git a/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy b/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy index f6fe0afc..251a22dd 100644 --- a/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy +++ b/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy @@ -1,5 +1,9 @@ package steps +import rgms.publication.Dissertacao +import rgms.publication.Tese +import rgms.publication.TeseController + class ThesisOrDissertationTestDataAndOperations { static protected void createThesisOrDissertation(String title, filename, school, cont) { @@ -12,4 +16,15 @@ class ThesisOrDissertationTestDataAndOperations { cont.response.reset() } + static protected void deleteThesisOrDissertation(String title, cont) { + def test + if (cont instanceof TeseController) { + test = Tese.findByTitle(title) + } else { + test = Dissertacao.findByTitle(title) + } + cont.params << [id: test.id] + cont.delete() + + } } diff --git a/test/functional/steps/ThesisTestDataAndOperations.groovy b/test/functional/steps/ThesisTestDataAndOperations.groovy index c89740fe..75fb4d1d 100644 --- a/test/functional/steps/ThesisTestDataAndOperations.groovy +++ b/test/functional/steps/ThesisTestDataAndOperations.groovy @@ -1,6 +1,6 @@ package steps -import rgms.publication.* +import rgms.publication.TeseController class ThesisTestDataAndOperations { @@ -9,4 +9,9 @@ class ThesisTestDataAndOperations { ThesisOrDissertationTestDataAndOperations.createThesisOrDissertation(title, filename, school, cont) } + static public void deleteTeseByTitle(String title) { + def cont = new TeseController() + ThesisOrDissertationTestDataAndOperations.deleteThesisOrDissertation(title, cont) + } + }