Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refatorization #342

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added chromedrivers/chromedriver.exe
Binary file not shown.
11 changes: 6 additions & 5 deletions grails-app/controllers/rgms/member/MemberController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class MemberController {

def memberInstance = new Member(params)
def userInstance = new User(params)

def password = ""

if (!userInstance.passwordHash) {
Expand All @@ -63,12 +62,13 @@ class MemberController {
userInstance.passwordHash = new Sha256Hash(password).toHex()
}
userInstance.passwordChangeRequiredOnNextLogon = true

if (!memberInstance.save(flush: true)) {
memberInstance.errors.each {
println it
}
render(view: "create", model: [userMemberInstanceList: [memberInstance: memberInstance, userInstance: userInstance]])
return
}

userInstance.author = memberInstance;
if (!userInstance.save(flush: true)) {
userInstance.errors.each {
Expand All @@ -84,10 +84,11 @@ class MemberController {
def title = message(code: 'mail.title.create.account')
def content = message(code: 'mail.body.create.account', args: [memberInstance.name, params.username, password, createLink(absolute: true, uri: '/')])

//Not Working
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VDDM: Comentado porque não estava funcionando

EmailService emailService = new EmailService();
emailService.sendEmail(email, mailSender, title, content)
//emailService.sendEmail(email, mailSender, title, content)

flash.message = message(code: 'default.created.message', args: [message(code: 'member.label', default: 'Member'), memberInstance.id])
//flash.message = message(code: 'default.created.message', args: [message(code: 'member.label', default: 'Member'), memberInstance.id])
redirect(action: "show", id: memberInstance.id)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ class TeseController extends ThesisOrDissertationController {
}

def save() {
saveThesisOrDissertation("Tese", params)
String file = params['file']
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VDDM: Implementação da issue #156 , atualmente apenas formatos do tipo doc e pdf.

def format = file.substring(file.indexOf('.')+1,file.size())
if(format == 'doc' || format == 'pdf') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(mfl3) Aqui não seria melhor criar um método genérico para validar o formato do arquivo? E se no futuro for necessário alterar a definição de "formato válido" (e.g se eu passar a aceitar arquivos no formato .odt)?

saveThesisOrDissertation("Tese", params)
}
}

def show() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ class ThesisOrDissertationController {

def saveThesisOrDissertation(String thesisOrDissertation, params) {
//noinspection GroovyAssignabilityCheck
def instance = getClassByName(thesisOrDissertation).newInstance(params)
PublicationController pb = new PublicationController()
def instance = null
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VDDM: Código mais claro

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(mfl3) Tem dois trechos de código com "if(thesisOrDissertation == 'Tese')". Uma possível melhora seria colocá-los em um único if.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Que tipo de refatoração é essa?
(Tentei identificar entre Mudar nome de variável, Mudar palavras para constantes, definição de If, extrair classe, extrair método, desenvolver if e substituir método com objeto método.)

if(thesisOrDissertation == 'Tese')
instance = new Tese(params)
else
instance = new Dissertacao(params)
def duplicated
if (thesisOrDissertation == "Tese") {
//noinspection GroovyAssignabilityCheck
Expand All @@ -50,7 +53,10 @@ class ThesisOrDissertationController {
render(view: "create", model: [instance: instance])
return
}
if (!pb.upload(instance as Publication) || !instance.save(flush: true)) {
if (!instance.save(flush: true)) {
instance.errors.each {
println it
}
render(view: "create", model: [instance: instance])
return
}
Expand Down
5 changes: 5 additions & 0 deletions test/cucumber/Authentication.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ Scenario: New user register with invalid email fail message
When I try to create a "newuser" username with the "invalid email abcde" email
Then A message indicating the email is invalid is displayed

Scenario: New user register with a small password
Given I am at the Login Page
When I try to create a "newuser" username with a password less than 5 characters
Then A message indicating the password is too small

Scenario: Try to access Member List Page without being logged in
Given I am not logged
When I directly access the Member List Page
Expand Down
26 changes: 9 additions & 17 deletions test/cucumber/Book.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ Feature: Book
I want to add, remove and modify books I have published
so that I can generate web pages and reports containing these books

Scenario: new book
Given the system has no book entitled "SPL Development"
When I create the book "SPL Development" with file name "HSPLE.pdf"
Then the book "SPL Development" is properly stored by the system

@scc
Scenario: remove book
Given the book "SPL Development" is stored in the system with file name "NGSPL-2.pdf"
Given the book "SPL Development" is stored in the system with file name "SPL-2.pdf"
When I remove the book "SPL Development"
Then the book "SPL Development" is properly removed by the system

Expand All @@ -19,19 +15,15 @@ Feature: Book
When I create the book "SPL Development" with file name "NGSPL-0.pdf"
Then the book "SPL Development" is not stored twice

Scenario: edit existing book
Given the book "SPL Development" is stored in the system with file name "HSPLE.pdf"
When I edit the book title from "SPL Development" to "New Title"
Then the book "New Title" is properly updated by the system

Scenario: upload book with a file
Given the system has no books stored
When I upload the books of "curriculo.xml"
Then the system has all the books of the xml file

Scenario: new book web
Given I am at the book page
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
@scc
Scenario: edit existing book with a invalid name
Given the book "SPL Development" is stored in the system with file name "HSPLE.pdf"
When I edit the book title from "SPL Development" to "ESS Book"
And there is already a stored book named "ESS Book"
Then the book "SPL Development" will not be modified
#if ($newBook)
18 changes: 8 additions & 10 deletions test/cucumber/BookChapter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Feature: BookChapter
When I remove the book chapter "Next Generation Software Product Line Engineering"
* the book chapter "Next Generation Software Product Line Engineering" is properly removed by the system

#if ($BookChapter)
@mjgfl
Scenario: modify existing book chapter
Given the book chapter "Next Generation Software Product Line Engineering" is stored in the system with file name "NGSPL-2.pdf"
When I edit the book chapter title from "Next Generation Software Product Line Engineering" to "Next Generation Software Product Line Engineering REVIEWED"
Then the book chapter "Next Generation Software Product Line Engineering" is properly updated by the system
#end

Scenario: register book chapter with invalid data
Given I am at the book chapter page
And I select the new book chapter option at the book chapter page
Expand Down Expand Up @@ -61,14 +69,4 @@ Feature: BookChapter
And the book chapter "Next Generation Software Product Line Engineering" with file name "Ngs.pdf" was created before
Then My resulting book chapter list contains "Next Generation Software Product Line Engineering"

Scenario: upload book chapter with a file
Given the system has some book chapters stored
When I upload the book chapters of "curriculo.xml"
Then the system has all the book chapters of the xml file

Scenario: upload book chapters without a file
Given I am at the publications menu
When I select the Book Chapter option at the program menu
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
20 changes: 20 additions & 0 deletions test/cucumber/Ferramenta.feature
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,23 @@ Feature: Ferramenta
And fill the others fields with valid values without Titulo
Then I am still on create new ferramenta page
And the ferramenta is not displayed in the ferramentas list page

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VDDM: Cenário novo implementado
--> Permite criar ferramenta usando website
--> Mostra a listagem de ferramentas

#if($ferramentaWithWebsite)
@vddm
Scenario: new ferramenta with website
Given the system has no ferramenta entitled "Target"
When I create the ferramenta "Target" with file name "target.pdf" with "www.targed.com" as its website
Then the ferramenta "Target" is stored

#if($list)
@vddm
Scenario: list ferramenta web
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Achei esse cenário muito grande

Given I am at the publications menu
When I select the "Ferramenta" option at the publications menu
And I select the "create" option at the ferramenta page
Then I can create a ferramenta with name "Joee"
And I select the "create" option at the show page
And I can create a ferramenta with name "Joee1"
When I select the "list" option at the show page
Then I can see all existing ferramentas in the system and the "Joee" and "Joee1" ferramentas
#end
1 change: 1 addition & 0 deletions test/cucumber/Funder.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Feature: Funder
When I create a funder with code "12345"
Then there is only one funder with code "12345" in the system


Scenario: new funder web
Given I am at the create funder page
When I fill the funder code with "12345"
Expand Down
81 changes: 65 additions & 16 deletions test/cucumber/Member.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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" "[email protected]" "UFPE" "Graduate Student"
Expand All @@ -51,22 +58,39 @@ Feature: member
When I fill some user details with "jose" "josesilva" "[email protected]" "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" "[email protected]" "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
Expand All @@ -75,4 +99,29 @@ 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
#end

#if($memberInfo)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VDDM: Cenário novo implementado
--> Permite a edição do membro assim como um cenário de GUI

@vddm
Scenario: editing member information
Given the system has member with "Victor Monteiro","rgmsTest", "[email protected]", "UFPE", "12345", "www.g.com.br", "Brazil", "Graduate Student"
When I edit the "[email protected]"'s "email" for "[email protected]"
Then "[email protected]"'s information is updated and saved in the system

@vddm
Scenario: editing member
Given I am at the member page
When I click the "1" member id
And I Click the option "edit" on Member Edition Page
And I change the member's "name" by "Victor Monteiro"
Then I can see the member's name is now "Victor Monteiro"
#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

15 changes: 14 additions & 1 deletion test/cucumber/News.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ Feature: news
When I request to update the news from Twitter to research group "SPG"
Then news of "SPG" research group has been updated

Scenario: disintegrate Twitter account
Given the research group "SPG" in the system has a Twitter account associated
When When I disassociate account "HumanBrainProj" group to "SPG"
Then "SPG" research group has a twitter account "@HumanBrainProj" registered

Scenario: consecutive update without duplicate news
Given the research group "SPG" in the system has a Twitter account "@HumanBrainProj" associated
And twitter account associated with "SPG" research group has been updated once
Expand All @@ -60,14 +65,22 @@ Feature: news
When I edit the news with description "noticiaTeste" to "newDescription", date "07-04-2012" and "SPG" research group
Then the news "newDescription", date "07-04-2012" and "SPG" research group is properly updated by the system


Scenario: edit existing news with a invalid description
Given the system has a news with description "noticiaTeste" and date "07-04-2012" for "SPG" research group
When I edit the news with description "noticiaTeste" to "newDescription", date "07-04-2012" and "SPG" research group
And the news "newDescription", date "07-04-2012" and "SPG" research group already exist
Then the news "noticiaTeste", date "07-04-2012" and "SPG" will not be be edited


Scenario: remove existing news web
Given I am at the publications menu
When I select the news page
And the news "Noticia1" is stored in the system
And I select the option to remove in news show page
Then the news "Noticia1" is properly removed by the system

Scenario: new invalid news (invalid date)
Scenario: new invalid news (invalid description)
Given the system has no news with description "teste" and date "31-02-2013" for "SPG" research group
When I try to create a news with description "teste" and date "31-02-2013" for "SPG" research group
Then the news with description "teste", date "31-02-2013" and "SPG" research group is not stored by the system because it is invalid
37 changes: 29 additions & 8 deletions test/cucumber/ResearchGroup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,58 @@ Feature: research group
When I modify the name of research group entitled "modcs-3" to none
Then the research group is not stored in the system because it has no name

#if ($ResearchGroup)
Scenario: editing the researchgroup's name to a invalid name by size
Given the system has a research group entitled "modcs-3" with the description "modcs-3 research group" stored in the system
When I modify the name of research group entitled "modcs-3" to "modcs 123456789"
Then the research group "modcs 123456789" is not stored in the system because exceeds the number of characters allowed
#end

Scenario:edit research group
#if ($ResearchGroup)
Scenario:edit research group
Given the system has a research group entitled "modcs" with the description "modcs research group" stored in the system
When I modify the research group entitled "modcs" to "modcs 123" and its description to "modcs research group 1234"
When I modify the research group entitled "modcs" to "modcs 123"
And I modify its description to "modcs research group 1234"
Then the edited research group "modcs 123" with description "modcs research group 1234" is properly stored in the system

#end

Scenario:delete research group
Given the system has a research group entitled "modcs" with the description "modcs research group" stored in the system
When I delete the research group entitled "modcs"
Then the research group "modcs" is properly deleted of the system



Scenario: new research group and show via web browser
Given I am at the publications menu
When I select the "Research Group" option at the publications menu
And I select the new research group option at research group list page
Then I can fill the research group details with name "modcs" and create a new one

#if($ResearchGroup)
Scenario: new invalid search group web (name field exceeded the limit of characters)
Given I am at the new Research Group page
When I fill all group information
And I fill the field name with "mdocs 123456789"
And I select to create the group
Then an error message is showed for the name field
#end

#if($ResearchGroup)
Scenario: show research group via web browser
Given I am at the publications menu
Given I am at Research Group list menu
And the system has a Research Group named "grupo" stored in the system
And I am at Research Group list menu
And I select a research group called "grupo"
Then the system will show the details of this research group
#end

#if($ResearchGroup)
Scenario: edit research group via web browser
Given I am at the publications menu
Given I am at Research Group list menu
And the system has a Research Group named "PESQUISA" stored in the system
And I am at Research Group list menu
When I select a research group called "PESQUISA"
And I select the edit option
Then I can change the research group name to "rgms" and save it
#end



Expand Down
Loading