Skip to content

Commit

Permalink
HIPP-1857: Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
victorarbuesmallada committed Jan 24, 2025
1 parent c0335d7 commit 836e5ec
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.mockito.ArgumentMatchers.any
import org.mockito.Mockito.*
import org.scalatest.BeforeAndAfterEach
import org.scalatest.matchers.should.Matchers
import org.scalatest.prop.TableDrivenPropertyChecks
import org.scalatest.wordspec.AnyWordSpec
import org.scalatestplus.mockito.MockitoSugar
import uk.gov.hmrc.integrationcatalogue.config.AppConfig
Expand All @@ -31,8 +32,10 @@ import uk.gov.hmrc.integrationcatalogue.models.common.ApiType
import uk.gov.hmrc.integrationcatalogue.parser.oas.adapters.{ExtensionKeys, IntegrationCatalogueExtensions, OASExtensionsAdapter}
import uk.gov.hmrc.integrationcatalogue.testdata.{ApiTestData, OasTestData}

import java.time.ZonedDateTime

class OasExtensionsAdapterSpec extends AnyWordSpec
with Matchers with MockitoSugar with ApiTestData with OasTestData with BeforeAndAfterEach with ExtensionKeys with OASExtensionsAdapter {
with Matchers with MockitoSugar with ApiTestData with OasTestData with BeforeAndAfterEach with ExtensionKeys with OASExtensionsAdapter with TableDrivenPropertyChecks {

trait Setup {
val publisherRefValue = "SOMEREFERENCE"
Expand Down Expand Up @@ -385,6 +388,31 @@ class OasExtensionsAdapterSpec extends AnyWordSpec
}
}

"return Right when reviewed date is an accepted iso 8601 format" in new Setup {
forAll(Table(
"reviewDate",
"2025-01-23T01:12:23.34567889Z",
"2025-01-23T01:12:23.3456788Z",
"2025-01-23T01:12:23.345678Z",
"2025-01-23T01:12:23.34567Z",
"2025-01-23T01:12:23.3456Z",
"2025-01-23T01:12:23.345Z",
"2025-01-23T01:12:23.34Z",
"2025-01-23T01:12:23.3Z"
)){ reviewDate =>
val extensionValues = new util.HashMap[String, Object]() {{
put(REVIEWED_DATE_EXTENSION_KEY, reviewDate)
}}
val result: Either[NonEmptyList[String], IntegrationCatalogueExtensions] =
parseExtensions(generateInfoObject(extensionValues), Some(publisherRefValue), mockAppConfig)
result match {
case Left(_) => fail()
case Right(extensions) =>
extensions.reviewedDate shouldBe ZonedDateTime.parse(reviewDate).toInstant
}
}
}

"return Left when status reviewed date is not an accepted iso 8601 format" in new Setup {
val result: Either[NonEmptyList[String], IntegrationCatalogueExtensions] =
parseExtensions(generateInfoObject(extensionsWithBadReviewDateString), Some(publisherRefValue), mockAppConfig)
Expand Down

0 comments on commit 836e5ec

Please sign in to comment.