<commit_before>/*
 * Copyright 2022 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 uk.gov.hmrc.nisp.models

import play.api.libs.json._
import uk.gov.hmrc.nisp.utils.{Constants, UnitSpec}

import java.time.LocalDate

class NpsDateSpec extends UnitSpec {

  val dateObject = Array(1, 1, 2015)

  "NpsDate" when {
    "JSON parsing" should {
      "return a JSError for null date" in {
        JsNull.validate[NpsDate].isError shouldBe true
      }

      "return a JsError for JsValue that isn't JsString" in {
        Json.fromJson[NpsDate](JsBoolean(false)).isError shouldBe true
      }
    }

    "JSON serialisation" should {
      "return JSString in correct format" in {
        Json.toJson(NpsDate(LocalDate.of(2015, 1, 1))) shouldBe JsString("01/01/2015")
      }
      "deserialise works" in {
        Json.fromJson[NpsDate](JsString("01/01/2015")).get shouldBe NpsDate(LocalDate.of(2015, 1, 1))
      }
    }

    "taxYearEndDate" should {
      "return tax year end date" in {
        NpsDate.taxYearEndDate(2015) shouldBe NpsDate(2016, Constants.taxYearsStartEndMonth, Constants.taxYearEndDay)
      }
    }

    "taxYearStartDate" should {
      "return tax year start date" in {
        NpsDate
          .taxYearStartDate(2015) shouldBe NpsDate(2015, Constants.taxYearsStartEndMonth, Constants.taxYearStartDay)
      }
    }
  }
}
<commit_msg>DDCNL-6056 | Removed unused test variable added<commit_after>/*
 * Copyright 2022 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 uk.gov.hmrc.nisp.models

import play.api.libs.json._
import uk.gov.hmrc.nisp.utils.{Constants, UnitSpec}

import java.time.LocalDate

class NpsDateSpec extends UnitSpec {

  "NpsDate" when {
    "JSON parsing" should {
      "return a JSError for null date" in {
        JsNull.validate[NpsDate].isError shouldBe true
      }

      "return a JsError for JsValue that isn't JsString" in {
        Json.fromJson[NpsDate](JsBoolean(false)).isError shouldBe true
      }
    }

    "JSON serialisation" should {
      "return JSString in correct format" in {
        Json.toJson(NpsDate(LocalDate.of(2015, 1, 1))) shouldBe JsString("01/01/2015")
      }
      "deserialise works" in {
        Json.fromJson[NpsDate](JsString("01/01/2015")).get shouldBe NpsDate(LocalDate.of(2015, 1, 1))
      }
    }

    "taxYearEndDate" should {
      "return tax year end date" in {
        NpsDate.taxYearEndDate(2015) shouldBe NpsDate(2016, Constants.taxYearsStartEndMonth, Constants.taxYearEndDay)
      }
    }

    "taxYearStartDate" should {
      "return tax year start date" in {
        NpsDate
          .taxYearStartDate(2015) shouldBe NpsDate(2015, Constants.taxYearsStartEndMonth, Constants.taxYearStartDay)
      }
    }
  }
}

{'fraction_non_alphanumeric': 0.09389794844818516, 'fraction_numerical': 0.02998421883219358, 'mean_word_length': 3.1202600216684724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6073018', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1160, 'n_words': 356}