<commit_before>package uk.gov.dvla.vehicles.retain.gatling

import io.gatling.core.Predef._
import io.gatling.core.feeder.RecordSeqFeederBuilder
import io.gatling.http.Predef._
import Headers.{headers_accept_html, headers_x_www_form_urlencoded}

class Chains(data: RecordSeqFeederBuilder[String]) {

  private val beforeYouStartPageTitle = "Take a Registration Number off a Vehicle"
  private val vehicleLookupPageTitle = "Enter details"
  private val setupBusinessDetailsPageTitle = "Provide your business details"
  private val businessChooseYourAddressPageTitle = "Select your business address"
  private val confirmPageTitle = "Confirm keeper details"
  private val paymentPageTitle = "Payment"
  private val fullscreenSolvePaymentPageTitle = "Complete your order - the-logic-group.com Checkout"
  private val confirmBusinessPageTitle = "Confirm your business details"
  private val successPageTitle = "Summary"
  private val vehicleLookupFailurePageTitle = "Look-up was unsuccessful"
  private val vehicleLookupToDirectToPaperTitle = "This registration number cannot be retained online"
  private val vehicleLookupToNotEligibleToTransactPageTitle = "This registration number cannot be retained"

  def assetsAreAccessible =
    exec(
      http("screen.min.css")
        .get( s"""/assets/screen.min.css""")
        .headers(Map(
        """If-Modified-Since""" -> """Thu, 05 Jun 2014 21:08:06 GMT""",
        """If-None-Match""" -> """59f34576dba4629e6e960e1d514fe573775e9999"""))
    )
      /*.exec(
      http("fonts.min.css")
        .get(s"""/assets/fonts.min.css""")
        .headers(Map(
          """If-Modified-Since""" -> """Fri, 30 May 2014 13:08:32 GMT""",
          """If-None-Match""" -> """0702d8d00d43562d6fa1a4e87ac82609dc70ffc9"""))
      )*/
      .exec(
        http("print.min.css")
          .get( s"""/assets/print.min.css""")
          .headers(Map(
          """If-Modified-Since""" -> """Thu, 05 Jun 2014 21:08:08 GMT""",
          """If-None-Match""" -> """b2b112249c52769ac41acd83e388f550e4c39c6f"""))
      )
      .exec(
        http("require.js")
          .get( s"""/assets/javascripts/require.js""")
          .headers(Map(
          """Accept""" -> """*/*""",
          """If-Modified-Since""" -> """Tue, 06 Aug 2013 09:49:32 GMT""",
          """If-None-Match""" -> """858bab5a8e8f73a1d706221ed772a4f740e168d5"""))
      )
      .exec(
        http("govuk-crest.png")
          .get( s"""/assets/lib/vehicles-presentation-common/images/govuk-crest.png""")
          .headers(Map(
          """Accept""" -> """image/png,image/*;q=0.8,*/*;q=0.5""",
          """If-Modified-Since""" -> """Thu, 22 May 2014 14:25:18 GMT""",
          """If-None-Match""" -> """0464ba08d53d88645ca77f9907c082c8c10d563b"""))
      )
      .exec(
        http("main.js")
          .get( s"""/assets/javascripts/main.js""")
          .headers(Map(
          """Accept""" -> """*/*""",
          """If-Modified-Since""" -> """Thu, 05 Jun 2014 21:10:42 GMT""",
          """If-None-Match""" -> """5f859f72e7cc426915cf32f2643ee5fc494b04a8"""))
      )

  def beforeYouStart =
    exitBlockOnFail(
      exec(
        http("beforeYouStart")
          .get(s"/before-you-start")
          .headers(headers_accept_html)
          // Assertions
          .check(status.is(200))
          .check(regex(beforeYouStartPageTitle).exists) // Page title
      )
    )

  def beforeYouStartToVehicleLookup =
    exitBlockOnFail(
      exec(
        http("beforeYouStartToVehicleLookup")
          .get(s"/vehicle-lookup") // Gatlin doesn't click on links, you need to go to the next page.
          .headers(headers_accept_html)
          .check(regex( """<input type="hidden" name="csrf_prevention_token" value="(.*)"/>""").saveAs("csrf_prevention_token"))
          // Assertions
          .check(status.is(200))<commit_msg>US2602: gatling test for all assets<commit_after>package uk.gov.dvla.vehicles.retain.gatling

import io.gatling.core.Predef._
import io.gatling.core.feeder.RecordSeqFeederBuilder
import io.gatling.http.Predef._
import Headers.{headers_accept_html, headers_x_www_form_urlencoded}

class Chains(data: RecordSeqFeederBuilder[String]) {

  private val beforeYouStartPageTitle = "Take a Registration Number off a Vehicle"
  private val vehicleLookupPageTitle = "Enter details"
  private val setupBusinessDetailsPageTitle = "Provide your business details"
  private val businessChooseYourAddressPageTitle = "Select your business address"
  private val confirmPageTitle = "Confirm keeper details"
  private val paymentPageTitle = "Payment"
  private val fullscreenSolvePaymentPageTitle = "Complete your order - the-logic-group.com Checkout"
  private val confirmBusinessPageTitle = "Confirm your business details"
  private val successPageTitle = "Summary"
  private val vehicleLookupFailurePageTitle = "Look-up was unsuccessful"
  private val vehicleLookupToDirectToPaperTitle = "This registration number cannot be retained online"
  private val vehicleLookupToNotEligibleToTransactPageTitle = "This registration number cannot be retained"

  def assetsAreAccessible =
    exec(
      http("apple-touch-icon-57x57.png")
        .get( s"""/assets/images/apple-touch-icon-57x57.png""")
    )
      .exec(
        http("apple-touch-icon-72x72.png")
          .get( s"""/assets/images/apple-touch-icon-72x72.png""")
      )
      .exec(
        http("apple-touch-icon-76x76.png")
          .get( s"""/assets/images/apple-touch-icon-76x76.png""")
      )
      .exec(
        http("apple-touch-icon-114x114.png")
          .get( s"""/assets/images/apple-touch-icon-114x114.png""")
      )
      .exec(
        http("apple-touch-icon-120x120.png")
          .get( s"""/assets/images/apple-touch-icon-120x120.png""")
      )
      .exec(
        http("apple-touch-icon-144x144.png")
          .get( s"""/assets/images/apple-touch-icon-144x144.png""")
      )
      .exec(
        http("apple-touch-icon-144x144.png")
          .get( s"""/assets/images/apple-touch-icon-152x152.png""")
      )
      .exec(
        http("document-reference-number.png")
          .get( s"""/assets/images/document-reference-number.png""")
      )
      .exec(
        http("favicon.ico")
          .get( s"""/assets/images/favicon.ico""")
      )
      .exec(
        http("gov.uk_logotype-2x.png")
          .get( s"""/assets/images/gov.uk_logotype-2x.png""")
      )
      .exec(
        http("gov.uk_logotype_crown-c09acb07e4d1d5d558f5a0bc53e9e36d.png")
          .get( s"""/assets/images/gov.uk_logotype_crown-c09acb07e4d1d5d558f5a0bc53e9e36d.png""")
      )
      .exec(
        http("gov-uk-email.png")
          .get( s"""/assets/images/gov-uk-email.png""")
      )
      .exec(
        http("govuk-crest.png")
          .get( s"""/assets/lib/vehicles-presentation-common/images/govuk-crest.png""")
          .headers(Map(
          """Accept""" -> """image/png,image/*;q=0.8,*/*;q=0.5""",
          """If-Modified-Since""" -> """Thu, 22 May 2014 14:25:18 GMT""",
          """If-None-Match""" -> """0464ba08d53d88645ca77f9907c082c8c10d563b"""))
      )
      .exec(
        http("icon-tick-green.gif")
          .get( s"""/assets/images/icon-tick-green.gif""")
      )
      .exec(
        http("open-government-licence-974ebd75112cb480aae1a55ae4593c67.png")
          .get( s"""/assets/images/open-government-licence-974ebd75112cb480aae1a55ae4593c67.png""")
      )
      .exec(
        http("payMock.png")
          .get( s"""/assets/images/payMock.png""")
      )
      .exec(
        http("pdf-icon-1.png")
          .get( s"""/assets/images/pdf-icon-1.png""")
      )
      .exec(
        http("progress-tick.png")
          .get( s"""/assets/images/progress-tick.png""")
      )

      /* javascript */
      .exec(
        http("confirm-page.js")
          .get( s"""/assets/javascripts/confirm-page.js""")
      )
      .exec(
        http("details-polyfill.js")
          .get( s"""/assets/javascripts/details-polyfill.js""")
      )
      .exec(
        http("firefox-dont-cache-page.js")
          .get( s"""/assets/javascripts/firefox-dont-cache-page.js""")
      )
      .exec(
        http("form-checked-selection.js")
          .get( s"""/assets/javascripts/form-checked-selection.js""")
      )
      .exec(
        http("header-footer-only.js")
          .get( s"""/assets/javascripts/header-footer-only.js""")
      )
      .exec(
        http("main.js")
          .get( s"""/assets/javascripts/main.js""")
          .headers(Map(
          """Accept""" -> """*/*""",
          """If-Modified-Since""" -> """Thu, 05 Jun 2014 21:10:42 GMT""",
          """If-None-Match""" -> """5f859f72e7cc426915cf32f2643ee5fc494b04a8"""))
      )
      .exec(
        http("on-event-change-display.js")
          .get( s"""/assets/javascripts/on-event-change-display.js""")
      )
      .exec(
        http("on-load-conditional-display.js")
          .get( s"""/assets/javascripts/on-load-conditional-display.js""")
      )

      /* javascript from webjars */
      .exec(
        http("require.min.js")
          .get( s"""/webjars/requirejs/2.1.16/require.min.js""")
          .headers(Map(
          """Accept""" -> """*/*""",
          """If-Modified-Since""" -> """Tue, 06 Aug 2013 09:49:32 GMT""",
          """If-None-Match""" -> """858bab5a8e8f73a1d706221ed772a4f740e168d5"""))
      )
      .exec(
        http("jquery.min.js")
          .get( s"""/webjars/jquery/1.9.1/jquery.min.js""")
          .headers(Map(
          """Accept""" -> """*/*""",
          """If-Modified-Since""" -> """Tue, 06 Aug 2013 09:49:32 GMT""",
          """If-None-Match""" -> """858bab5a8e8f73a1d706221ed772a4f740e168d5"""))
      )


      /* css */
      .exec(
        http("print.min.css")
          .get( s"""/assets/print.min.css""")
          .headers(Map(
          """If-Modified-Since""" -> """Thu, 05 Jun 2014 21:08:08 GMT""",
          """If-None-Match""" -> """b2b112249c52769ac41acd83e388f550e4c39c6f"""))
      )
      .exec(
        http("screen.min.css")
          .get( s"""/assets/screen.min.css""")
          .headers(Map(
          """If-Modified-Since""" -> """Thu, 05 Jun 2014 21:08:06 GMT""",
          """If-None-Match""" -> """59f34576dba4629e6e960e1d514fe573775e9999"""))
      )

  def beforeYouStart =
    exitBlockOnFail(
      exec(
        http("beforeYouStart")
          .get(s"/before-you-start")
          .headers(headers_accept_html)
          // Assertions
          .check(status.is(200))
          .check(regex(beforeYouStartPageTitle).exists) // Page title
      )
    )

  def beforeYouStartToVehicleLookup =
    exitBlockOnFail(
      exec(
        http("beforeYouStartToVehicleLookup")
          .get(s"/vehicle-lookup") // Gatlin doesn't click on links, you need to go to the next page.
          .headers(headers_accept_html)
          .check(regex( """<input type="hidden" name="csrf_prevention_token" value="(.*)"/>""").saveAs("csrf_prevention_token"))
          // Assertions
          .check(status.is(200))
{'fraction_non_alphanumeric': 0.17174666910020076, 'fraction_numerical': 0.058952363569994524, 'mean_word_length': 2.4834710743801653, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '19679', 'n_tokens_mistral': 4115, 'n_tokens_neox': 3659, 'n_words': 561}