-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from hmcts/task/JM-5314
Added postpone tests
- Loading branch information
Showing
9 changed files
with
316 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/gatling/java/uk/gov/hmcts/juror/performance/scenario/AvailablePoolsScenario.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package uk.gov.hmcts.juror.performance.scenario; | ||
|
||
import io.gatling.javaapi.core.ChainBuilder; | ||
import io.gatling.javaapi.http.HttpRequestActionBuilder; | ||
import uk.gov.hmcts.juror.performance.Util; | ||
import uk.gov.hmcts.juror.support.generation.generators.value.RandomFromCollectionGeneratorImpl; | ||
|
||
import static io.gatling.javaapi.core.CoreDsl.css; | ||
import static io.gatling.javaapi.core.CoreDsl.exec; | ||
import static io.gatling.javaapi.core.CoreDsl.group; | ||
import static io.gatling.javaapi.core.CoreDsl.substring; | ||
import static io.gatling.javaapi.http.HttpDsl.http; | ||
|
||
public class AvailablePoolsScenario { | ||
private static final String GROUP_NAME = "Available Pools"; | ||
private static final String BASE_URL = "/juror-management/juror/#{juror_number}/available-pools"; | ||
|
||
|
||
public static ChainBuilder postDeferralMaintenance() { | ||
return postDeferralMaintenance(Util.getNewScenarioId()); | ||
} | ||
|
||
public static ChainBuilder postDeferralMaintenance(String scenarioId) { | ||
return postPoolRequestInternal(scenarioId, "Deferral Maintenance"); | ||
} | ||
|
||
public static HttpRequestActionBuilder applyChecks(HttpRequestActionBuilder http) { | ||
return http | ||
//Validates we are on either the select a pool for this date or no active pools screen | ||
.check(css("h1.govuk-heading-l") | ||
.transform(value -> { | ||
if (value != null && ( | ||
value.equals("There are no active pools for this date") | ||
|| value.equals("Select a pool for this date")) | ||
) { | ||
return value; | ||
} | ||
return null; | ||
}).notNull().saveAs("headingValue")) | ||
//If we are on select pool screen sae all the shown pools for later use | ||
.checkIf(session -> { | ||
String headingValue = session.getString("headingValue"); | ||
return headingValue != null | ||
&& headingValue.equals("Select a pool for this date"); | ||
}).then(css("input[name=\"deferralDateAndPool\"]","value") | ||
.findAll().notNull().saveAs("deferralDateAndPools") | ||
); | ||
} | ||
|
||
public static ChainBuilder postPoolRequest() { | ||
return postPoolRequest(Util.getNewScenarioId()); | ||
} | ||
|
||
public static ChainBuilder postPoolRequest(String scenarioId) { | ||
return exec(session -> session.set("deferralDateAndPoolDate", | ||
new RandomFromCollectionGeneratorImpl<>(session.getList("deferralDateAndPools")) | ||
.generate())) | ||
.exec(postPoolRequestInternal(scenarioId, "Pool Request")); | ||
} | ||
|
||
public static ChainBuilder postPoolRequestInternal(String scenarioId, String name) { | ||
return group(scenarioId + GROUP_NAME + " - POST - " + name) | ||
.on(exec( | ||
http("POST - Available pools - " + name) | ||
.post(BASE_URL) | ||
.headers(Util.COMMON_HEADERS) | ||
.formParam("deferralDateAndPool", "#{deferralDateAndPoolDate}") | ||
.formParam("_csrf", "#{csrf}") | ||
.check(Util.validatePageIdentifier("juror record - overview")) | ||
.check(substring("Juror record updated: <b>Postponed</b>")) | ||
) | ||
); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...java/uk/gov/hmcts/juror/performance/scenario/jurorrecord/JurorRecordDeferralScenario.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package uk.gov.hmcts.juror.performance.scenario.jurorrecord; | ||
|
||
import io.gatling.javaapi.core.ChainBuilder; | ||
import uk.gov.hmcts.juror.performance.Feeders; | ||
import uk.gov.hmcts.juror.performance.Util; | ||
|
||
import static io.gatling.javaapi.core.CoreDsl.feed; | ||
import static io.gatling.javaapi.core.CoreDsl.group; | ||
import static io.gatling.javaapi.core.CoreDsl.substring; | ||
import static io.gatling.javaapi.http.HttpDsl.http; | ||
|
||
public class JurorRecordDeferralScenario { | ||
private static final String GROUP_NAME = JurorRecordUpdateScenario.GROUP_NAME + " - deferral"; | ||
private static final String BASE_URL = JurorRecordUpdateScenario.BASE_URL + "/deferral"; | ||
|
||
public static ChainBuilder postDeferalGrant() { | ||
return postDeferalGrant(Util.getNewScenarioId()); | ||
} | ||
|
||
public static ChainBuilder postDeferalGrant(String scenarioId) { | ||
return group(scenarioId + GROUP_NAME + " - POST - GRANT") | ||
.on( | ||
feed(Feeders.DEFERAL_CODE_FEEDER).exec( | ||
http("POST - Juror Record - Update Record - deferral - GRANT") | ||
.post(BASE_URL) | ||
.headers(Util.COMMON_HEADERS) | ||
.formParam("deferralReason", "#{exc_code}") | ||
.formParam("deferralDecision", "GRANT") | ||
.formParam("deferralDateSelection", "otherDate") | ||
.formParam("deferralDate", Util.createDateString(Util.STANDARD_DATE_FORMATTER)) | ||
.formParam("hearingDate", "") | ||
.formParam("jurorNumber", "#{juror_number}") | ||
.formParam("_csrf", "#{csrf}") | ||
.formParam("version", "") | ||
.check(Util.validatePageIdentifier("juror record - overview")) | ||
.check(substring("Deferral granted")) | ||
) | ||
); | ||
} | ||
|
||
public static ChainBuilder postDeferalRefuse() { | ||
return postDeferalRefuse(Util.getNewScenarioId()); | ||
} | ||
|
||
public static ChainBuilder postDeferalRefuse(String scenarioId) { | ||
return group(scenarioId + GROUP_NAME + " - POST - REFUSE") | ||
.on( | ||
feed(Feeders.DEFERAL_CODE_FEEDER) | ||
.exec( | ||
http("POST - Juror Record - Update Record - deferral - REFUSE") | ||
.post(BASE_URL) | ||
.headers(Util.COMMON_HEADERS) | ||
.formParam("deferralReason", "#{exc_code}") | ||
.formParam("deferralDecision", "REFUSE") | ||
.formParam("deferralDate", "") | ||
.formParam("hearingDate", "") | ||
.formParam("jurorNumber", "#{juror_number}") | ||
.formParam("_csrf", "#{csrf}") | ||
.formParam("version", "") | ||
.check(Util.validatePageIdentifier("juror record - overview")) | ||
.check(substring("Deferral refused")) | ||
) | ||
); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
.../java/uk/gov/hmcts/juror/performance/scenario/jurorrecord/JurorRecordExcusalScenario.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package uk.gov.hmcts.juror.performance.scenario.jurorrecord; | ||
|
||
import io.gatling.javaapi.core.ChainBuilder; | ||
import uk.gov.hmcts.juror.performance.Feeders; | ||
import uk.gov.hmcts.juror.performance.Util; | ||
|
||
import static io.gatling.javaapi.core.CoreDsl.feed; | ||
import static io.gatling.javaapi.core.CoreDsl.group; | ||
import static io.gatling.javaapi.core.CoreDsl.substring; | ||
import static io.gatling.javaapi.http.HttpDsl.http; | ||
|
||
public class JurorRecordExcusalScenario { | ||
private static final String GROUP_NAME = JurorRecordUpdateScenario.GROUP_NAME + " - excusal"; | ||
private static final String BASE_URL = JurorRecordUpdateScenario.BASE_URL + "/excusal"; | ||
|
||
public static ChainBuilder postExcusalGrant() { | ||
return postExcusalGrant(Util.getNewScenarioId()); | ||
} | ||
|
||
public static ChainBuilder postExcusalGrant(String scenarioId) { | ||
return group(scenarioId + GROUP_NAME + " - POST - GRANT") | ||
.on( | ||
feed(Feeders.EXCUSAL_CODE_FEEDER) | ||
.exec( | ||
http("POST - Juror Record - Update Record - Excusal - GRANT") | ||
.post(BASE_URL) | ||
.headers(Util.COMMON_HEADERS) | ||
.formParam("excusalCode", "#{exc_code}") | ||
.formParam("excusalDecision", "GRANT") | ||
.formParam("_csrf", "#{csrf}") | ||
.check(Util.validatePageIdentifier("juror record - overview")) | ||
.check(substring("Excusal granted")) | ||
) | ||
); | ||
} | ||
|
||
public static ChainBuilder postExcusalRefuse() { | ||
return postExcusalRefuse(Util.getNewScenarioId()); | ||
} | ||
|
||
public static ChainBuilder postExcusalRefuse(String scenarioId) { | ||
return group(scenarioId + GROUP_NAME + " - POST - REFUSE") | ||
.on( | ||
feed(Feeders.EXCUSAL_CODE_FEEDER) | ||
.exec( | ||
http("POST - Juror Record - Update Record - Excusal - REFUSE") | ||
.post(BASE_URL) | ||
.headers(Util.COMMON_HEADERS) | ||
.formParam("excusalCode", "#{exc_code}") | ||
.formParam("excusalDecision", "REFUSE") | ||
.formParam("_csrf", "#{csrf}") | ||
.check(Util.validatePageIdentifier("juror record - overview")) | ||
.check(substring("Excusal refused")) | ||
) | ||
); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...java/uk/gov/hmcts/juror/performance/scenario/jurorrecord/JurorRecordPostponeScenario.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package uk.gov.hmcts.juror.performance.scenario.jurorrecord; | ||
|
||
import io.gatling.javaapi.core.ChainBuilder; | ||
import uk.gov.hmcts.juror.performance.Util; | ||
import uk.gov.hmcts.juror.performance.scenario.AvailablePoolsScenario; | ||
import uk.gov.hmcts.juror.support.generation.util.RandomGenerator; | ||
|
||
import java.time.LocalDate; | ||
|
||
import static io.gatling.javaapi.core.CoreDsl.exec; | ||
import static io.gatling.javaapi.core.CoreDsl.group; | ||
import static io.gatling.javaapi.http.HttpDsl.http; | ||
|
||
public class JurorRecordPostponeScenario { | ||
private static final String GROUP_NAME = JurorRecordUpdateScenario.GROUP_NAME + " - postpone"; | ||
|
||
private static final String BASE_URL = JurorRecordUpdateScenario.BASE_URL + "/postpone-date"; | ||
|
||
public static ChainBuilder postPostponeDate() { | ||
return group(Util.getNewScenarioId() + GROUP_NAME + " - POST - date") | ||
.on( | ||
exec(session -> { | ||
String minDate = session.getString("postponeNewServiceStartMinDateStr"); | ||
|
||
assert minDate != null; | ||
LocalDate newDate = LocalDate.from(Util.STANDARD_DATE_FORMATTER.parse(minDate)) | ||
.plusWeeks(RandomGenerator.nextInt(1, 3)); | ||
return session.set("postponeNewServiceStart", Util.STANDARD_DATE_FORMATTER.format(newDate)); | ||
}).exec( | ||
AvailablePoolsScenario.applyChecks(http("POST - Juror Record - Update Record - postpone - date") | ||
.post(BASE_URL) | ||
.headers(Util.COMMON_HEADERS) | ||
.formParam("postponeTo", "#{postponeNewServiceStart}") | ||
.formParam("_csrf", "#{csrf}") | ||
) | ||
) | ||
); | ||
} | ||
} |
Oops, something went wrong.