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

Refactor hairdressing #110

Merged
merged 2 commits into from
Jun 5, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,10 @@ public String processDeleteHairdressingForm(@PathVariable("hairdressingId") int

private Hairdressing convertToEntity(HairdressingDTO dto) throws MappingException {
Hairdressing hairdressing = new Hairdressing();

try {
String owner = SecurityContextHolder.getContext().getAuthentication().getName();
Pet pet = this.petService.findPetsByName(dto.getPetName(), owner);
hairdressing.setPet(pet);
} catch (DataAccessException e) {
throw new MappingException("pet", "Not existance", "Pet does not exist");
}

String owner = SecurityContextHolder.getContext().getAuthentication().getName();
Pet pet = getOwnerPet(dto, owner);

hairdressing.setPet(pet);
hairdressing.setCuidado(dto.getCuidado());
hairdressing.setDate(dto.getDate());
hairdressing.setDescription(dto.getDescription());
Expand All @@ -285,6 +280,16 @@ private Hairdressing convertToEntity(HairdressingDTO dto) throws MappingExceptio
return hairdressing;
}

private Pet getOwnerPet(HairdressingDTO dto, String owner) throws MappingException {
Pet result;
try {
result = this.petService.findPetsByName(dto.getPetName(), owner);
} catch (DataAccessException e) {
throw new MappingException("pet", "Not existance", "Pet does not exist");
}
return result;
}

private HairdressingDTO convertToDto(Hairdressing entity) {
HairdressingDTO dto = new HairdressingDTO();
dto.setDate(entity.getDate());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package dp2

import scala.concurrent.duration._

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._

class Historia10y18Diagnosis extends Simulation {

val httpProtocol = http
.baseUrl("http://www.dp2.com")
.inferHtmlResources(BlackList(""".*.css""", """.*.js""", """.*.ico""", """.*.png""", """.*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", """.*\.ico""", """.*\.woff""", """.*\.woff2""", """.*\.(t|o)tf""", """.*\.png""", """.*detectportal\.firefox\.com.*"""), WhiteList())
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("es-ES,es;q=0.9,en;q=0.8")
.userAgentHeader("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36")

val headers_0 = Map(
"Proxy-Connection" -> "keep-alive",
"Upgrade-Insecure-Requests" -> "1")

val headers_2 = Map(
"Accept" -> "image/webp,image/apng,image/*,*/*;q=0.8",
"Proxy-Connection" -> "keep-alive")

val headers_3 = Map(
"Origin" -> "http://www.dp2.com",
"Proxy-Connection" -> "keep-alive",
"Upgrade-Insecure-Requests" -> "1")

object Home{
var home = exec(http("Home")
.get("/")
.headers(headers_0))
.pause(10)
}

object LoginOwner{
var loginOwner = exec(http("Login")
.get("/login")
.headers(headers_0)
.resources(http("request_2")
.get("/login")
.headers(headers_2))
.check(css("input[name=_csrf]", "value").saveAs("stoken")))
.pause(13)
.exec(http("Logged")
.post("/login")
.headers(headers_3)
.formParam("username", "george")
.formParam("password", "george")
.formParam("_csrf", "$[stoken]"))
.pause(10)
}

object LoginAdmn{
var loginAdmn = exec(http("Login")
.get("/login")
.headers(headers_0)
.resources(http("request_2")
.get("/login")
.headers(headers_2))
.check(css("input[name=_csrf]", "value").saveAs("stoken")))
.pause(13)
.exec(http("Logged")
.post("/login")
.headers(headers_3)
.formParam("username", "admin")
.formParam("password", "admin")
.formParam("_csrf", "$[stoken]"))
.pause(10)
}

object ListHairdressingsOwner{
var listHairdressingsOwner = exec(http("ListHairdressingsOwner")
.get("/hairdressings/owner")
.headers(headers_0))
.pause(19)
}

object ListHairdressingsAdmn{
var listHairdressingsAdmn = exec(http("ListHairdressingsAdmn")
.get("/hairdressings")
.headers(headers_0))
.pause(16)
}

val CasoPositivoScn = scenario("Historia10y18CasoPositivo").exec(Home.home,
LoginOwner.loginOwner,
ListHairdressingsOwner.listHairdressingsOwner)

val CasoNegativoScn = scenario("Historia10y18CasoNegativo").exec(Home.home,
LoginAdmn.loginAdmn,
ListHairdressingsAdmn.listHairdressingsAdmn)


setUp(
CasoPositivoScn.inject(rampUsers(5500) during (10 seconds)),
CasoNegativoScn.inject(rampUsers(5500) during (10 seconds))
).protocols(httpProtocol)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package dp2

import scala.concurrent.duration._

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._

class Historia6y7Diagnosis extends Simulation {

val httpProtocol = http
.baseUrl("http://www.dp2.com")
.inferHtmlResources(BlackList(""".*.css""", """.*.js""", """.*.ico""", """.*.png""", """.*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", """.*\.ico""", """.*\.woff""", """.*\.woff2""", """.*\.(t|o)tf""", """.*\.png""", """.*detectportal\.firefox\.com.*"""), WhiteList())
.acceptEncodingHeader("gzip, deflate")
.userAgentHeader("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36")

val headers_0 = Map(
"Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Language" -> "es-ES,es;q=0.9,en;q=0.8",
"Proxy-Connection" -> "keep-alive",
"Upgrade-Insecure-Requests" -> "1")

val headers_2 = Map(
"Accept" -> "image/webp,image/apng,image/*,*/*;q=0.8",
"Accept-Language" -> "es-ES,es;q=0.9,en;q=0.8",
"Proxy-Connection" -> "keep-alive")

val headers_3 = Map(
"Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Language" -> "es-ES,es;q=0.9,en;q=0.8",
"Origin" -> "http://www.dp2.com",
"Proxy-Connection" -> "keep-alive",
"Upgrade-Insecure-Requests" -> "1")

val headers_8 = Map(
"A-IM" -> "x-bm,gzip",
"Proxy-Connection" -> "keep-alive")

val uri1 = "http://clientservices.googleapis.com/chrome-variations/seed"


object Home{
var home = exec(http("Home")
.get("/")
.headers(headers_0))
.pause(10)
}

object Login{
var login = exec(http("Login")
.get("/login")
.headers(headers_0)
.resources(http("request_2")
.get("/login")
.headers(headers_2))
.check(css("input[name=_csrf]", "value").saveAs("stoken")))
.pause(13)
.exec(http("Logged")
.post("/login")
.headers(headers_3)
.formParam("username", "george")
.formParam("password", "george")
.formParam("_csrf", "$[stoken]"))
.pause(10)
}

object ListHairdressings{
var listHairdressings = exec(http("ListHairdressings")
.get("/hairdressings/owner")
.headers(headers_0))
.pause(13)
}

object AddHairdressing{
var addHairdressing = exec(http("AddHairdressingForm")
.get("/hairdressings/new")
.headers(headers_0)
.headers(headers_2)
.check(css("input[name=_csrf]", "value").saveAs("stoken")))
.pause(36)
.exec(http("AddHairdressing")
.post("/hairdressings/new")
.headers(headers_3)
.formParam("date", "2050/06/26")
.formParam("description", "Hola")
.formParam("time", "6:00")
.formParam("cuidado", "ESTETICA")
.formParam("petName", "Leo")
.formParam("_csrf", "${stoken}"))
.pause(18)
}

object AddHairdressingEmpty{
var addHairdressingEmpty = exec(http("AddHairdressingForm")
.get("/hairdressings/new")
.headers(headers_0)
.headers(headers_2)
.check(css("input[name=_csrf]", "value").saveAs("stoken")))
.pause(22)
.exec(http("AddHairdressing")
.post("/hairdressings/new")
.headers(headers_3)
.formParam("date", "")
.formParam("description", "")
.formParam("petName", "Leo")
.formParam("_csrf", "${stoken}"))
.pause(71)
}

object ShowHairdressing{
var showHairdressing = exec(http("ShowHairdressing")
.get("/hairdressings/100")
.headers(headers_0))
.pause(6)
}

object DeleteHairdressing{
var deleteHairdressing = exec(http("DeleteHairdressing")
.get("/hairdressings/100/delete")
.headers(headers_0))
.pause(16)
}

object DeleteHairdressingUnauthorised{
var deleteHairdressingUnauthorised = exec(http("DeleteHairdressingUnauthorised")
.get("/hairdressings/90/delete")
.headers(headers_0))
.pause(15)
}




val CasoPositivoScn = scenario("Historia6y7CasoPositivo").exec(Home.home,
Login.login,
ListHairdressings.listHairdressings,
AddHairdressing.addHairdressing,
ShowHairdressing.showHairdressing,
DeleteHairdressing.deleteHairdressing)

val CasoNegativoScn = scenario("Historia6y7CasoNegativo").exec(Home.home,
Login.login,
ListHairdressings.listHairdressings,
AddHairdressingEmpty.addHairdressingEmpty,
DeleteHairdressingUnauthorised.deleteHairdressingUnauthorised)


setUp(
CasoPositivoScn.inject(rampUsers(5500) during (10 seconds)),
CasoNegativoScn.inject(rampUsers(5500) during (10 seconds))
).protocols(httpProtocol)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading