<commit_before>/*
 * Copyright 2016 HM Revenue & Customs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package repositories.application

import _root_.services.testdata.{ StatusGeneratorFactory, TestDataGeneratorService }
import factories.UUIDFactory
import model.ProgressStatuses.{ PHASE1_TESTS_PASSED => _, SUBMITTED => _ }
import model.SchemeType.SchemeType
import model._
import model.report.{ AdjustmentReportItem, CandidateProgressReportItem }
import services.GBTimeZoneService
import config.MicroserviceAppConfig._
import model.ApplicationRoute.{ apply => _ }
import model.command.testdata.GeneratorConfig
import model.command.{ ProgressResponse, WithdrawApplication }
import model.exchange.testdata.{ AssistanceDetailsRequest, CreateCandidateInStatusRequest, StatusDataRequest }
import model.persisted._
import repositories.CommonBSONDocuments
import testkit.MongoRepositorySpec
import uk.gov.hmrc.play.http.HeaderCarrier

import scala.concurrent.Await

class ReportingMongoRepositorySpec extends MongoRepositorySpec with UUIDFactory with CommonBSONDocuments {

  val frameworkId = "FastStream-2016"

  val collectionName = "application"

  def repository = new ReportingMongoRepository(GBTimeZoneService)

  def applicationRepo = new GeneralApplicationMongoRepository(GBTimeZoneService, cubiksGatewayConfig)

  def testDataRepo = new TestDataMongoRepository()

  val testDataGeneratorService = TestDataGeneratorService

  implicit def blankedHeaderCarrier = new HeaderCarrier()

  "Candidate Progress Report" should {
    "for an application with all fields" in {
      val userId = generateUUID()
      val appId = generateUUID()
      testDataRepo.createApplicationWithAllFields(userId, appId, "FastStream-2016").futureValue

      val result = repository.candidateProgressReport("FastStream-2016").futureValue

      result must not be empty
      result.head mustBe CandidateProgressReportItem(userId, appId, Some("submitted"),
        List(SchemeType.DiplomaticService, SchemeType.GovernmentOperationalResearchService), Some("Yes"),
        Some("No"), Some("No"), None, Some("No"), Some("Yes"), Some("No"), Some("Yes"), Some("No"), Some("Yes"), Some("1234567"), None, None)
    }

    "for the minimum application" in {
      val userId = generateUUID()
      val appId = generateUUID()
      testDataRepo.createMinimumApplication(userId, appId, "FastStream-2016").futureValue

      val result = repository.candidateProgressReport("FastStream-2016").futureValue

      result must not be empty
      result.head must be(CandidateProgressReportItem(userId, appId, Some("registered"),
        List.empty[SchemeType], None, None, None, None, None, None, None, None, None, None, None, None, None)
      )
    }
  }<commit_msg>fix test<commit_after>/*
 * Copyright 2016 HM Revenue & Customs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package repositories.application

import _root_.services.testdata.{ StatusGeneratorFactory, TestDataGeneratorService }
import factories.UUIDFactory
import model.ProgressStatuses.{ PHASE1_TESTS_PASSED => _, SUBMITTED => _ }
import model.SchemeType.SchemeType
import model._
import model.report.{ AdjustmentReportItem, CandidateProgressReportItem }
import services.GBTimeZoneService
import config.MicroserviceAppConfig._
import model.ApplicationRoute.{ apply => _ }
import model.command.testdata.GeneratorConfig
import model.command.{ ProgressResponse, WithdrawApplication }
import model.exchange.testdata.{ AssistanceDetailsRequest, CreateCandidateInStatusRequest, StatusDataRequest }
import model.persisted._
import repositories.CommonBSONDocuments
import testkit.MongoRepositorySpec
import uk.gov.hmrc.play.http.HeaderCarrier

import scala.concurrent.Await

class ReportingMongoRepositorySpec extends MongoRepositorySpec with UUIDFactory with CommonBSONDocuments {

  val frameworkId = "FastStream-2016"

  val collectionName = "application"

  def repository = new ReportingMongoRepository(GBTimeZoneService)

  def applicationRepo = new GeneralApplicationMongoRepository(GBTimeZoneService, cubiksGatewayConfig)

  def testDataRepo = new TestDataMongoRepository()

  val testDataGeneratorService = TestDataGeneratorService

  implicit def blankedHeaderCarrier = new HeaderCarrier()

  "Candidate Progress Report" should {
    "for an application with all fields" in {
      val userId = generateUUID()
      val appId = generateUUID()
      testDataRepo.createApplicationWithAllFields(userId, appId, "FastStream-2016").futureValue

      val result = repository.candidateProgressReport("FastStream-2016").futureValue

      result must not be empty
      result.head mustBe CandidateProgressReportItem(userId, appId, Some("submitted"),
        List(SchemeType.DiplomaticService, SchemeType.GovernmentOperationalResearchService), Some("Yes"),
        Some("No"), Some("No"), None, Some("No"), Some("Yes"), Some("No"), None, Some("No"), Some("Yes"), Some("1234567"), None, None)
    }

    "for the minimum application" in {
      val userId = generateUUID()
      val appId = generateUUID()
      testDataRepo.createMinimumApplication(userId, appId, "FastStream-2016").futureValue

      val result = repository.candidateProgressReport("FastStream-2016").futureValue

      result must not be empty
      result.head must be(CandidateProgressReportItem(userId, appId, Some("registered"),
        List.empty[SchemeType], None, None, None, None, None, None, None, None, None, None, None, None, None)
      )
    }
  }
{'fraction_non_alphanumeric': 0.08587257617728532, 'fraction_numerical': 0.0110803324099723, 'mean_word_length': 4.984346224677717, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6986291', 'n_tokens_mistral': 1766, 'n_tokens_neox': 1678, 'n_words': 513}