diff --git a/.gitignore b/.gitignore
index 8059c686..2fdf093a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -444,3 +444,4 @@ target/test-reports/plain/TEST-functional-cucumber-orientations-out.txt
target/test-reports/plain/TEST-functional-cucumber-orientations.txt
+target/classes
diff --git a/grails-app/conf/BuildConfig.groovy b/grails-app/conf/BuildConfig.groovy
index a5a5999f..384411ea 100644
--- a/grails-app/conf/BuildConfig.groovy
+++ b/grails-app/conf/BuildConfig.groovy
@@ -58,6 +58,8 @@ grails.project.dependency.resolution = {
plugins {
compile ":twitter4j:0.3.2"
compile ":remote-control:1.4"
+ compile ":codenarc:0.20"
+ compile ":gmetrics:0.3.1"
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.7.1"
diff --git a/grails-app/controllers/rgms/member/OrientationController.groovy b/grails-app/controllers/rgms/member/OrientationController.groovy
index 6ba805fe..3031fee7 100644
--- a/grails-app/controllers/rgms/member/OrientationController.groovy
+++ b/grails-app/controllers/rgms/member/OrientationController.groovy
@@ -1,12 +1,6 @@
//#if($Orientation)
package rgms.member
-import org.springframework.dao.DataIntegrityViolationException
-import org.springframework.web.multipart.MultipartHttpServletRequest
-import org.springframework.web.multipart.commons.CommonsMultipartFile
-import rgms.XMLService
-import rgms.authentication.User
-
class OrientationController {
static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
@@ -27,21 +21,29 @@ class OrientationController {
def save() {
def orientationInstance = new Orientation(params)
- if(orientationInstance.orientador.name .equalsIgnoreCase(orientationInstance.orientando))
- {
- render(view: "create", model: [orientationInstance: orientationInstance])
- flash.message = message(code: 'orientation.same.members', args: [message(code: 'orientation.label', default: 'Orientation'), orientationInstance.id])
- return
+ if(!comparacaoOrientationComRender(orientationInstance, "create")) {
+ return false
}
if (!orientationInstance.save(flush: true)) {
render(view: "create", model: [orientationInstance: orientationInstance])
- return
+ return false
}
showFlashMessage(orientationInstance.id, "show", 'default.created.message')
}
+ def comparacaoOrientationComRender(orientationInstance, tipoRender) {
+ if(orientationInstance.orientador.name.equalsIgnoreCase(orientationInstance.orientando)) {
+ render(view: tipoRender, model: [orientationInstance: orientationInstance])
+ //noinspection InvalidI18nProperty
+ flash.message = message(code: 'orientation.same.members', args: [message(code: 'orientation.label', default: 'Orientation'), orientationInstance.id])
+ return false
+ }
+ return true
+
+ }
+
def show = {
_processOrientation()
}
@@ -51,12 +53,14 @@ class OrientationController {
}
def showFlashMessage(Long id, String action, String code){
+ //noinspection InvalidI18nProperty
flash.message = message(code: code, args: [message(code: 'orientation.label', default: 'Orientation'), id])
redirect(action: action, id: id)
}
def _processOrientation()
{
+ //noinspection GroovyAssignabilityCheck
def orientationInstance = Orientation.get(params.id)
if (!orientationInstance) {
showFlashMessage(null, "list",'default.not.found.message')
@@ -98,12 +102,9 @@ class OrientationController {
def checkOrientationOrientando(Orientation orientationInstance){
- if(orientationInstance.orientador.name.equalsIgnoreCase(orientationInstance.orientando)) {
- render(view: "edit", model: [orientationInstance: orientationInstance])
- flash.message = message(code: 'orientation.same.members', args: [message(code: 'orientation.label', default: 'Orientation'), orientationInstance.id])
+ if(!comparacaoOrientationComRender(orientationInstance, "edit")) {
return false
}
-
return true
}
@@ -111,6 +112,7 @@ class OrientationController {
if (version != null) {
if (orientationInstance.version > version) {
+ //noinspection InvalidI18nProperty
orientationInstance.errors.rejectValue("version", "default.optimistic.locking.failure",
[message(code: 'orientation.label', default: 'Orientation')] as Object[],
'default.orientation.checkVersion.message')
@@ -125,6 +127,7 @@ class OrientationController {
def orientationInstance = isOrientationInstance(id)
if(orientationInstance != null){
+ //noinspection GroovyUnusedCatchParameter
try {
orientationInstance.delete(flush: true)
showFlashMessage(id,"list",'default.deleted.message')
diff --git a/grails-app/controllers/rgms/publication/BibtexGenerateFileController.groovy b/grails-app/controllers/rgms/publication/BibtexGenerateFileController.groovy
index 3a44e20a..8c2d492d 100644
--- a/grails-app/controllers/rgms/publication/BibtexGenerateFileController.groovy
+++ b/grails-app/controllers/rgms/publication/BibtexGenerateFileController.groovy
@@ -41,22 +41,22 @@ class BibtexGenerateFileController {
}
def generateBibTex = {
- String bibtex = ""
int numero = (params.id).toInteger()
- for(publication in Publication.getAll())
- {
- for(member in publication.getMembers())
- {
- if(member.getId() == numero)
- {
- bibtex = bibtex + publication.generateBib() + "
"
+ render(membroPublicacoes(numero))
+ }
+
+ private String membroPublicacoes(int numero) {
+ String bibtex = ""
+ for (publication in Publication.getAll()) {
+ for (member in publication.getMembers()) {
+ if (member.getId() == numero) {
+ bibtex = bibtex + publication.generateBib() + "
"
break
}
}
}
-
- render(bibtex)
+ return bibtex
}
def generateBibTexGroup = {
@@ -78,18 +78,6 @@ class BibtexGenerateFileController {
String teste(numero)
{
- String bibtex = ""
- for(publication in Publication.getAll())
- {
- for(member in publication.getMembers())
- {
- if(member.getId() == numero)
- {
- bibtex = bibtex + publication.generateBib() + "
"
- break
- }
- }
- }
- return bibtex
+ return membroPublicacoes(numero)
}
}
diff --git a/grails-app/controllers/rgms/publication/BookChapterController.groovy b/grails-app/controllers/rgms/publication/BookChapterController.groovy
index 7ad983b3..654e42a4 100644
--- a/grails-app/controllers/rgms/publication/BookChapterController.groovy
+++ b/grails-app/controllers/rgms/publication/BookChapterController.groovy
@@ -35,18 +35,25 @@ class BookChapterController {
//Member author = user?.author
//pb.sendPostFacebook(author, bookChapterInstance.toString())
//#end
+ //noinspection InvalidI18nProperty
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) {
+ BookChapter bookChapterInstance = checkBook(id)
+ if(bookChapterInstance != null){
[bookChapterInstance: bookChapterInstance]
}
}
+ private BookChapter checkBook(long id) {
+ def bookChapterInstance = BookChapter.get(id)
+ //noinspection GroovyUnusedAssignment,GroovyUnusedAssignment
+ boolean isReturned = aux.check(id, bookChapterInstance, 'bookChapter.label', 'BookChapter')
+ isReturned ? bookChapterInstance : null
+ }
+
def show(Long id) {
accessBookChapter(id)
}
@@ -56,9 +63,9 @@ class BookChapterController {
}
def update(Long id, Long version) {
- def bookChapterInstance = BookChapter.get(id)
- boolean isReturned = aux.check(id, bookChapterInstance, 'bookChapter.label', 'BookChapter')
- if (!isReturned) {
+
+ def bookChapterInstance = checkBook(id)
+ if (bookChapterInstance != null) {
if (version != null && bookChapterInstance.version > version) {
outdatedVersionError((BookChapter) bookChapterInstance)
} else {
@@ -68,6 +75,7 @@ class BookChapterController {
}
def outdatedVersionError(BookChapter bookChapterInstance) {
+ //noinspection InvalidI18nProperty
bookChapterInstance.errors.rejectValue("version", "default.optimistic.locking.failure",
[message(code: 'bookChapter.label', default: 'BookChapter')] as Object[],
"Another user has updated this BookChapter while you were editing")
@@ -79,6 +87,7 @@ class BookChapterController {
if (!bookChapterInstance.save(flush: true)) {
render(view: "edit", model: [bookChapterInstance: bookChapterInstance])
} else {
+ //noinspection InvalidI18nProperty
flash.message = message(code: 'default.updated.message', args: [message(code: 'bookChapter.label', default: 'BookChapter'), bookChapterInstance.id])
redirect(action: "show", id: bookChapterInstance.id)
}
diff --git a/grails-app/controllers/rgms/publication/DissertacaoController.groovy b/grails-app/controllers/rgms/publication/DissertacaoController.groovy
index 1d3d295f..44ec3e10 100644
--- a/grails-app/controllers/rgms/publication/DissertacaoController.groovy
+++ b/grails-app/controllers/rgms/publication/DissertacaoController.groovy
@@ -22,11 +22,11 @@ class DissertacaoController extends ThesisOrDissertationController {
def save() {
saveThesisOrDissertation("Dissertacao", params)
}
- def getDissertacaoInstance(def id)
-{
- def dissertacaoInstance = Dissertacao.get(id)
+ def getDissertacaoInstance(def id){
+ //noinspection GroovyAssignabilityCheck
+ def dissertacaoInstance = Dissertacao.get(id)
if (!dissertacaoInstance) {
- flash.message = messageGenerator('default.not.found.message', id)
+ flash.message = messageGenerator('','default.not.found.message', id)
redirect(action: "list")
return
}
diff --git a/grails-app/controllers/rgms/publication/PublicationController.groovy b/grails-app/controllers/rgms/publication/PublicationController.groovy
index fb20ec51..30c5c92e 100644
--- a/grails-app/controllers/rgms/publication/PublicationController.groovy
+++ b/grails-app/controllers/rgms/publication/PublicationController.groovy
@@ -81,6 +81,10 @@ class PublicationController {
return false
}
+ return lerPreencherBuffer(f)
+ }
+
+ private boolean lerPreencherBuffer(File f) {
InputStream inputStream = request.getInputStream()
OutputStream outputStream = new FileOutputStream(f)
byte[] buffer = new byte[1024 * 10] //buffer de 10MB
@@ -106,18 +110,7 @@ class PublicationController {
flash.message = 'File already exists. Please try to use a different file name.'
return false
}
- InputStream inputStream = request.getInputStream()
- OutputStream outputStream = new FileOutputStream(f)
- byte[] buffer = new byte[1024 * 10] //buffer de 10MB
- int length
-
- while ((length = inputStream.read(buffer)) > 0) {
- outputStream.write(buffer, 0, length)
- }
- outputStream.close()
- inputStream.close()
-
- return true
+ return lerPreencherBuffer(f)
}
/**
diff --git a/grails-app/controllers/rgms/publication/ThesisOrDissertationController.groovy b/grails-app/controllers/rgms/publication/ThesisOrDissertationController.groovy
index 96e0b983..4e134061 100644
--- a/grails-app/controllers/rgms/publication/ThesisOrDissertationController.groovy
+++ b/grails-app/controllers/rgms/publication/ThesisOrDissertationController.groovy
@@ -1,7 +1,6 @@
package rgms.publication
import org.apache.shiro.SecurityUtils
-import org.codehaus.groovy.grails.commons.ConfigurationHolder
import org.springframework.dao.DataIntegrityViolationException
import rgms.member.Member
@@ -14,16 +13,19 @@ class ThesisOrDissertationController {
def listThesisOrDissertation(String thesisOrDissertation, params) {
params.max = Math.min(params.max ? params.int('max') : 10, 100)
if (thesisOrDissertation == "Tese") {
+ //noinspection GroovyAssignabilityCheck
[teseInstanceList: Tese.list(params), teseInstanceTotal: Tese.count()]
} else if (thesisOrDissertation == "Dissertacao") {
+ //noinspection GroovyAssignabilityCheck
[dissertacaoInstanceList: Dissertacao.list(params), dissertacaoInstanceTotal: Dissertacao.count()]
}
}
def createThesisOrDissertation(String thesisOrDissertation, params) {
+ //noinspection GroovyAssignabilityCheck
def instance = getClassByName(thesisOrDissertation).newInstance(params)
//#if($contextualInformation)
- def user = PublicationController.addAuthor(instance)
+ def user = PublicationController.addAuthor(instance as Publication)
if (user && !user.university.isEmpty()){
instance.school = user.university
}
@@ -32,12 +34,15 @@ class ThesisOrDissertationController {
}
def saveThesisOrDissertation(String thesisOrDissertation, params) {
+ //noinspection GroovyAssignabilityCheck
def instance = getClassByName(thesisOrDissertation).newInstance(params)
PublicationController pb = new PublicationController()
def duplicated
if (thesisOrDissertation == "Tese") {
+ //noinspection GroovyAssignabilityCheck
duplicated = Tese.findByTitle(params.title)
} else if (thesisOrDissertation == "Dissertacao") {
+ //noinspection GroovyAssignabilityCheck
duplicated = Dissertacao.findByTitle(params.title)
}
if (duplicated) {
@@ -45,7 +50,7 @@ class ThesisOrDissertationController {
render(view: "create", model: [instance: instance])
return
}
- if (!pb.upload(instance) || !instance.save(flush: true)) {
+ if (!pb.upload(instance as Publication) || !instance.save(flush: true)) {
render(view: "create", model: [instance: instance])
return
}
@@ -67,16 +72,14 @@ class ThesisOrDissertationController {
}
def updateThesisOrDissertation(String thesisOrDissertation, params) {
- def instance = getClassByName(thesisOrDissertation).get(params.id)
- if (!instance) {
- messageGenerator(thesisOrDissertation, 'default.not.found.message', params.id)
- redirect(action: "list")
- return
- }
+ def instance = getThesisOrDissertationControllerInstance(thesisOrDissertation,params)
+ if(instance == null) return
if (params.version) {
def version = params.version.toLong()
if (instance.version > version) {
+ //noinspection GroovyUnusedAssignment
def lower = thesisOrDissertation.toLowerCase()
+ //noinspection InvalidI18nProperty
instance.errors.rejectValue("version", "default.optimistic.locking.failure",
[message(code: '${lower}.label', default: thesisOrDissertation)] as Object[],
messageGenerator(thesisOrDissertation, "default.optimistic.locking.failure", params.id))
@@ -98,24 +101,29 @@ class ThesisOrDissertationController {
}
def deleteThesisOrDissertation(String thesisOrDissertation, params) {
- def instance = getClassByName(thesisOrDissertation).get(params.id)
- if (!instance) {
- messageGenerator(thesisOrDissertation, 'default.not.found.message', params.id)
- redirect(action: "list")
- return
- }
+ def instance = getThesisOrDissertationControllerInstance(thesisOrDissertation, params)
+ if(instance == null) return
try {
instance.removeFromPublications()
instance.delete(flush: true)
messageGenerator(thesisOrDissertation, 'default.deleted.message', instance.id)
redirect(action: "list")
}
- catch (DataIntegrityViolationException e) {
+ catch (DataIntegrityViolationException ignored) {
messageGenerator(thesisOrDissertation, 'default.not.deleted.message', instance.id)
redirect(action: "show", id: params.id)
}
}
+ def getThesisOrDissertationControllerInstance(String thesisOrDissertation, params) {
+ def instance = getClassByName(thesisOrDissertation).get(params.id)
+ if (!instance) {
+ messageGenerator(thesisOrDissertation, 'default.not.found.message', params.id)
+ redirect(action: "list")
+ }
+ return instance
+ }
+
def getClassByName(String thesisOrDissertation) {
Thread.currentThread().contextClassLoader.loadClass("rgms.publication.${thesisOrDissertation}")
}
diff --git a/grails-app/controllers/rgms/publication/XMLController.groovy b/grails-app/controllers/rgms/publication/XMLController.groovy
index 01331c04..9c850840 100644
--- a/grails-app/controllers/rgms/publication/XMLController.groovy
+++ b/grails-app/controllers/rgms/publication/XMLController.groovy
@@ -50,7 +50,7 @@ class XMLController {
return
}
- private Closure saveBookChapters = {
+ public Closure saveBookChapters = {
Node xmlFile ->
XMLService.createBooksChapters(xmlFile)
}
diff --git a/grails-app/domain/rgms/member/Orientation.groovy b/grails-app/domain/rgms/member/Orientation.groovy
index f4235b3a..88db786a 100644
--- a/grails-app/domain/rgms/member/Orientation.groovy
+++ b/grails-app/domain/rgms/member/Orientation.groovy
@@ -21,12 +21,16 @@ class Orientation {
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)
}
+
+ String toString() {
+ return "Titulo = " + this.tituloTese + "; Orientador = " + this.orientador + "; Orientando: " + this.orientando
+ }
}
//#end
diff --git a/grails-app/services/rgms/XMLService.groovy b/grails-app/services/rgms/XMLService.groovy
index 31045751..9d5e51ad 100644
--- a/grails-app/services/rgms/XMLService.groovy
+++ b/grails-app/services/rgms/XMLService.groovy
@@ -2,7 +2,6 @@ package rgms
import org.springframework.web.multipart.MultipartHttpServletRequest
import org.springframework.web.multipart.commons.CommonsMultipartFile
-import javax.*
import rgms.member.*
import rgms.publication.*
@@ -195,7 +194,7 @@ class XMLService {
//Only saves if the orientation does not already exist
private static void saveOrientation(Orientation newOrientation) {
- if (Orientation.findAll().find { it -> newOrientation.Equals(it) } == null)
+ if (Orientation.findAll().find { it -> newOrientation.equals(it) } == null)
newOrientation.save(flush: false)
}
diff --git a/target/classes/application.properties b/target/classes/application.properties
deleted file mode 100644
index e6246333..00000000
--- a/target/classes/application.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-#Grails Metadata file
-#Thu Jun 06 10:16:12 GMT-03:00 2013
-app.grails.version=2.1.0
-app.name=rgms
-app.servlet.version=2.5
-app.version=0.1
-plugins.cloud-bees=0.6.2
-plugins.cucumber=0.8.0
-plugins.geb=0.9.0-RC-1
-plugins.gmetrics=0.3.1
-plugins.jasper=1.6.1
-plugins.mail=1.0.1
-plugins.pdf=0.6
-plugins.shiro=1.1.4
-plugins.shiro-ui=1.2.0-SNAPSHOT
-plugins.twitter=0.2
diff --git a/test/cucumber/Orientation.feature b/test/cucumber/Orientation.feature
index a1f9d5ee..792341e5 100644
--- a/test/cucumber/Orientation.feature
+++ b/test/cucumber/Orientation.feature
@@ -17,7 +17,6 @@ Feature: orientations
Scenario: create orientation web
Given I am at the create orientation 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
@@ -29,7 +28,6 @@ Feature: orientations
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
diff --git a/test/cucumber/steps/ArticleSteps.groovy b/test/cucumber/steps/ArticleSteps.groovy
index f2f9a77c..8f354057 100644
--- a/test/cucumber/steps/ArticleSteps.groovy
+++ b/test/cucumber/steps/ArticleSteps.groovy
@@ -1,12 +1,7 @@
-import cucumber.runtime.PendingException
import pages.ArticlePages.*
import pages.*
-import rgms.member.Member
-import rgms.publication.BookChapter
import rgms.publication.Periodico
import rgms.tool.TwitterTool
-import steps.BookChapterTestDataAndOperations
-import steps.TestDataAndOperations
import steps.TestDataAndOperationsFacebook
import steps.ArticleTestDataAndOperations
import steps.TestDataAndOperationsPublication
@@ -186,25 +181,11 @@ Given(~'^I am logged as "([^"]*)"$') { String userName ->
}
Given (~'^I am at the Article Page$'){->
- Login()
- at PublicationsPage
- page.select("Periodico")
- to ArticlesPage
- def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "TCS.pdf"
- println path
- def f = new File(path)
- println "exist Path?" + f.exists()
+ addPage()
}
Given(~'^I am logged as "([^"]*)" and at the Add Article Page$') { String userName ->
- Login()
- at PublicationsPage
- page.select("Periodico")
- to ArticlesPage
- def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "TCS.pdf"
- println path
- def f = new File(path)
- println "exist Path?" + f.exists()
+ addPage()
//Mantive esse Given para testes do facebook.
// As duplicacoes de Twitter so dizem respeito a esse teste que pode ser removido. Renato Ferreira.
}
@@ -349,3 +330,15 @@ And(~'^the articles are not stored by the system$') {->
Given(~'^the system has some articles stored$') {->
initialSize = Periodico.findAll().size()
}
+
+//Funcoes Auxiliares
+def addPage(){
+ Login()
+ at PublicationsPage
+ page.select("Periodico")
+ to ArticlesPage
+ def path = new File(".").getCanonicalPath() + File.separator + "test" + File.separator + "files" + File.separator + "TCS.pdf"
+ println path
+ def f = new File(path)
+ println "exist Path?" + f.exists()
+}
diff --git a/test/cucumber/steps/BookChapterSteps.groovy b/test/cucumber/steps/BookChapterSteps.groovy
index 2f95b8f4..b6a998c9 100644
--- a/test/cucumber/steps/BookChapterSteps.groovy
+++ b/test/cucumber/steps/BookChapterSteps.groovy
@@ -2,6 +2,7 @@ import pages.BookChapterCreatePage
import pages.BookChapterPage
import pages.LoginPage
import pages.PublicationsPage
+import pages.*
import rgms.publication.BookChapter
import steps.BookChapterTestDataAndOperations
import steps.TestDataAndOperationsPublication
@@ -79,7 +80,7 @@ When(~'^I view the book chapter list$') { ->
Then(~'my book chapter list contains "([^"]*)"$') { String title ->
at BookChapterPage
bookChapterList = BookChapter.findAll()
- assert BookChapterTestDataAndOperations.containsBookChapter(title, bookChapterList)
+ assert BookChapterTestDataAndOperations.containsBookChapter(title)
}
And(~'^the book chapter "([^"]*)" with file name "([^"]*)" was created before$') { String title, filename ->
page.selectNewBookChapter()
@@ -91,13 +92,16 @@ And(~'^the book chapter "([^"]*)" with file name "([^"]*)" was created before$')
}
Then(~'My resulting book chapter list contains "([^"]*)"$') { String title ->
+ checkIfBookIsOnListAtBookChapterPage(title)
+}
+
+private void checkIfBookIsOnListAtBookChapterPage(String title) {
at BookChapterPage
page.checkBookChapterAtList(title, 0)
}
When(~'^I go to new book chapter page$') { ->
-// to BookChapterPage
- at BookChapterPage
+ to BookChapterPage
page.selectNewBookChapter()
at BookChapterCreatePage
}
@@ -154,6 +158,7 @@ And(~'^the system has a book chapter entitled "([^"]*)" with file name "([^"]*)"
book = BookChapter.findByTitle(title)
if (book == null) {
BookChapterTestDataAndOperations.createBookChapter(title, filename)
+ to BookChapterCreatePage
}
}
@@ -163,10 +168,8 @@ Then(~'^the book chapter "([^"]*)" was not stored twice$') { String entitled ->
}
And(~'^the system shows an error message$') { ->
- at BookChapterPage
- //assert page.readFlashMessage()
- //Thread.sleep(100000)
- assert page.hasErrorUploadFile()
+ at BookChapterSavePage
+ assert page.readFlashMessage() != null
}
diff --git a/test/cucumber/steps/MemberSteps.groovy b/test/cucumber/steps/MemberSteps.groovy
index b8b1b230..210c1aa6 100644
--- a/test/cucumber/steps/MemberSteps.groovy
+++ b/test/cucumber/steps/MemberSteps.groovy
@@ -143,9 +143,9 @@ Then(~'^I am still on the create member page with the error message$') { ->
}
-When(~'^I fill many user details with "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)"$') { String name, username, email, university, additionalInfo ->
- page.fillMemberDetails(name, username, email, university, additionalInfo)
-}
+//When(~'^I fill many user details with "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)"$') { String name, username, email, university, additionalInfo ->
+// page.fillMemberDetails(name, username, email, university, additionalInfo)
+//}
When(~'^I fill user details with "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)"$') { String name, username, email, university ->
page.fillSomeMemberDetails(name, username, email, university)
diff --git a/test/cucumber/steps/OrientationSteps.groovy b/test/cucumber/steps/OrientationSteps.groovy
index 04285dc7..c793fb09 100644
--- a/test/cucumber/steps/OrientationSteps.groovy
+++ b/test/cucumber/steps/OrientationSteps.groovy
@@ -12,14 +12,16 @@ import rgms.member.Member
import rgms.member.Orientation
import steps.MemberTestDataAndOperations
import steps.OrientationTestDataAndOperations
+import pages.LoginPage
+import org.apache.shiro.SecurityUtils
+import org.apache.shiro.subject.Subject
+import org.apache.shiro.util.ThreadContext
import static cucumber.api.groovy.EN.*
// create
Given(~'^the system has no orientations entitled "([^"]*)"$') { String tituloTese ->
- // Express the Regexp above with the code you wish you had
- orientation = Orientation.findByTituloTese(tituloTese)
- assert orientation == null
+ checkIfOrientationDoNotExists(tituloTese)
}
When(~'^I create a new orientation entitled "([^"]*)"$') { String tituloTese ->
@@ -28,8 +30,7 @@ When(~'^I create a new orientation entitled "([^"]*)"$') { String tituloTese ->
}
Then(~'^the orientation "([^"]*)" is properly stored by the system$') { String title ->
- orientation = Orientation.findByTituloTese(title)
- assert orientation != null
+ checkIfOrientationExists(title)
}
//delete
@@ -44,38 +45,33 @@ When(~'^I delete the orientation for "([^"]*)"$') { String title ->
}
Then(~'^the orientation for "([^"]*)" is properly removed by the system$') { String title ->
+ checkIfOrientationDoNotExists(title)
+}
+
+private void checkIfOrientationDoNotExists(String title) {
orientation = Orientation.findByTituloTese(title)
assert orientation == null
+}
+private void checkIfOrientationExists(String title){
+ orientation = Orientation.findByTituloTese(title)
+ assert orientation != null
}
//create web
Given(~'^I am at the create orientation page$') { ->
-
- Login()
-
- to PublicationsPage
- at PublicationsPage
- page.select("Orientation")
-
- at OrientationsPage
- page.selectNewOrientation()
-
- at OrientationCreatePage
+ goToOrientationCreatePage()
}
-When(~'^I fill the orientation title with "([^"]*)"$') { String title ->
+When(~'^I fill the orientation title with "([^"]*)"$') { title ->
+ fillOrientationWithTitleAndCreateThen(title)
+}
+private void fillOrientationWithTitleAndCreateThen(title) {
page.fillOrientationDetails(title)
page.selectCreateOrientation()
at OrientationShowPage
-
-
-}
-
-And(~'^I select the list orientation option$') { ->
- at OrientationShowPage
page.showList()
at OrientationsPage
@@ -84,33 +80,15 @@ And(~'^I select the list orientation option$') { ->
//edit web
Given(~'^I am at the orientation page$') { ->
-
- Login()
-
- to PublicationsPage
- at PublicationsPage
- page.select("Orientation")
-
- at OrientationsPage
+ goToOrientationCreatePage()
}
-And(~'^the orientation "([^"]*)" is stored in the system$') { String title ->
- page.selectNewOrientation()
-
- at OrientationCreatePage
- page.fillOrientationDetails(title)
- page.selectCreateOrientation()
-
- at OrientationShowPage
- page.showList()
-
- at OrientationsPage
- orientation = Orientation.findByTituloTese(title)
- assert orientation != null
+And(~'^the orientation "([^"]*)" is stored in the system$') { String title ->
+ fillOrientationWithTitleAndCreateThen(title)
+ checkIfOrientationExists(title)
}
-
When(~'^I select to view orientation "([^"]*)" in resulting list$') { String oldtitle ->
at OrientationsPage
@@ -131,25 +109,16 @@ When(~'^I select the change option at the orientation edit page$') { ->
Then(~'^the edited orientation "([^"]*)" is properly stored by the system$') { String title ->
at OrientationShowPage
- orientation = Orientation.findByTituloTese(title)
- assert orientation != null
+ checkIfOrientationExists(title)
}
+Then(~'^I am on the orientation show page with edition completed$'){ ->
+ at OrientationShowPage
+ assert page.readFlashMessage() != null
+}
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
- ThreadContext.put(ThreadContext.SECURITY_MANAGER_KEY,
- [getSubject: { subject } as SecurityManager])
- SecurityUtils.metaClass.static.getSubject = { subject }
-
+ loginController()
initialSize = Orientation.findAll().size()
}
@@ -162,8 +131,7 @@ When(~'^I upload a new orientation "([^"]*)"$') { filename ->
}
Then(~'the system has more orientations now$') { ->
- // restore metaclass
- GroovySystem.metaClassRegistry.setMetaClass(SecurityUtils, this.oldMetaClass)
+ logoutController()
finalSize = Orientation.findAll().size()
}
@@ -217,12 +185,6 @@ Then(~'^the orientation "([^"]*)" with orientated member "([^"]*)" is properly s
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
@@ -262,9 +224,38 @@ When(~'^I select the option remove at the orientation show page$') { ->
//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 loginController(){
+ def registry = GroovySystem.metaClassRegistry
+ this.oldMetaClass = registry.getMetaClass(SecurityUtils)
+ registry.removeMetaClass(SecurityUtils)
+ def subject = [getPrincipal: { "admin" },
+ isAuthenticated: { true }
+ ]as Subject
+ ThreadContext.put(ThreadContext.SECURITY_MANAGER_KEY,
+ [getSubject: { subject } as SecurityManager])
+ SecurityUtils.metaClass.static.getSubject = { subject }
+}
+
+def logoutController() {
+ // restore metaclass
+ GroovySystem.metaClassRegistry.setMetaClass(SecurityUtils, this.oldMetaClass)
+}
+
+def loginWeb() {
to LoginPage
at LoginPage
page.fillLoginData("admin", "adminadmin")
}
+
+private void goToOrientationCreatePage() {
+ loginWeb()
+
+ to PublicationsPage
+ at PublicationsPage
+ page.select("Orientation")
+
+ at OrientationsPage
+ page.selectNewOrientation()
+
+ at OrientationCreatePage
+}
diff --git a/test/cucumber/steps/ThesisSteps.groovy b/test/cucumber/steps/ThesisSteps.groovy
index cfae1180..1453f2bf 100644
--- a/test/cucumber/steps/ThesisSteps.groovy
+++ b/test/cucumber/steps/ThesisSteps.groovy
@@ -1,4 +1,7 @@
-import org.codehaus.groovy.grails.web.context.ServletContextHolder
+import pages.PublicationsPage
+import pages.thesis.ThesisEditPage
+import rgms.authentication.User
+import steps.ThesisTestDataAndOperations
import pages.LoginPage
import pages.PublicationsPage
import pages.ThesisPage
@@ -10,6 +13,7 @@ import steps.TestDataAndOperationsPublication
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 ->
article = Tese.findByTitle(title)
@@ -18,9 +22,9 @@ Given(~'^The system has no thesis entitled "([^"]*)"$') { String title ->
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 "([^"]*)"$') {
diff --git a/test/cucumber/steps/XMLImportSteps.groovy b/test/cucumber/steps/XMLImportSteps.groovy
index f5076a72..e6d08f0a 100644
--- a/test/cucumber/steps/XMLImportSteps.groovy
+++ b/test/cucumber/steps/XMLImportSteps.groovy
@@ -2,30 +2,30 @@ import pages.ArticlePages.ArticlesPage
import pages.BookChapterPage
import pages.Conferencia.ConferenciaPage
import pages.DissertationPage
+import pages.LoginPage
import pages.OrientationPages.OrientationsPage
import pages.XMLImportPage
import pages.ferramenta.FerramentaPage
import rgms.publication.*
import static cucumber.api.groovy.EN.*
import steps.TestDataAndOperations
+import CommonSteps
import org.apache.shiro.util.ThreadContext
import org.apache.shiro.subject.Subject
import org.apache.shiro.SecurityUtils
-Given(~'^the system has some publications stored$') {->
- // save old metaclass
+Given(~'^the system has some publications stored$') { ->
+
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 = Publication.findAll().size()
}
diff --git a/test/functional/pages/BookChapterPage.groovy b/test/functional/pages/BookChapterPage.groovy
index 1700fba8..98e14073 100644
--- a/test/functional/pages/BookChapterPage.groovy
+++ b/test/functional/pages/BookChapterPage.groovy
@@ -24,10 +24,11 @@ class BookChapterPage extends Page {
$('a.create').click()
}
- def checkBookChapterAtList(title, row) {
+ def checkBookChapterAtList(String title, row) {
def listDiv = $('div', id: 'list-bookChapter')
def bookTable = (listDiv.find('table'))[0]
def bookRows = bookTable.find('tbody').find('tr')
+ //noinspection GroovyAssignabilityCheck
def bookColumns = bookRows[row].find('td')
def testarbook = BookChapter.findByTitle(title)
diff --git a/test/functional/pages/BookChapterSavePage.groovy b/test/functional/pages/BookChapterSavePage.groovy
index b8896894..71a723ed 100644
--- a/test/functional/pages/BookChapterSavePage.groovy
+++ b/test/functional/pages/BookChapterSavePage.groovy
@@ -1,5 +1,6 @@
package pages
+
class BookChapterSavePage extends FormPage {
static url = "bookChapter/save"
diff --git a/test/functional/pages/LoginPage.groovy b/test/functional/pages/LoginPage.groovy
index acb7c442..6b116a93 100644
--- a/test/functional/pages/LoginPage.groovy
+++ b/test/functional/pages/LoginPage.groovy
@@ -1,6 +1,9 @@
package pages
import geb.Page
+import org.apache.shiro.SecurityUtils
+import org.apache.shiro.subject.Subject
+import org.apache.shiro.util.ThreadContext
class LoginPage extends Page {
def titleName = /${(new GetPageTitle()).getMessageServerLocale("user.login.title")}/
@@ -32,5 +35,4 @@ class LoginPage extends Page {
$("form").signIn().click()
}
-
}
diff --git a/test/functional/pages/OrientationPages/OrientationCreatePage.groovy b/test/functional/pages/OrientationPages/OrientationCreatePage.groovy
index 4099a4d9..5890401c 100644
--- a/test/functional/pages/OrientationPages/OrientationCreatePage.groovy
+++ b/test/functional/pages/OrientationPages/OrientationCreatePage.groovy
@@ -24,12 +24,7 @@ class OrientationCreatePage extends Page {
}
def fillOrientationDetails(title) {
- $("form").tipo = "Mestrado"
- $("form").orientando = "Tomaz"
- $("form").tituloTese = title
- $("form").anoPublicacao = 2013
- $("form").instituicao = "UFPE"
- $("form").curso = "Ciencia da Computacao"
+ fillOrientationDetailsWithGivenYear(title, 2013)
}
def fillOrientationDetailsWithGivenYear(title, year) {
diff --git a/test/functional/pages/OrientationPages/OrientationEditPage.groovy b/test/functional/pages/OrientationPages/OrientationEditPage.groovy
index 4d7de4d1..fa6430e7 100644
--- a/test/functional/pages/OrientationPages/OrientationEditPage.groovy
+++ b/test/functional/pages/OrientationPages/OrientationEditPage.groovy
@@ -43,5 +43,4 @@ class OrientationEditPage extends Page {
def delete() {
assert withConfirm(true) { $("form").find('input', class: 'delete').click() }
}
-
}
diff --git a/test/functional/pages/OrientationPages/OrientationsPage.groovy b/test/functional/pages/OrientationPages/OrientationsPage.groovy
index 0d8c91f8..4f0c676c 100644
--- a/test/functional/pages/OrientationPages/OrientationsPage.groovy
+++ b/test/functional/pages/OrientationPages/OrientationsPage.groovy
@@ -29,7 +29,7 @@ class OrientationsPage extends Page {
$('a', class: 'create').click()
}
- def selectViewOrientation(title) {
+ def selectViewOrientation(String title) {
def id = Orientation.findByTituloTese(title).id
$("a", text: id.toString()).click()
@@ -48,18 +48,25 @@ class OrientationsPage extends Page {
showLink[0].click()*/
}
- def checkOrientationAtList(title, row) {
- def orientationColumns = getRow()[row].find('td')
+ def checkOrientationAtList(String title, row) {
+ def orientationColumns = getTdOnRow(row)
def testorientation = Orientation.findByTituloTese(title)
+ //noinspection GroovyAssignabilityCheck
assert orientationColumns[1].text() == testorientation.tipo
+ //noinspection GroovyAssignabilityCheck
assert orientationColumns[2].text() == testorientation.orientando
+ //noinspection GroovyAssignabilityCheck
assert orientationColumns[4].text() == testorientation.tituloTese
}
- def checkIfOrientationListIsEmpty() {
- def conferenciaColumns = getRow()[0].find('td')
+ private Object getTdOnRow(row) {
+ //noinspection GroovyAssignabilityCheck
+ getRow()[row].find('td')
+ }
+ def checkIfOrientationListIsEmpty() {
+ def conferenciaColumns = getTdOnRow(0)
assert conferenciaColumns.size() < 8
}
diff --git a/test/functional/pages/ThesisPage.groovy b/test/functional/pages/ThesisPage.groovy
index 61eca4bb..87603075 100644
--- a/test/functional/pages/ThesisPage.groovy
+++ b/test/functional/pages/ThesisPage.groovy
@@ -32,7 +32,6 @@ class ThesisPage extends Page {
def listDiv = $('div', id: 'list-tese')
def thesisTable = (listDiv.find('table'))[0]
def thesisRow = thesisTable.find('tbody').find('tr')
-
return thesisRow
}
diff --git a/test/functional/pages/thesis/ThesisShowPage.groovy b/test/functional/pages/thesis/ThesisShowPage.groovy
index ef66f6b1..4443d793 100644
--- a/test/functional/pages/thesis/ThesisShowPage.groovy
+++ b/test/functional/pages/thesis/ThesisShowPage.groovy
@@ -2,6 +2,7 @@ package pages.thesis
import geb.Page
import pages.GetPageTitle
+import rgms.publication.Tese
class ThesisShowPage extends Page {
static url = "tese/show"
diff --git a/test/functional/steps/BookChapterTestDataAndOperations.groovy b/test/functional/steps/BookChapterTestDataAndOperations.groovy
index de824c0f..f4a0a0c7 100644
--- a/test/functional/steps/BookChapterTestDataAndOperations.groovy
+++ b/test/functional/steps/BookChapterTestDataAndOperations.groovy
@@ -30,7 +30,7 @@ class BookChapterTestDataAndOperations {
}
}
- static public boolean bookChapterCompatibleTo(bookChapter, title) {
+ static public boolean bookChapterCompatibleTo(bookChapter, String title) {
def testBookChapter = findBookChapterByTitle(title)
def compatible = false
if (testBookChapter == null && bookChapter == null) {
@@ -44,7 +44,7 @@ class BookChapterTestDataAndOperations {
return compatible
}
- static public void uploadBookChapter(filename) {
+ static public void uploadBookChapter(String filename) {
def cont = new XMLController()
def xml = new File(filename);
def records = new XmlParser()
@@ -54,8 +54,7 @@ class BookChapterTestDataAndOperations {
static public void createBookChapter(String title, String filename) {
def cont = new BookChapterController()
- def date = new Date()
- cont.params << BookChapterTestDataAndOperations.findBookChapterByTitle(title) << [file: filename]
+ cont.params << findBookChapterByTitle(title) << [file: filename]
cont.request.setContent(new byte[1000])
cont.create()
cont.save()
@@ -66,12 +65,13 @@ class BookChapterTestDataAndOperations {
def testBookChapter = BookChapter.findByTitle(title)
def cont = new BookChapterController()
cont.params << [id: testBookChapter.id]
- cont.delete()
+ cont.delete(testBookChapter.id)
}
- static public boolean containsBookChapter(title, bookList) {
+ static public boolean containsBookChapter(String title) {
def testarbook = BookChapter.findByTitle(title)
def cont = new BookChapterController()
+ //noinspection GroovyAssignabilityCheck
def result = cont.list().bookChapterInstanceList
return result.contains(testarbook)
}
diff --git a/test/functional/steps/OrientationTestDataAndOperations.groovy b/test/functional/steps/OrientationTestDataAndOperations.groovy
index ea5a3ee1..ee3b1bc1 100644
--- a/test/functional/steps/OrientationTestDataAndOperations.groovy
+++ b/test/functional/steps/OrientationTestDataAndOperations.groovy
@@ -3,6 +3,7 @@ package steps
import rgms.member.Member
import rgms.member.Orientation
import rgms.member.OrientationController
+import steps.MemberTestDataAndOperations
import rgms.publication.XMLController
/**
@@ -14,16 +15,7 @@ import rgms.publication.XMLController
*/
class OrientationTestDataAndOperations {
- static members = [
- [name: "Rodolfo Ferraz", username: "usernametest", email: "rodolfofake@gmail.com",
- status: "Graduate Student", university: "UFPE", enabled: true
- ],
- [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 members = MemberTestDataAndOperations.members
static orientations = [
[tipo: "Mestrado", orientando: "Tomaz", tituloTese: "The Book is on the table", anoPublicacao: 2013, instituicao: "UFPE", orientador: (new Member(members[0]))]
@@ -42,6 +34,10 @@ class OrientationTestDataAndOperations {
memberCreater.create()
memberCreater.save()
def member = Member.findByName(memberCreater.name)
+ createOrientationAux(cont, tituloTese, member)
+ }
+
+ 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.
cont.create()
@@ -52,11 +48,7 @@ class OrientationTestDataAndOperations {
static public void createOrientationWithMenber(String tituloTese, member) {
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()
+ createOrientationAux(cont, tituloTese, new Member(member))
}
static public void removeOrientation(String tituloTese) {
diff --git a/test/functional/steps/TestDataAndOperations.groovy b/test/functional/steps/TestDataAndOperations.groovy
index e516ed4b..b6c332e9 100644
--- a/test/functional/steps/TestDataAndOperations.groovy
+++ b/test/functional/steps/TestDataAndOperations.groovy
@@ -300,8 +300,8 @@ class TestDataAndOperations {
-
- static public void createOrientation(String tituloTese) {
+// Está sendo usado a funçao do arquivo OrientatationTestDataAndOperations
+ /* 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]))]
@@ -310,7 +310,7 @@ class TestDataAndOperations {
cont.save()
cont.response.reset()
}
-
+*/
//article
diff --git a/test/functional/steps/TestDataDissertacao.groovy b/test/functional/steps/TestDataDissertacao.groovy
index 5505f705..a7e034fa 100644
--- a/test/functional/steps/TestDataDissertacao.groovy
+++ b/test/functional/steps/TestDataDissertacao.groovy
@@ -8,13 +8,7 @@ class TestDataDissertacao
static public void createDissertacao(String title, filename, school) {
def cont = new DissertacaoController()
- def date = new Date()
- cont.params << [title: title, publicationDate: new Date(2013, 03, 02),
- school: school, address: "Boa Viagem", file: filename]
- cont.request.setContent(new byte[1000]) // Could also vary the request content.
- cont.create()
- cont.save()
- cont.response.reset()
+ ThesisOrDissertationTestDataAndOperations.createThesisOrDissertation(title,filename,school,cont)
}
diff --git a/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy b/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy
index 251a22dd..3ee5bc62 100644
--- a/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy
+++ b/test/functional/steps/ThesisOrDissertationTestDataAndOperations.groovy
@@ -1,13 +1,13 @@
package steps
import rgms.publication.Dissertacao
+import rgms.publication.Publication
import rgms.publication.Tese
import rgms.publication.TeseController
class ThesisOrDissertationTestDataAndOperations {
static protected void createThesisOrDissertation(String title, filename, school, cont) {
- def date = new Date()
cont.params << [title: title, publicationDate: new Date(2013, 03, 02),
school: school, address: "Boa Viagem", file: filename]
cont.request.setContent(new byte[1000]) // Could also vary the request content.