-
+
- data-field-id="${error.field}">
diff --git a/application.properties b/application.properties
index e6246333..129a61b3 100644
--- a/application.properties
+++ b/application.properties
@@ -1,5 +1,5 @@
#Grails Metadata file
-#Thu Jun 06 10:16:12 GMT-03:00 2013
+#Mon Oct 27 15:36:21 GMT-03:00 2014
app.grails.version=2.1.0
app.name=rgms
app.servlet.version=2.5
diff --git a/grails-app/conf/BuildConfig.groovy b/grails-app/conf/BuildConfig.groovy
index 42066943..26347d30 100644
--- a/grails-app/conf/BuildConfig.groovy
+++ b/grails-app/conf/BuildConfig.groovy
@@ -39,6 +39,7 @@ grails.project.dependency.resolution = {
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
+ compile 'commons-codec:commons-codec:1.6'
test("org.codehaus.geb:geb-junit4:$gebVersion")
test("org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion")
test("org.seleniumhq.selenium:selenium-support:$seleniumVersion")
diff --git a/grails-app/controllers/rgms/publication/BookController.groovy b/grails-app/controllers/rgms/publication/BookController.groovy
index eab9da7a..ac874446 100644
--- a/grails-app/controllers/rgms/publication/BookController.groovy
+++ b/grails-app/controllers/rgms/publication/BookController.groovy
@@ -28,14 +28,7 @@ class BookController {
bookInstance = pb.extractAuthors(bookInstance)
-
- if (!bookInstance.save(flush: true)) {
- render(view: "create", model: [bookInstance: bookInstance])
- return
- }
-
- flash.message = message(code: 'default.created.message', args: [message(code: 'book.label', default: 'Book'), bookInstance.id])
- redirect(action: "show", id: bookInstance.id)
+ saveAndNotify(bookInstance, "create", 'default.created.message')
}
def show(Long id) {
@@ -80,12 +73,16 @@ class BookController {
bookInstance.properties = params
+ saveAndNotify(bookInstance, "edit", 'default.updated.message')
+ }
+
+ private saveAndNotify(Book bookInstance, viewParameter, codeParameter ) {
if (!bookInstance.save(flush: true)) {
- render(view: "edit", model: [bookInstance: bookInstance])
+ render(view: viewParameter, model: [bookInstance: bookInstance])
return
}
- flash.message = message(code: 'default.updated.message', args: [message(code: 'book.label', default: 'Book'), bookInstance.id])
+ flash.message = message(code: codeParameter, args: [message(code: 'book.label', default: 'Book'), bookInstance.id])
redirect(action: "show", id: bookInstance.id)
}
diff --git a/grails-app/domain/rgms/member/Orientation.groovy b/grails-app/domain/rgms/member/Orientation.groovy
index 800e5020..113bdb46 100644
--- a/grails-app/domain/rgms/member/Orientation.groovy
+++ b/grails-app/domain/rgms/member/Orientation.groovy
@@ -30,6 +30,22 @@ class Orientation {
}
+ static public def isFiltered(orientations,typeof) {
+ for (orientation in orientations) {
+ if(!(orientation.tipo).contains(typeof))
+ return false
+ }
+ return true
+ }
+
+ static public def isFiltered(orientations,supervised, tipo) {
+ for (orientation in orientations) {
+ if(!(orientation.orientador).contains(supervised))
+ return false
+ }
+ return true
+ }
+
String toString() {
return "Titulo = " + this.tituloTese + "; Orientador = " + this.orientador + "; Orientando: " + this.orientando
}
diff --git a/grails-app/i18n/META-INF/MANIFEST.MF b/grails-app/i18n/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..15007978
--- /dev/null
+++ b/grails-app/i18n/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: rgms.ShiroDbRealm
+
diff --git a/grails-app/i18n/messages.properties b/grails-app/i18n/messages.properties
index 05c696f1..d69565b1 100644
--- a/grails-app/i18n/messages.properties
+++ b/grails-app/i18n/messages.properties
@@ -229,3 +229,6 @@ default.researchproject.import.flashmessage.success = "The non existent Research
#if($researchLine)
default.researchline.import.flashmessage.success = "The non existent Research Line were successfully imported"
#end
+
+#if($magazinePublication)
+magazinePublication.label = "Magazine Publication"
\ No newline at end of file
diff --git a/grails-app/i18n/messages_pt_BR.properties b/grails-app/i18n/messages_pt_BR.properties
index 6d3cc59d..16d02e0a 100644
--- a/grails-app/i18n/messages_pt_BR.properties
+++ b/grails-app/i18n/messages_pt_BR.properties
@@ -223,4 +223,5 @@ default.researchproject.import.flashmessage.success = "Os Projetos de Pesquisa n
#if($researchLine)
default.researchline.import.flashmessage.success = "As linhas de pesquisa que não existiam foram importadas com sucesso"
-#end
\ No newline at end of file
+#end
+
diff --git a/grails-app/views/book/_errors.gsp b/grails-app/views/book/_errors.gsp
new file mode 100644
index 00000000..a293139a
--- /dev/null
+++ b/grails-app/views/book/_errors.gsp
@@ -0,0 +1,10 @@
+
+
+
${fieldValue(bean: magazinePublicationInstance, field: "number")} | + +${fieldValue(bean: magazinePublicationInstance, field: "page")} | + +${fieldValue(bean: magazinePublicationInstance, field: "place")} | + +${fieldValue(bean: magazinePublicationInstance, field: "month")} | + +${fieldValue(bean: magazinePublicationInstance, field: "year")} | + +
Information gathered from the controller: ${randomString}
+ +ID | +Name | +Age | +
---|---|---|
${id} | +${name} | +${age} | +
styled with css... | +
Favorite food: ${pdf?.food}
+Favorite food: ${pdf?.food.toString()}
+Hometown: ${pdf?.hometown}
+ +${pdf}
+ +Images with relative URL's are automatically resolved by the the modified version of XHTMLrenderer included with the plugin
+ + +Images with absolute URI's also do just fine:
+ + +Hint: One way to style gsp's that you intend to make into pdf's is to have two seperate style sheets one for media="print" and one for media="screen". The print style sheet will be used to style the PDF, and if PDF generation fails you will get a styled HTML view that isn't all weird because of fonts sized in pt and such.
+ + diff --git a/grails-app/views/pdf/demo.gsp b/grails-app/views/pdf/demo.gsp new file mode 100644 index 00000000..2abd5023 --- /dev/null +++ b/grails-app/views/pdf/demo.gsp @@ -0,0 +1,342 @@ + + + + +Description | +Sample Source/HTML output | +In Action | +
---|---|---|
URL method examples: | ||
Simple Usage: | +
+ <g:pdfLink url="/pdf/demo2">PDF View</g:pdfLink>
+ |
+
+ |
+
+
+ <a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2">
+ |
+ ||
Simple Usage w/ Get data: | +
+ <g:pdfLink url="/pdf/demo2/5?name=bob&age=22">PDF View</g:pdfLink>
+ |
+
+ |
+
+
+ <a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2%2F5%3Fname%3Dbob%26age%3D22">
+ |
+ ||
Custom filename | +
+ <g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf">sample.pdf</g:pdfLink>
+ |
+
+ |
+
+
+ <a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2.gsp&filename=sample.pdf">
+ |
+ ||
Bundled icon | +
+ <g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf" icon="true"/>
+ |
+
+ |
+
+
+ <a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2.gsp&filename=sample.pdf">
+ |
+ ||
Bundled icon w/ link content | +
+ <g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf" icon="true" class="myPdfLink">Custom link</g:pdfLink>
+ |
+
+ |
+
+
+ <a class="myPdfLink" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2.gsp&filename=sample.pdf">
+ |
+ ||
String method examples: | ||
Simple Template Usage: | +
+ <g:pdfLink template="demo2">template as PDF</g:pdfLink>
+ |
+
+ |
+
+
+ <a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?template=demo2&filename=document.pdf">
+ |
+ ||
Simple Controller Action Usage (action and id are optional): | +
+ <g:pdfLink pdfController="pdf" pdfAction="demo2">GSP as PDF</g:pdfLink>
+ |
+
+ |
+
+
+ <a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?&pdfController=pdf&pdfAction=demo2">
+ |
+ ||
Simple Controller Action + Id Usage: | +
+ <g:pdfLink pdfController="pdf" pdfAction="demo2" pdfId="65432">GSP as PDF</g:pdfLink>
+ |
+
+ |
+
+
+ <a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?&pdfController=pdf&pdfAction=demo2&pdfId=65432">
+ |
+
Description | +Sample Source/HTML output | +In Action | +
---|---|---|
GET method examples: | ||
Simple Usage: | +
+ <g:pdfForm url="/pdf/demo2">...</g:pdfForm>
+ |
+
+ + |
+
+
+ <form id="simplePdfForm" method="get" action="/pdf/pdf/pdfForm" name="simplePdfForm">
+ |
+ ||
w/ Id and Filename: | +
+ <g:pdfForm url="/pdf/demo2/1968" filename="sample.pdf">...</g:pdfForm>
+ |
+
+ + |
+
+
+ <form id="simplePdfForm" method="get" action="/pdf/pdf/pdfForm" name="simplePdfForm">
+ |
+ ||
POST method examples: | ||
Controller and Action: | +
+ <g:pdfForm controller="pdf" action="demo3" method="post">...</g:pdfForm>
+ |
+
+ + |
+
+
+ <form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm" name="simplePdfForm">
+ |
+ ||
Controller, Action, Id and Filename: | +
+ <g:pdfForm controller="pdf" action="demo3" method="post">...</g:pdfForm>
+ |
+
+ + |
+
+
+ <form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm" name="simplePdfForm">
+ |
+ ||
Template: | +
+ <g:pdfForm template="demo2" >...</g:pdfForm>
+ |
+
+ + |
+
+
+ <form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm2" name="simplePdfForm">
+ |
+ ||
Template and Filename: | +
+ <g:pdfForm template="demo2" filename="sample.pdf">...</g:pdfForm>
+ |
+
+ + |
+
+
+ <form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm2" name="simplePdfForm">
+ |
+
Information gathered from the controller: ${randomString}
+ +ID | +Name | +Age | +
---|---|---|
${id} | +${name} | +${age} | +
styled with css... | +
Images with relative URL's are automatically resolved by the the modified version of XHTMLrenderer included with the plugin
+ + +Images with absolute URI's also do just fine:
+ + +Hint: One way to style gsp's that you intend to make into pdf's is to have two seperate style sheets one for media="print" and one for media="screen". The print style sheet will be used to style the PDF, and if PDF generation fails you will get a styled HTML view that isn't all weird because of fonts sized in pt and such.
+ + diff --git a/grails-app/views/pdf/demo3.gsp b/grails-app/views/pdf/demo3.gsp new file mode 100644 index 00000000..7d7140c9 --- /dev/null +++ b/grails-app/views/pdf/demo3.gsp @@ -0,0 +1,73 @@ + + + + +Information gathered from the controller: ${randomString}
+ +ID | +Name | +Age | +
---|---|---|
${id} | +${name} | +${age} | +
styled with css... | +
Favorite food: ${pdf?.food}
+Favorite food: ${pdf?.food.toString()}
+Hometown: ${pdf?.hometown}
+ +${pdf}
+ +Images with relative URL's are automatically resolved by the the modified version of XHTMLrenderer included with the plugin
+ + +Images with absolute URI's also do just fine:
+ + +Hint: One way to style gsp's that you intend to make into pdf's is to have two seperate style sheets one for media="print" and one for media="screen". The print style sheet will be used to style the PDF, and if PDF generation fails you will get a styled HTML view that isn't all weird because of fonts sized in pt and such.
+ +Varialbles passed into gsp that the plugin will render as PDF need to start with pdf. so for example the form field name was hometown and to reference that varialbe here we needed {pdf.hometown}
+
+ ${content}
+
+
+
diff --git a/grails-app/views/pdf/sampleInclude.gsp b/grails-app/views/pdf/sampleInclude.gsp
new file mode 100644
index 00000000..2938d1c8
--- /dev/null
+++ b/grails-app/views/pdf/sampleInclude.gsp
@@ -0,0 +1,10 @@
+
+
+
+
+ ${bar}
+${today}
+${tomorrow}
+ + diff --git a/test/cucumber/Article.feature b/test/cucumber/Article.feature index 01606f0d..b1fc1660 100644 --- a/test/cucumber/Article.feature +++ b/test/cucumber/Article.feature @@ -27,10 +27,32 @@ Feature: journal article Scenario: new article web Given I am at the publications menu + And I want to add a new article + Then I can fill the article details + + Scenario: new article web + Given I am at the publications menu When I select the "Periodico" option at the publications menu And I select the new article option at the article page Then I can fill the article details +#if ($publicationInformationController) + Scenario: new article web with publication + Given I am at the article page + And I want to add a new article + Then I can fill the article details + And It may include the "publication" information +#end + +#if ($publicationInformation) + Scenario: new article web with publication + Given I am at the article page + When I select the "Periodico" option + And I select the 'new article' option + Then I can fill the article details + And It may include the option "publication" information +#end + Scenario: remove existing article Given the system has article entitled "A theory of software product line refinement" with file name "TCS-44.pdf" When I delete the article "A theory of software product line refinement" @@ -101,7 +123,24 @@ Feature: journal article When I share the article entitled "A theory of software product line refinement" on facebook Then A facebook message was posted - Scenario: Post an existing article on facebook web +#if ($postPublicationInformation) + Scenario: Post an existing article publication on facebook web + Given I am at the articles page and the article "A theory of software product line refinement 3" is stored in the system with file name "TCS-04.pdf" + When I select to view "A theory of software product line refinement 3" in resulting list + And I choose to share the "Publicacao" of this article on Facebook + And I click on 'Share publicacao' on Facebook + Then A facebook message is posted + #end + +#if ($postPublicationInformationController) + Scenario: Post an existing article publication on facebook web + Given I am at the articles page and the article "A theory of software product line refinement 3" is stored in the system with file name "TCS-04.pdf" + When I choose to share the "Publicacao" of this article on Facebook + And I go to this section in the page and click on share + Then A facebook message is posted + #end + + Scenario: Post an existing article on facebook web Given I am at the articles page and the article "A theory of software product line refinement 3" is stored in the system with file name "TCS-04.pdf" When I select to view "A theory of software product line refinement 3" in resulting list And I click on Share on Facebook diff --git a/test/cucumber/Book.feature b/test/cucumber/Book.feature index 3624ed38..08024465 100644 --- a/test/cucumber/Book.feature +++ b/test/cucumber/Book.feature @@ -34,4 +34,48 @@ Feature: Book And the system has no book entitled "Next Generation Software Product Line Engineering" When I go to new book page And I use the webpage to create the book "Next Generation Software Product Line Engineering" with file name "Ngs.pdf" - Then the book "Next Generation Software Product Line Engineering" was stored by the system \ No newline at end of file + Then the book "Next Generation Software Product Line Engineering" was stored by the system + + +#if($updateExistingBook) + Scenario: update existing book + Given the book "SPL Development" is stored in the system with file name "HSPLE.pdf" + When I upload the file in the system with name "newHSPLE.pdf" + Then the book "SPL Development" has the archive file "newHSPLE.pdf" updated by the system +#end + + #if($updateExistingBookWeb) + Scenario: update existing book web + Given the system has the book entitled "SPL Development" with file name "HSPLE.pdf" + And I am at the book page + When I edit the book "SPL Development" file name from "HSPLE.pdf" to "newHSPLE.pdf" + Then I have the book entitled "SPL Development" with file name "newHSPLE.pdf" stored on the system +#end + +#if($newBookWithoutFile) + Scenario: new book without file + Given the system has no book entitled "SPL Development" + When I try to create the book "SPL Development" without file + Then the book "SPL Development" is not stored by the system +#end + +#if($newBookWithoutFileWeb) + Scenario: new book without file web + Given I am at the book page + And the system has no book entitled "Design de Interação" + When I go to new book page + And I use the webpage to create the book "Design de Interação" with file name "" + Then I should see an error message containing "Book without file, it is mandatory" +#end + + Scenario: list existing book web + Given I am at the book page + And the system has the book entitled "Next Generation Software Product Line Engineering" with file name "Ngs.pdf" + Then the book list contains "Next Generation Software Product Line Engineering" + + Scenario: remove existing book web + Given I am at the book page + And the system has the book entitled "Next Generation Software Product Line Engineering" with file name "Ngs.pdf" + When I choose to view "Next Generation Software Product Line Engineering" in book list + And I press to remove at the book show page + Then the book "Next Generation Software Product Line Engineering" is removed from the system \ No newline at end of file diff --git a/test/cucumber/BookChapter.feature b/test/cucumber/BookChapter.feature index 9f21361b..97141923 100644 --- a/test/cucumber/BookChapter.feature +++ b/test/cucumber/BookChapter.feature @@ -6,7 +6,7 @@ Feature: BookChapter Scenario: new book chapter Given the system has no book chapter entitled "SPL Development" - When I create the book chapter "SPL Development" with file name "HSPLE.pdf" + When I create the book chapter "SPL Development" with file name "HSPLE.pdf" and publication date "21/11/2014" Then the book chapter "SPL Development" is properly stored by the system Scenario: duplicate book chapter @@ -72,3 +72,15 @@ Feature: BookChapter And I select the upload button at the book chapter page Then I'm still on book chapter page And the book chapters are not stored by the system + + Scenario: filter existing book chapter by title + Given the system has some book chapter entitled by "Next Generation Software Product Line Engineering" + When the system filter the book chapter entitled by title "Next Generation Software Product Line Engineering" + Then the system book chapter list content is not modified + + Scenario: filter existing book chapter by title web + Given I am at the book chapter page + And I create some book chapter entitled by "Next Generation Software Product Line Engineering" + When I select to view the list of book chapters + And I select to filter the list of book chapter by title "Next Generation Software Product Line Engineering" + Then my book chapter list shows only the book chapters entitled by "Next Generation Software Product Line Engineering" diff --git a/test/cucumber/Dissertacao.feature b/test/cucumber/Dissertacao.feature index 98a20dd2..5afc8355 100644 --- a/test/cucumber/Dissertacao.feature +++ b/test/cucumber/Dissertacao.feature @@ -29,7 +29,7 @@ Feature: Dissertation Tests Scenario: new dissertation duplicated Given the dissertation "Dissertation duplicated" is stored in the system with file name "Dissertationduplicated.txt" - When I create the dissertation "Dissertation duplicated" with file name "Dissertationduplicated2.txt" and school "UFPE" + When I create the dissertation "Dissertation duplicated" with file name "Dissertationduplicated2.txt" Then the dissertation "Dissertation duplicated" is not stored twice Scenario: new dissertation without file @@ -39,11 +39,6 @@ Feature: Dissertation Tests And I cant add the dissertation without a file Then the system has no dissertation entitled "Dissertacao sem arquivo" - Scenario: upload a dissertation and system has no dissertation stored - Given the system has no dissertation entitled "New dissertation" - When I upload a new dissertation "curriculo4.xml" with title "New dissertation" - Then the system has more dissertations now - Scenario: new dissertation with file Given I am at the publications menu When I select the "Dissertacao" option at the program menu @@ -58,18 +53,16 @@ Feature: Dissertation Tests Then the dissertation "Edit dissertation" is properly updated by the system Scenario: delete dissertation - Given the dissertation "Delete dissertation" is stored in the system with file name "Deletedissertation.txt" - Given I am at the publications menu - When I select the "Dissertacao" option at the program menu - And I select "Delete dissertation" at the dissertation page - And I delete "Delete dissertation" - Then the system has no dissertation entitled "Delete dissertation" + Given I am at the dissertation page + And the dissertation named "Dissertation One" is stored in the system + When I select "Dissertation One" at the dissertation list + And I press to remove "Delete dissertation" at the dissertation show page + Then the system has no dissertation entitled "Dissertation One" Scenario: upload dissertation without a file - Given I am at the publications menu - When I select the "Dissertacao" option at the program menu - And I select the upload button at the dissertation page - Then I'm still on dissertation page + Given I am at the dissertation page + And I select the upload button with no file selected + Then I stay on dissertation page with an error message Scenario: upload dissertation with a file Given the system has some dissertation stored @@ -90,4 +83,19 @@ Feature: Dissertation Tests And I select the new dissertation option at the dissertation page Then I see my user listed as an author member of dissertation by default And I see my school name as school of dissertation by default -#end \ No newline at end of file +#end + +#if($addDisertacao) + + Scenario: add "Dissertacao"'s Supervisor + Given I am at the "Dissetação" page + And the system has no dissertation entitled "New dissertation" + When I create the dissertation "New dissertation" with file name "Newdissertation.txt" + And school "UFPE" + And the supervisor "Silvio Melo" + Then the dissertation "New dissertation" is properly stored by the system +#end + +#Issue - vml +#A unificação da linguagem do formulário é bastante útil +#pois padroniza o uso do software e evita possíveis ambiguidades e erros diff --git a/test/cucumber/Funder.feature b/test/cucumber/Funder.feature index be8c4fe8..d2e83244 100644 --- a/test/cucumber/Funder.feature +++ b/test/cucumber/Funder.feature @@ -17,8 +17,23 @@ Feature: Funder Given the system has funder with code "12345" When I create a funder with code "12345" Then there is only one funder with code "12345" in the system + + #if($listFunders) + Scenario: list existing funder + Given the system has a funder with code "12345" + When I view the funder list + Then my list funders contains funder "12345" + #end Scenario: new funder web Given I am at the create funder page When I fill the funder code with "12345" Then the funder with code "12345" is properly stored by the system + +#if($duplicateFunderWeb) + Scenario: duplicate funder web + Given I am at the create funder page + When I fill the funder code with "12345" + Then the funder with code "12345" is not stored + And I am still at the create funder page +#end diff --git a/test/cucumber/Member.feature b/test/cucumber/Member.feature index 239da9ff..4e1d7491 100644 --- a/test/cucumber/Member.feature +++ b/test/cucumber/Member.feature @@ -32,7 +32,14 @@ Feature: member Given I am at the login page When I fill username and password with "admin" and "incorrectpassword" Then I am still on the login page with an error message - + +#if($nonexisting) + Scenario: login with nonexisting username + Given I am at the login page + When I fill username and password with "nonexistingusername" and "password" + Then I am still on the login page with an error message +#end + Scenario: user registration Given I am at the register page When I fill the user details with a name, username, passoword1, password2, email, university, status "jose" "josesilva" "123456" "123456" "jose@ufpe.br" "UFPE" "Graduate Student" @@ -51,22 +58,39 @@ Feature: member When I fill some user details with "jose" "josesilva" "jose@ufpe.br" "UFPE" Then I am still on the create member page with the error message - Scenario: register user with invalid data +#if($longUsername) + Scenario: register user with long username Given I am at the create member page - When I fill the user details with "jose" "josesilva" "jose@com" "UFPE" - Then I am still on the create member page with the error message - - -#Scenario: register member invalid aditional info -# Given I am at the create member page -# When I fill many user details with "berg" "bergU" "jus@cin.ufpe.br" "UFPE" "ajsdaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaajsdaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaajsdaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaajsdaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaajsdaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaajsdaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -# Then I am still on the create member page with the error message - -#Scenario: new member with invalid phone -# Given the system has no member with username "userwithinvalidphone" -# When I create a member with username "userwithinvalidphone" -# Then I am still on the create member page with the error message + When I fill the username with "josedmskejfjsdifejfje" + Then I am still on the create member page + And a long username error message is displayed +#end +#if($invalidEmail) + Scenario: register member with invalid email + Given I am at the create member page + When I fill the email with "lalala.la" + Then I am still on the create member page + And a invalid email error message is displayed +#end + +#if($invalid info) +Scenario: register member invalid info + Given I am at the create member page + When I fill city with "321" + And I fill country with "123" + Then I am still on the create member page + And a "no numbers in city and country allowed" error message is displayed +#end + +#if($invalidPhone) +Scenario: new member with invalid phone + Given I am at the create member page + When I fill the phone with "camilasouto" + Then I am still on the create member page + And a invalid phone message is displayed +#end + #if ($contextualInformation) Scenario: new member filled with default data Given I am at the create member page @@ -75,4 +99,13 @@ Feature: member Scenario: user registration with default data Given I am at the register page Then I see default data filled on register form -#end \ No newline at end of file +#end + +#if($loginfacebook) + Scenario: new member with facebook account + Given I am at the create member page + And I am logged on "Camila Souto" facebook + When I click on "register with facebook" + Then the member "Camila Souto" is properly stored by the system +#end + \ No newline at end of file diff --git a/test/cucumber/Orientation.feature b/test/cucumber/Orientation.feature index 6ca3f5e4..87a15cbe 100644 --- a/test/cucumber/Orientation.feature +++ b/test/cucumber/Orientation.feature @@ -6,7 +6,7 @@ Feature: orientations Scenario: new orientation 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" + When I create a new orientation entitled "The Book is on the table" and with type of "Mestrado" Then the orientation "The Book is on the table" is properly stored by the system Scenario: remove existing orientation @@ -78,3 +78,27 @@ Feature: orientations Then I'm still on orientations page And the orientations are not stored by the system #end + + Scenario: filter existing orientation by type + Given the system has some orientation with type "Mestrado" + When the system filter the orientation with type "Mestrado" + Then the system orientation list content is not modified + + Scenario: filter existing orientation by type web + Given I am at the orientation page + And I create some orientation with type of "Mestrado" + When I select to view the list of orientation + And I select to filter the list of orientation by type of "Mestrado" + Then my orientation list shows only the orientation type of by "Mestrado" + + Scenario: filter existing orientation by leader + Given the system has some orientation supervised by "Rodolfo Jose" + When the system filter the articles supervised by leader "Rodolfo Jose" + Then the system article list content is not modified + + Scenario: filter existing orientation by leader web + Given I am at the orientation page + And I create some orientation supervised by "Rodolfo Jose" + When I select to view the list of orientation + And I select to filter the list of orientation by leader "Rodolfo Jose" + Then my orientation list shows only the orientation supervised by "Rodolfo Jose" \ No newline at end of file diff --git a/test/cucumber/Thesis.feature b/test/cucumber/Thesis.feature index e664276f..afdb44b5 100644 --- a/test/cucumber/Thesis.feature +++ b/test/cucumber/Thesis.feature @@ -12,7 +12,27 @@ Feature: Thesis Tests 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 + +#if($addThesisWithSupervisor) + Scenario: add Thesis with Supervisor + Given I am at the "Thesis" page + And the system has no dissertation entitled "New thesis" + When I create the dissertation by clicking on "New thesis" + And fill in the file name with "Newthesis.txt" + And school "UFPE" + And the supervisor's "Silvio Meira" + Then the dissertation "New thesis" is properly stored by the system +#end +#if($addThesisWithSupervisor) + Scenario: add Thesis with Supervisor + Given I want to add a "New thesis" + When I create the dissertation "New thesis" with file "Newthesis.txt" + And school "UFPE" + And the supervisor's "Silvio Meira" + Then the dissertation "New thesis" is properly stored by the system +#end + Scenario: remove existing thesis Given the system has thesis entitled "New thesis2" When I delete the thesis "New thesis2" @@ -106,3 +126,4 @@ Feature: Thesis Tests # o arquivo depois, address deveria ser opcional, deveria ter universidade e # centro/departamento, deveria ter apenas um autor e a possibilidade de um # orientador e co-orientador + diff --git a/test/cucumber/steps/BookChapterSteps.groovy b/test/cucumber/steps/BookChapterSteps.groovy index 1ef01632..fff0c284 100644 --- a/test/cucumber/steps/BookChapterSteps.groovy +++ b/test/cucumber/steps/BookChapterSteps.groovy @@ -5,6 +5,7 @@ import pages.PublicationsPage import pages.* import rgms.publication.BookChapter import steps.BookChapterTestDataAndOperations +import steps.OrientationTestDataAndOperations import steps.TestDataAndOperationsPublication import static cucumber.api.groovy.EN.* @@ -17,6 +18,10 @@ When(~'^I create the book chapter "([^"]*)" with file name "([^"]*)"$') { String BookChapterTestDataAndOperations.createBookChapter(title, filename) } +When(~'^I create the book chapter "([^"]*)" with file name "([^"]*)" and publication date "([^"]*)"$') { String title, filename, date -> + BookChapterTestDataAndOperations.createBookChapter(title, filename) +} + Then(~'^the book chapter "([^"]*)" is properly stored by the system$') { String title -> bookChapter = BookChapter.findByTitle(title) assert BookChapterTestDataAndOperations.bookChapterCompatibleTo(bookChapter, title) @@ -55,6 +60,23 @@ Given(~'^I am at the book chapter page$') { -> at BookChapterPage } +And(~'^I create some book chapter entitled by "([^"]*)"$'){String title -> + at BookChapterPage + page.selectNewBookChapter() + at BookChapterCreatePage + page.fillArticleDetails(BookChapterTestDataAndOperations.path() + 'A.pdf', title) + page.selectCreateBookChapter() + assert !bookChapterNoExist(title) + to BookChapterPage + page.selectNewBookChapter() + at BookChapterCreatePage + page.fillArticleDetails(BookChapterTestDataAndOperations.path() + 'A.pdf', 'Refinement of Concurrent Object Oriented Programs') + page.selectCreateBookChapter() + assert !bookChapterNoExist('Refinement of Concurrent Object Oriented Programs') + to BookChapterPage +} + + And(~'^I fill only the title field with the value "([^"]*)"$') { String title -> at BookChapterCreatePage page.fillTitle(title) @@ -176,6 +198,43 @@ When(~'I select the Book Chapter option at the program menu'){ -> page.select("Book Chapter") } +Given(~'^the system has some book chapter entitled by "([^"]*)"$'){ String title -> + BookChapterTestDataAndOperations.createBookChapter(title, "A.pdf") + BookChapterTestDataAndOperations.createBookChapter('Refinement of Concurrent Object Oriented Programs', "B.pdf") + + assert (!bookChapterNoExist(title) && !bookChapterNoExist('Refinement of Concurrent Object Oriented Programs')) +} + +When(~'^the system filter the book chapter entitled by title "([^"]*)"$') { String title -> + bookChapterFilter = BookChapterTestDataAndOperations.findBookChapterByTitle(title) + BookChapterTestDataAndOperations.isFiltered(bookChapterFilter, title) +} + +Then(~'^the system book chapter list content is not modified$'){-> + assert BookChapter.findAll().size() == 2 + assert !bookChapterNoExist('Next Generation Software Product Line Engineering') + assert !bookChapterNoExist('Refinement of Concurrent Object Oriented Programs') +} + +When(~'^I select to view the list of book chapters$'){-> + at BookChapterPage + page.selectViewBookChapter() +} + +And(~'^I select to filter the list of book chapter by title "([^"]*)"$'){ String title -> + at BookChapterPage + page.fillAndSelectFilter(title) +} + +Then(~'^my book chapter list shows only the book chapters entitled by "([^"]*)"$') { String title -> + at BookChapterPage + assert page.checkFilteredBy(title) +} + +def bookChapterNoExist(String title){ + return BookChapterTestDataAndOperations.findBookChapterByTitle(title) == null +} + def createAndCheckBookOnBrowser(String title, String filename) { page.fillBookChapterDetails(title, filename) diff --git a/test/cucumber/steps/BookSteps.groovy b/test/cucumber/steps/BookSteps.groovy index 45aae835..44230891 100644 --- a/test/cucumber/steps/BookSteps.groovy +++ b/test/cucumber/steps/BookSteps.groovy @@ -8,6 +8,8 @@ import pages.BookCreatePage import pages.BookPage +import pages.BookShowPage +import pages.BookEditPage import pages.LoginPage import pages.PublicationsPage import rgms.publication.Book @@ -28,12 +30,60 @@ Then(~'^the book "([^"]*)" is properly stored by the system$') { String title -> assert BookTestDataAndOperations.bookCompatibleTo(book, title) } +//beginning of @gml's $updateExistingBook steps + Given(~'^the book "([^"]*)" is stored in the system with file name "([^"]*)"$') { String title, String filename -> BookTestDataAndOperations.createBook(title, filename) book = Book.findByTitle(title) assert BookTestDataAndOperations.bookCompatibleTo(book, title) } +Then(~'^the book "([^"]*)" has the archive file "([^"]*)" updated by the system$') { String title, String filename -> + assert book.file.equals(filename) +} + +When (~'^I edit the book file name from "([^"]*)" to "([^"]*)"$') { String oldFile, newFile -> + BookTestDataAndOperations.editFile(oldFile, newFile) +} + +When (~'^I edit the book "([^"]*)" file name from "([^"]*)" to "([^"]*)"$'){ String title, oldFilename, newFilename -> + at BookPage + page.selectViewBook(title) + to BookShowPage + //at BookShowPage + page.select("input", "edit") + to BookEditPage + page.editFilename(newFilename) + page.clickSaveBook() +} + +Then(~'^I have the book entitled "([^"]*)" with file name "([^"]*)" stored on the system$') { String title, String filename -> + book = Book.findByTitleAndFile(title, filename) + assert book != null +} + +When(~'^I upload the file in the system with name "([^"]*)"$') { String fileName -> + book.setFile(fileName) + assert Book.findByFile(fileName) +} + +//@gml's $bookWithoutFile steps + +When (~'^I try to create the book "([^"]*)" without file$'){String title -> + !checkIfExists(title) +} + +Then(~'^the book "([^"]*)" is not stored by the system$') {String title -> + !checkIfExists(title) +} + +Then (~'I should see an error message containing "([^"]*)"$') { + assert book == null + assert (page.readFlashMessage() != null) + +} +//end of @gml tests + When(~'^I remove the book "([^"]*)"$') { String title -> BookTestDataAndOperations.removeBook(title) } @@ -69,11 +119,11 @@ When(~'^I upload the books of "([^"]*)"$') { filename -> } Then(~'^the system has all the books of the xml file$') { -> - assert Book.findByTitle("Proceedings of the IV Brazilian Symposium on Programming Languages") != null - assert Book.findByTitle("Testing Techniques in Software Engineering") != null - assert Book.findByTitle("Proceedings of the XXIII Brazilian Symposium on Software Engineering") != null - assert Book.findByTitle("Anais da IV Conferência Latina-Americana em Linguagens de Padrões para Programação (SugarLoafPLoP 2004)") != null - assert Book.findByTitle("AOSD 2011 Proceedings and Companion Material") != null + assert checkIfExists("Proceedings of the IV Brazilian Symposium on Programming Languages") + assert checkIfExists("Testing Techniques in Software Engineering") + assert checkIfExists("Proceedings of the XXIII Brazilian Symposium on Software Engineering") + assert checkIfExists("Anais da IV Conferência Latina-Americana em Linguagens de Padrões para Programação (SugarLoafPLoP 2004)") + assert checkIfExists("AOSD 2011 Proceedings and Companion Material") } Given(~'^I am at the book page$') { -> @@ -88,7 +138,6 @@ When(~'^I go to new book page$') { -> to BookPage page.selectNewBook() } - And(~'^I use the webpage to create the book "([^"]*)" with file name "([^"]*)"$') { String title, filename -> at BookCreatePage createAndCheckBookOnBrowser(title, filename) @@ -97,20 +146,53 @@ And(~'^I use the webpage to create the book "([^"]*)" with file name "([^"]*)"$' } Then(~'^the book "([^"]*)" was stored by the system$') { String title -> - book = Book.findByTitle(title) - assert book != null + checkIfExists(title) to BookPage at BookPage } +When(~'^I choose to view "([^"]*)" in book list$') { String title -> + page.selectViewBook(title) + at BookShowPage +} + +And(~'^I press to remove at the book show page$') {-> + at BookShowPage + page.select('input', 'delete') +} + +Then(~'^the book list contains" ([^"]*)"$') { String title -> + at BookPage + page.checkArticleAtList(title, 0) +} + def checkIfExists(String title) { book = Book.findByTitle(title) - assert book == null + return book != null } def createAndCheckBookOnBrowser(String title, String filename) { page.fillBookDetails(title, filename) page.clickSaveBook() + checkIfExists(title) +} + +Given(~'^the system has the book entitled "([^"]*)" with file name "([^"]*)"$') { String title, String file -> + book = Book.findByTitleAndFile(title, file) + if(book == null){ + to BookPage + page.selectNewBook() + at BookCreatePage + createAndCheckBookOnBrowser(title, file) + to BookPage + } +} + +Then(~'^the book "([^"]*)" is removed from the system$') { String title -> book = Book.findByTitle(title) - assert book != null -} \ No newline at end of file + assert book == null +} + +Then(~'^the book list contains "([^"]*)"$') { String title -> + checkIfExists(title) +} diff --git a/test/cucumber/steps/DissertacaoSteps.groovy b/test/cucumber/steps/DissertacaoSteps.groovy index 03cd3324..4d11b9c7 100644 --- a/test/cucumber/steps/DissertacaoSteps.groovy +++ b/test/cucumber/steps/DissertacaoSteps.groovy @@ -6,7 +6,8 @@ import rgms.authentication.User import rgms.publication.Dissertacao import steps.TestDataDissertacao import steps.TestDataAndOperationsPublication - +import pages.LoginPage +import pages.PublicationsPage import static cucumber.api.groovy.EN.* @@ -67,8 +68,8 @@ Given(~'^the dissertation "([^"]*)" is stored in the system with file name "([^" } -When(~'^I create the dissertation "([^"]*)" with file name "([^"]*)" and school "([^"]*)"$') { String title, filename, school -> - TestDataDissertacao.createDissertacao(title, filename, school) +When(~'^I create the dissertation "([^"]*)" with file name "([^"]*)", school "([^"]*)" and supervisor "([^"]*)"$') { String title, filename, school, supervisor -> + TestDataDissertacao.createDissertacao(title, filename, school, supervisor) } @@ -101,13 +102,6 @@ Then(~'^the dissertation "([^"]*)" is properly updated by the system$') { String assert article == null } -When(~'^I select the upload button at the dissertation page$') {-> - at DissertationPage - page.uploadWithoutFile() -} -Then(~'^I\'m still on dissertation page$') {-> - at DissertationPage -} When(~'^I upload a new dissertation "([^"]*)"$') { filename -> String path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "functional" + File.separator + "steps" + File.separator + filename @@ -157,3 +151,40 @@ Given(~'^the system has no dissertation stored$') {-> } +Given(~'^I am at the dissertation page$') { -> + to LoginPage + at LoginPage + page.fillLoginData("admin", "adminadmin") + at PublicationsPage + to DissertationPage +} +When(~'^I select the upload button with no file selected$') {-> + page.uploadWithoutFile() +} +Then(~'^I stay on dissertation page with an error message$') { -> + at DissertationPage + assert page.readFlashMessage() != null +} + + +When(~'^I press to remove "([^"]*)" at the dissertation show page$'){ String title-> + at DissertationShowPage + page.select('input', 'delete') +} + +When(~'^I create the dissertation "([^"]*)" with file name "([^"]*)"$') { String title, String filename -> + TestDataDissertacao.createDissertacao(title, filename, "UFPE") + dissertation = Dissertacao.findByTitle(title) + assert dissertation != null +} + +Given(~'^the dissertation named "([^"]*)" is stored in the system$') { String title -> + TestDataDissertacao.createDissertacao(title, "testDissertation.pdf", "UFPE") + dissertation = Dissertacao.findByTitle(title) + assert dissertation != null +} + +When(~'^I select "([^"]*)" at the dissertation list$') { String title -> + page.selectDissertation(title) +} + diff --git a/test/cucumber/steps/OrientationSteps.groovy b/test/cucumber/steps/OrientationSteps.groovy index 3bec0229..0d551188 100644 --- a/test/cucumber/steps/OrientationSteps.groovy +++ b/test/cucumber/steps/OrientationSteps.groovy @@ -26,6 +26,11 @@ When(~'^I create a new orientation entitled "([^"]*)"$') { String tituloTese -> OrientationTestDataAndOperations.createOrientation(tituloTese) } +When(~'^I create a new orientation entitled "([^"]*)" and with type of "([^"]*)"$') { String tituloTese, String tipo-> + // Express the Regexp above with the code you wish you had + OrientationTestDataAndOperations.createOrientation(tituloTese, tipo) +} + Then(~'^the orientation "([^"]*)" is properly stored by the system$') { String title -> checkIfOrientationExists(title) } @@ -219,6 +224,99 @@ When(~'^I select the option remove at the orientation show page$') { -> } +def orientationNoExist(String title){ + return OrientationTestDataAndOperations.findOrientationByTitle(title) == null +} + +//filter +Given(~'^the system has some orientation with type "([^"]*)"$'){ String tipo -> + OrientationTestDataAndOperations.createOrientation('A theory of software product line refinement', tipo) + OrientationTestDataAndOperations.createOrientation('Modularity analysis of use case implementations') + + assert (!orientationNoExist('A theory of software product line refinement') && !orientationNoExist('Modularity analysis of use case implementations')) +} + +When(~'^the system filter the orientation with type "([^"]*)"$'){ String tipo -> + orientationFiltered = Orientation.findByTipo(tipo) + assert Orientation.isFiltered(orientationFiltered, tipo) +} + +Then(~'^the system orientation list content is not modified$'){ + assert Orientation.findAll().size() == 2 + assert !orientationNoExist('Modularity analysis of use case implementations') + assert !orientationNoExist('A theory of software product line refinement') +} + +And(~'^I create some orientation with type of "([^"]*)"$') {String tipo-> + at OrientationsPage + page.selectNewOrientation() + at OrientationCreatePage + fillOrientationWithTitleAndCreateThen('Modularity analysis of use case implementations') + page.selectCreateOrientation() + assert !orientationNoExist('Modularity analysis of use case implementations') + to OrientationsPage + page.selectNewOrientation() + at OrientationCreatePage + fillOrientationWithTitleAndCreateThen('A theory of software product line refinement') + page.selectCreateOrientation() + assert !orientationNoExist('A theory of software product line refinement') + to OrientationsPage +} + +When(~'^I select to view the list of orientation$') {-> + at OrientationsPage + page.selectViewOrientation() +} + +And(~'^I select to filter the list of orientation by type of "([^"]*)"$') {String tipo-> + at OrientationsPage + page.fillAndSelectFilter(tipo) +} + +Then(~'^my orientation list shows only the orientation type of by "([^"]*)"$') {String tipo-> + at OrientationsPage + assert page.checkFilteredBy(tipo); +} + + +Given(~'^the system has some orientation supervised by "([^"]*)"$'){ String leader -> + OrientationTestDataAndOperations.createOrientation('The Book is on the table', leader) + OrientationTestDataAndOperations.createOrientation('The Book is on the table') + + assert (!orientationNoExist('A theory of software product line refinement') && !orientationNoExist('Modularity analysis of use case implementations')) +} + +When(~'^the system filter the articles supervised by leader "([^"]*)"$'){ String leader -> + orientationFiltered = Orientation.findByOrientador(leader) + assert Orientation.isFiltered(orientationFiltered, leader, null) +} + +And(~'^I create some orientation supervised by "([^"]*)"$') {String leader-> + at OrientationsPage + page.selectNewOrientation() + at OrientationCreatePage + fillOrientationWithTitleAndCreateThen('Modularity analysis of use case implementations', leader) + page.selectCreateOrientation() + assert !orientationNoExist('Modularity analysis of use case implementations') + to OrientationsPage + page.selectNewOrientation() + at OrientationCreatePage + fillOrientationWithTitleAndCreateThen('A theory of software product line refinement') + page.selectCreateOrientation() + assert !orientationNoExist('A theory of software product line refinement') + to OrientationsPage +} + +And(~'^I select to filter the list of orientation by leader "([^"]*)"$') {String leader-> + at OrientationsPage + page.fillAndSelectFilter(leader) +} + +Then(~'^my orientation list shows only the orientation supervised by "([^"]*)"$') {String leader-> + at OrientationsPage + assert page.checkFilteredBy(leader); +} + //FUNCOES AUXILIARES private void goToOrientationCreatePage() { diff --git a/test/cucumber/steps/ThesisSteps.groovy b/test/cucumber/steps/ThesisSteps.groovy index 90129b91..0c2a7427 100644 --- a/test/cucumber/steps/ThesisSteps.groovy +++ b/test/cucumber/steps/ThesisSteps.groovy @@ -23,9 +23,9 @@ Given(~'^The thesis "([^"]*)" is stored in the system with file name "([^"]*)"$' assert article != null } -When(~'^I create the thesis "([^"]*)" with file name "([^"]*)" and school "([^"]*)"$') { - String title, filename, school -> - ThesisTestDataAndOperations.createTese(title, filename, school) +When(~'^I create the thesis "([^"]*)" with file name "([^"]*)" and school "([^"]*)" and supervisor "([^"]*)"$') { + String title, filename, school, supervisor -> + ThesisTestDataAndOperations.createTese(title, filename, school, supervisor) } Then(~'^The thesis "([^"]*)" is not stored twice$') { String title -> @@ -46,16 +46,16 @@ Given(~'^I am at the create thesis page$') { -> at ThesisCreatePage } -When(~'^I fill the thesis details with "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)" and "([^"]*)"$') { - title, pub_day, pub_month, pub_year, school, address -> +When(~'^I fill the thesis details with "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)" and "([^"]*)"$') { + title, pub_day, pub_month, pub_year, school, address, supervisor -> 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) + page.fillThesisDetails(title, pub_day, pub_month, pub_year, school, address, supervisor, 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) +When(~'^I fill some thesis details with "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)" and "([^"]*)"$') { + title, pub_day, pub_month, pub_year, school, address, supervisor -> + page.fillSomeThesisDetails(title, pub_day, pub_month, pub_year, school, address, supervisor) } Then(~'^I am on the thesis show page$') { -> @@ -170,7 +170,7 @@ Then(~'^the returned thesis list has the same items but it is sorted by date$') } //Scenario: search an existing thesis -Given(~'^the system has one thesis entitled "([^"]*)" with author name "([^"]*)", year of publication "([^"]*)" and university "([^"]*)"$') { title, author, year, university -> +Given(~'^the system has one thesis entitled "([^"]*)" with author name "([^"]*)", year of publication "([^"]*)", university "([^"]*)" and supervisor "([^"]*)"$') { title, author, year, university, supervisor -> } @@ -193,7 +193,7 @@ Then(~'^the thesis "([^"]*)" by "([^"]*)" appears in the thesis view page$') { t //Scenario: create thesis web without a file -When(~'^I fill the thesis fields with "([^"]*)", "([^"]*)", "([^"]*)","([^"]*)", "([^"]*)","([^"]*)"$') { title, date, university, address, author, advisor -> +When(~'^I fill the thesis fields with "([^"]*)", "([^"]*)", "([^"]*)","([^"]*)", "([^"]*)","([^"]*)", "([^"]*)"$') { title, date, university, address, author, advisor, supervisor -> } @@ -269,6 +269,8 @@ And(~'^the system stores properly the thesis entitled "([^"]*)"$') { title -> } +Given (~'^I want to add a "New thesis"') { } + //FUNÇÔES AUXILIARES def thesisDoNotExists(title) { tese = Tese.findByTitle(title) @@ -280,4 +282,4 @@ def Login() { to LoginPage at LoginPage page.fillLoginData("admin", "adminadmin") -} \ No newline at end of file +} diff --git a/test/functional/pages/ArticlePages/ArticleShowPage.groovy b/test/functional/pages/ArticlePages/ArticleShowPage.groovy index fa25e24c..938604cc 100644 --- a/test/functional/pages/ArticlePages/ArticleShowPage.groovy +++ b/test/functional/pages/ArticlePages/ArticleShowPage.groovy @@ -49,4 +49,3 @@ class ArticleShowPage extends Page { } //#end } -//#end diff --git a/test/functional/pages/BookCreatePage.groovy b/test/functional/pages/BookCreatePage.groovy index b4768335..bd1bd481 100644 --- a/test/functional/pages/BookCreatePage.groovy +++ b/test/functional/pages/BookCreatePage.groovy @@ -28,11 +28,14 @@ class BookCreatePage extends FormPage { } def fillBookDetails(title, filename) { - fillTitle(title) + $("form").title = title $("form").publisher = "Person" $("form").volume = 1 $("form").pages = "20" - $("form").file = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "functional" + File.separator + "steps" + File.separator + filename + if(!filename.equals("")){ + $("form").file = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "functional" + File.separator + "steps" + File.separator + filename + } + clickSaveBook() } def clickSaveBook() { diff --git a/test/functional/pages/BookEditPage.groovy b/test/functional/pages/BookEditPage.groovy new file mode 100644 index 00000000..8d8f3e9e --- /dev/null +++ b/test/functional/pages/BookEditPage.groovy @@ -0,0 +1,39 @@ +package pages; + +import geb.Page +import rgms.publication.Book +import steps.BookTestDataAndOperations + +/** + * Created by Gabriela on 04-Feb-15. + */ +public class BookEditPage extends Page { + static url = "book/edit/12" + + static at = { + GetPageTitle gp = new GetPageTitle() + def currentBook = gp.msg("default.book.label") + def currentTitle = gp.msg("default.edit.label", [currentBook]) + + title ==~ currentTitle + } + + static content = { + publisher { + $("input", id: "publisher") + } + } + + def editFilename(String newFile) { + $("form").file = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "functional" + File.separator + "steps" + File.separator + newFile + } + + def select(String s) { + $("form").find("input", value: s).click() + } + + def clickSaveBook() { + $("form").find(class: "save").click() + } +} + diff --git a/test/functional/pages/BookPage.groovy b/test/functional/pages/BookPage.groovy index 2c658d49..c2fdcba0 100644 --- a/test/functional/pages/BookPage.groovy +++ b/test/functional/pages/BookPage.groovy @@ -26,6 +26,14 @@ class BookPage extends Page { } + def selectViewBook(title) { + def listDiv = $('div', id: 'list-book') + def bookTable = (listDiv.find('table'))[0] + def bookRow = bookTable.find('tbody').find('tr') + def showLink = bookRow.find('td').find([text: title]) + showLink.click() + } + def selectNewBook() { $('a.create').click() } diff --git a/test/functional/pages/BookShowPage.groovy b/test/functional/pages/BookShowPage.groovy new file mode 100644 index 00000000..eb5bb4eb --- /dev/null +++ b/test/functional/pages/BookShowPage.groovy @@ -0,0 +1,34 @@ +package pages + +import geb.Page + +/** + * Created by Casa on 20/01/2015. + */ +class BookShowPage extends Page { + static url = "book/show" + + static at = { + GetPageTitle gp = new GetPageTitle() + def currentBook = gp.msg("default.book.label") + def currentTitle = gp.msg("default.show.label", [currentBook]) + + title ==~ currentTitle + } + + static content = { + book { + $('input', id: 'book') + } + } + + def select(String e, v) { + if (v == 'delete') { + assert withConfirm(true) { $("form").find(e, class: v).click() } + } else if (v == "edit"){ + $("form").find(e, class: "edit").click() + } else { + $("form").find(e, class: v).click() + } + } +} \ No newline at end of file diff --git a/test/functional/pages/DissertationPage.groovy b/test/functional/pages/DissertationPage.groovy index b510ee72..473f7455 100644 --- a/test/functional/pages/DissertationPage.groovy +++ b/test/functional/pages/DissertationPage.groovy @@ -6,7 +6,11 @@ class DissertationPage extends Page { static url = "dissertacao/list" static at = { - title ==~ /Dissertacao Listagem/ + GetPageTitle gp = new GetPageTitle() + def currentDissertation = gp.msg("default.periodico.label") + def currentTitle = gp.msg("default.list.label", [currentDissertation]) + + title ==~ currentTitle } static content = { @@ -23,6 +27,14 @@ class DissertationPage extends Page { $('input.save').click() } + def selectViewDissertation(title) { + def listDiv = $('div', id: 'list-dissertacao') + def dissertationTable = (listDiv.find('table'))[0] + def dissertationRow = dissertationTable.find('tbody').find('tr') + def showLink = dissertationRow.find('td').find([text: title]) + showLink.click() + } + def checkIfDissertationListIsEmpty(){ def listDiv = $('div', id: 'list-dissertacao') def dissertationTable = (listDiv.find('table'))[0] @@ -31,4 +43,5 @@ class DissertationPage extends Page { assert dissertationColumns.size() < 6 } + } diff --git a/test/functional/pages/DissertationShowPage.groovy b/test/functional/pages/DissertationShowPage.groovy index 30d667a3..eebd00d3 100644 --- a/test/functional/pages/DissertationShowPage.groovy +++ b/test/functional/pages/DissertationShowPage.groovy @@ -8,9 +8,13 @@ import geb.Page; class DissertationShowPage extends Page{ static url = "dissertacao/show" - + static at = { - title ==~ /Ver Dissertacao/ + GetPageTitle gp = new GetPageTitle() + def currentDissertation = gp.msg("default.dissertacao.label") + def currentTitle = gp.msg("default.show.label", [currentDissertation]) + + title ==~ currentTitle } static content = { @@ -26,4 +30,12 @@ class DissertationShowPage extends Page{ $('input.delete').click() } } + + def select(String e, v) { + if (v == 'delete') { + assert withConfirm(true) { $("form").find(e, class: v).click() } + } else { + $("form").find(e, class: v).click() + } + } } diff --git a/test/functional/steps/ArticleTestDataAndOperations.groovy b/test/functional/steps/ArticleTestDataAndOperations.groovy index 390bd57f..a2d3c804 100644 --- a/test/functional/steps/ArticleTestDataAndOperations.groovy +++ b/test/functional/steps/ArticleTestDataAndOperations.groovy @@ -67,7 +67,6 @@ class ArticleTestDataAndOperations { } if(authorName!=null){ cont.params["authors"] = authorName - } cont.request.setContent(new byte[1000]) // Could also vary the request content. cont.create() diff --git a/test/functional/steps/BookChapterTestDataAndOperations.groovy b/test/functional/steps/BookChapterTestDataAndOperations.groovy index f4a0a0c7..5e354d95 100644 --- a/test/functional/steps/BookChapterTestDataAndOperations.groovy +++ b/test/functional/steps/BookChapterTestDataAndOperations.groovy @@ -61,6 +61,18 @@ class BookChapterTestDataAndOperations { cont.response.reset() } + static public def path(){ + return new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + } + + static public def isFiltered(bookChapters,title) { + for (bookChapter in bookChapters) { + if(!(bookChapter.title).contains(title)) + return false + } + return true + } + static public void removeBookChapter(String title) { def testBookChapter = BookChapter.findByTitle(title) def cont = new BookChapterController() diff --git a/test/functional/steps/BookTestDataAndOperations.groovy b/test/functional/steps/BookTestDataAndOperations.groovy index a6a8f379..2d5de416 100644 --- a/test/functional/steps/BookTestDataAndOperations.groovy +++ b/test/functional/steps/BookTestDataAndOperations.groovy @@ -27,6 +27,12 @@ class BookTestDataAndOperations { } } + static public def findBookByFile(String file) { + books.find { book -> + book.file == file + } + } + static public void createBook(String title, String filename) { def cont = new BookController() cont.params << findBookByTitle(title) << [file: filename] @@ -46,11 +52,24 @@ class BookTestDataAndOperations { static public Book editBook(oldtitle, newtitle) { def book = Book.findByTitle(oldtitle) book.setTitle(newtitle) + createEditedBookAndUpdate(book) + def updatedBook = Book.findByTitle(newtitle) + return updatedBook + } + + private static createEditedBookAndUpdate(Book book) { def cont = new BookController() cont.params << book.properties cont.update() + } - def updatedBook = Book.findByTitle(newtitle) + //created/modified by @gml + static public Book editFile(oldFile, newFile) { + def book = Book.findByFile(oldFile) + book.setFile(newFile) + createEditedBookAndUpdate(book) + + def updatedBook = Book.findByFile(newFile) return updatedBook } diff --git a/test/functional/steps/OrientationTestDataAndOperations.groovy b/test/functional/steps/OrientationTestDataAndOperations.groovy index b1f88aed..75b3bd7c 100644 --- a/test/functional/steps/OrientationTestDataAndOperations.groovy +++ b/test/functional/steps/OrientationTestDataAndOperations.groovy @@ -37,6 +37,24 @@ class OrientationTestDataAndOperations { createOrientationAux(cont, tituloTese, member) } + static public void createOrientation(String tituloTese, String tipo) { + + def cont = new OrientationController() + def memberCreater = new Member(members[0]) + memberCreater.create() + memberCreater.save() + def member = Member.findByName(memberCreater.name) + createOrientationAux(cont, tituloTese, member, tipo) + } + + private static void createOrientationAux(OrientationController cont, String tituloTese, Member member, String tipo) { + cont.params << [tipo: tipo, 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() + } + private static void createOrientationAux(OrientationController cont, String tituloTese, Member member) { 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. diff --git a/test/functional/steps/TestDataDissertacao.groovy b/test/functional/steps/TestDataDissertacao.groovy index a7e034fa..d0dcfb74 100644 --- a/test/functional/steps/TestDataDissertacao.groovy +++ b/test/functional/steps/TestDataDissertacao.groovy @@ -55,7 +55,7 @@ class TestDataDissertacao def testDissertation = Dissertacao.findByTitle(title) def cont = new DissertacaoController() def date = new Date() - cont.params << [id: testDissertation.id] + cont.params << [id: testDissertation?.id] cont.delete() } diff --git a/test/functional/steps/newHSPLE.pdf b/test/functional/steps/newHSPLE.pdf new file mode 100644 index 00000000..012b3279 Binary files /dev/null and b/test/functional/steps/newHSPLE.pdf differ diff --git a/test/integration/rgms/FunctionalCucumberSpec.groovy b/test/integration/rgms/FunctionalCucumberSpec.groovy new file mode 100644 index 00000000..ae463935 --- /dev/null +++ b/test/integration/rgms/FunctionalCucumberSpec.groovy @@ -0,0 +1,15 @@ +package rgms + +import grails.plugin.spock.IntegrationSpec + +class FunctionalCucumberSpec extends IntegrationSpec { + + def setup() { + } + + def cleanup() { + } + + void "test something"() { + } +} \ No newline at end of file diff --git a/test/integration/rgms/TestAppSpec.groovy b/test/integration/rgms/TestAppSpec.groovy new file mode 100644 index 00000000..0feba4f9 --- /dev/null +++ b/test/integration/rgms/TestAppSpec.groovy @@ -0,0 +1,15 @@ +package rgms + +import grails.plugin.spock.IntegrationSpec + +class TestAppSpec extends IntegrationSpec { + + def setup() { + } + + def cleanup() { + } + + void "test something"() { + } +} \ No newline at end of file diff --git a/test/unit/rgms/publication/MagazinePublicationControllerTests.groovy b/test/unit/rgms/publication/MagazinePublicationControllerTests.groovy new file mode 100644 index 00000000..cb534ba3 --- /dev/null +++ b/test/unit/rgms/publication/MagazinePublicationControllerTests.groovy @@ -0,0 +1,154 @@ +package rgms.publication + + +import org.junit.* +import grails.test.mixin.* + +@TestFor(MagazinePublicationController) +@Mock(MagazinePublication) +class MagazinePublicationControllerTests { + + def populateValidParams(params) { + assert params != null + // TODO: Populate valid properties like... + //params["name"] = 'someValidName' + } + + void testIndex() { + controller.index() + assert "/magazinePublication/list" == response.redirectedUrl + } + + void testList() { + + def model = controller.list() + + assert model.magazinePublicationInstanceList.size() == 0 + assert model.magazinePublicationInstanceTotal == 0 + } + + void testCreate() { + def model = controller.create() + + assert model.magazinePublicationInstance != null + } + + void testSave() { + controller.save() + + assert model.magazinePublicationInstance != null + assert view == '/magazinePublication/create' + + response.reset() + + populateValidParams(params) + controller.save() + + assert response.redirectedUrl == '/magazinePublication/show/1' + assert controller.flash.message != null + assert MagazinePublication.count() == 1 + } + + void testShow() { + controller.show() + + assert flash.message != null + assert response.redirectedUrl == '/magazinePublication/list' + + populateValidParams(params) + def magazinePublication = new MagazinePublication(params) + + assert magazinePublication.save() != null + + params.id = magazinePublication.id + + def model = controller.show() + + assert model.magazinePublicationInstance == magazinePublication + } + + void testEdit() { + controller.edit() + + assert flash.message != null + assert response.redirectedUrl == '/magazinePublication/list' + + populateValidParams(params) + def magazinePublication = new MagazinePublication(params) + + assert magazinePublication.save() != null + + params.id = magazinePublication.id + + def model = controller.edit() + + assert model.magazinePublicationInstance == magazinePublication + } + + void testUpdate() { + controller.update() + + assert flash.message != null + assert response.redirectedUrl == '/magazinePublication/list' + + response.reset() + + populateValidParams(params) + def magazinePublication = new MagazinePublication(params) + + assert magazinePublication.save() != null + + // test invalid parameters in update + params.id = magazinePublication.id + //TODO: add invalid values to params object + + controller.update() + + assert view == "/magazinePublication/edit" + assert model.magazinePublicationInstance != null + + magazinePublication.clearErrors() + + populateValidParams(params) + controller.update() + + assert response.redirectedUrl == "/magazinePublication/show/$magazinePublication.id" + assert flash.message != null + + //test outdated version number + response.reset() + magazinePublication.clearErrors() + + populateValidParams(params) + params.id = magazinePublication.id + params.version = -1 + controller.update() + + assert view == "/magazinePublication/edit" + assert model.magazinePublicationInstance != null + assert model.magazinePublicationInstance.errors.getFieldError('version') + assert flash.message != null + } + + void testDelete() { + controller.delete() + assert flash.message != null + assert response.redirectedUrl == '/magazinePublication/list' + + response.reset() + + populateValidParams(params) + def magazinePublication = new MagazinePublication(params) + + assert magazinePublication.save() != null + assert MagazinePublication.count() == 1 + + params.id = magazinePublication.id + + controller.delete() + + assert MagazinePublication.count() == 0 + assert MagazinePublication.get(magazinePublication.id) == null + assert response.redirectedUrl == '/magazinePublication/list' + } +}