{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CodeBuild.Types.TestCase
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeBuild.Types.TestCase where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Information about a test case created using a framework such as NUnit or
-- Cucumber. A test case might be a unit test or a configuration test.
--
-- /See:/ 'newTestCase' smart constructor.
data TestCase = TestCase'
  { -- | The number of nanoseconds it took to run this test case.
    TestCase -> Maybe Integer
durationInNanoSeconds :: Prelude.Maybe Prelude.Integer,
    -- | The date and time a test case expires. A test case expires 30 days after
    -- it is created. An expired test case is not available to view in
    -- CodeBuild.
    TestCase -> Maybe POSIX
expired :: Prelude.Maybe Data.POSIX,
    -- | A message associated with a test case. For example, an error message or
    -- stack trace.
    TestCase -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The name of the test case.
    TestCase -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A string that is applied to a series of related test cases. CodeBuild
    -- generates the prefix. The prefix depends on the framework used to
    -- generate the tests.
    TestCase -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the report to which the test case belongs.
    TestCase -> Maybe Text
reportArn :: Prelude.Maybe Prelude.Text,
    -- | The status returned by the test case after it was run. Valid statuses
    -- are @SUCCEEDED@, @FAILED@, @ERROR@, @SKIPPED@, and @UNKNOWN@.
    TestCase -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The path to the raw data file that contains the test result.
    TestCase -> Maybe Text
testRawDataPath :: Prelude.Maybe Prelude.Text
  }
  deriving (TestCase -> TestCase -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestCase -> TestCase -> Bool
$c/= :: TestCase -> TestCase -> Bool
== :: TestCase -> TestCase -> Bool
$c== :: TestCase -> TestCase -> Bool
Prelude.Eq, ReadPrec [TestCase]
ReadPrec TestCase
Int -> ReadS TestCase
ReadS [TestCase]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestCase]
$creadListPrec :: ReadPrec [TestCase]
readPrec :: ReadPrec TestCase
$creadPrec :: ReadPrec TestCase
readList :: ReadS [TestCase]
$creadList :: ReadS [TestCase]
readsPrec :: Int -> ReadS TestCase
$creadsPrec :: Int -> ReadS TestCase
Prelude.Read, Int -> TestCase -> ShowS
[TestCase] -> ShowS
TestCase -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestCase] -> ShowS
$cshowList :: [TestCase] -> ShowS
show :: TestCase -> String
$cshow :: TestCase -> String
showsPrec :: Int -> TestCase -> ShowS
$cshowsPrec :: Int -> TestCase -> ShowS
Prelude.Show, forall x. Rep TestCase x -> TestCase
forall x. TestCase -> Rep TestCase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestCase x -> TestCase
$cfrom :: forall x. TestCase -> Rep TestCase x
Prelude.Generic)

-- |
-- Create a value of 'TestCase' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'durationInNanoSeconds', 'testCase_durationInNanoSeconds' - The number of nanoseconds it took to run this test case.
--
-- 'expired', 'testCase_expired' - The date and time a test case expires. A test case expires 30 days after
-- it is created. An expired test case is not available to view in
-- CodeBuild.
--
-- 'message', 'testCase_message' - A message associated with a test case. For example, an error message or
-- stack trace.
--
-- 'name', 'testCase_name' - The name of the test case.
--
-- 'prefix', 'testCase_prefix' - A string that is applied to a series of related test cases. CodeBuild
-- generates the prefix. The prefix depends on the framework used to
-- generate the tests.
--
-- 'reportArn', 'testCase_reportArn' - The ARN of the report to which the test case belongs.
--
-- 'status', 'testCase_status' - The status returned by the test case after it was run. Valid statuses
-- are @SUCCEEDED@, @FAILED@, @ERROR@, @SKIPPED@, and @UNKNOWN@.
--
-- 'testRawDataPath', 'testCase_testRawDataPath' - The path to the raw data file that contains the test result.
newTestCase ::
  TestCase
newTestCase :: TestCase
newTestCase =
  TestCase'
    { $sel:durationInNanoSeconds:TestCase' :: Maybe Integer
durationInNanoSeconds = forall a. Maybe a
Prelude.Nothing,
      $sel:expired:TestCase' :: Maybe POSIX
expired = forall a. Maybe a
Prelude.Nothing,
      $sel:message:TestCase' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:name:TestCase' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:TestCase' :: Maybe Text
prefix = forall a. Maybe a
Prelude.Nothing,
      $sel:reportArn:TestCase' :: Maybe Text
reportArn = forall a. Maybe a
Prelude.Nothing,
      $sel:status:TestCase' :: Maybe Text
status = forall a. Maybe a
Prelude.Nothing,
      $sel:testRawDataPath:TestCase' :: Maybe Text
testRawDataPath = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of nanoseconds it took to run this test case.
testCase_durationInNanoSeconds :: Lens.Lens' TestCase (Prelude.Maybe Prelude.Integer)
testCase_durationInNanoSeconds :: Lens' TestCase (Maybe Integer)
testCase_durationInNanoSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestCase' {Maybe Integer
durationInNanoSeconds :: Maybe Integer
$sel:durationInNanoSeconds:TestCase' :: TestCase -> Maybe Integer
durationInNanoSeconds} -> Maybe Integer
durationInNanoSeconds) (\s :: TestCase
s@TestCase' {} Maybe Integer
a -> TestCase
s {$sel:durationInNanoSeconds:TestCase' :: Maybe Integer
durationInNanoSeconds = Maybe Integer
a} :: TestCase)

-- | The date and time a test case expires. A test case expires 30 days after
-- it is created. An expired test case is not available to view in
-- CodeBuild.
testCase_expired :: Lens.Lens' TestCase (Prelude.Maybe Prelude.UTCTime)
testCase_expired :: Lens' TestCase (Maybe UTCTime)
testCase_expired = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestCase' {Maybe POSIX
expired :: Maybe POSIX
$sel:expired:TestCase' :: TestCase -> Maybe POSIX
expired} -> Maybe POSIX
expired) (\s :: TestCase
s@TestCase' {} Maybe POSIX
a -> TestCase
s {$sel:expired:TestCase' :: Maybe POSIX
expired = Maybe POSIX
a} :: TestCase) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | A message associated with a test case. For example, an error message or
-- stack trace.
testCase_message :: Lens.Lens' TestCase (Prelude.Maybe Prelude.Text)
testCase_message :: Lens' TestCase (Maybe Text)
testCase_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestCase' {Maybe Text
message :: Maybe Text
$sel:message:TestCase' :: TestCase -> Maybe Text
message} -> Maybe Text
message) (\s :: TestCase
s@TestCase' {} Maybe Text
a -> TestCase
s {$sel:message:TestCase' :: Maybe Text
message = Maybe Text
a} :: TestCase)

-- | The name of the test case.
testCase_name :: Lens.Lens' TestCase (Prelude.Maybe Prelude.Text)
testCase_name :: Lens' TestCase (Maybe Text)
testCase_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestCase' {Maybe Text
name :: Maybe Text
$sel:name:TestCase' :: TestCase -> Maybe Text
name} -> Maybe Text
name) (\s :: TestCase
s@TestCase' {} Maybe Text
a -> TestCase
s {$sel:name:TestCase' :: Maybe Text
name = Maybe Text
a} :: TestCase)

-- | A string that is applied to a series of related test cases. CodeBuild
-- generates the prefix. The prefix depends on the framework used to
-- generate the tests.
testCase_prefix :: Lens.Lens' TestCase (Prelude.Maybe Prelude.Text)
testCase_prefix :: Lens' TestCase (Maybe Text)
testCase_prefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestCase' {Maybe Text
prefix :: Maybe Text
$sel:prefix:TestCase' :: TestCase -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: TestCase
s@TestCase' {} Maybe Text
a -> TestCase
s {$sel:prefix:TestCase' :: Maybe Text
prefix = Maybe Text
a} :: TestCase)

-- | The ARN of the report to which the test case belongs.
testCase_reportArn :: Lens.Lens' TestCase (Prelude.Maybe Prelude.Text)
testCase_reportArn :: Lens' TestCase (Maybe Text)
testCase_reportArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestCase' {Maybe Text
reportArn :: Maybe Text
$sel:reportArn:TestCase' :: TestCase -> Maybe Text
reportArn} -> Maybe Text
reportArn) (\s :: TestCase
s@TestCase' {} Maybe Text
a -> TestCase
s {$sel:reportArn:TestCase' :: Maybe Text
reportArn = Maybe Text
a} :: TestCase)

-- | The status returned by the test case after it was run. Valid statuses
-- are @SUCCEEDED@, @FAILED@, @ERROR@, @SKIPPED@, and @UNKNOWN@.
testCase_status :: Lens.Lens' TestCase (Prelude.Maybe Prelude.Text)
testCase_status :: Lens' TestCase (Maybe Text)
testCase_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestCase' {Maybe Text
status :: Maybe Text
$sel:status:TestCase' :: TestCase -> Maybe Text
status} -> Maybe Text
status) (\s :: TestCase
s@TestCase' {} Maybe Text
a -> TestCase
s {$sel:status:TestCase' :: Maybe Text
status = Maybe Text
a} :: TestCase)

-- | The path to the raw data file that contains the test result.
testCase_testRawDataPath :: Lens.Lens' TestCase (Prelude.Maybe Prelude.Text)
testCase_testRawDataPath :: Lens' TestCase (Maybe Text)
testCase_testRawDataPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestCase' {Maybe Text
testRawDataPath :: Maybe Text
$sel:testRawDataPath:TestCase' :: TestCase -> Maybe Text
testRawDataPath} -> Maybe Text
testRawDataPath) (\s :: TestCase
s@TestCase' {} Maybe Text
a -> TestCase
s {$sel:testRawDataPath:TestCase' :: Maybe Text
testRawDataPath = Maybe Text
a} :: TestCase)

instance Data.FromJSON TestCase where
  parseJSON :: Value -> Parser TestCase
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TestCase"
      ( \Object
x ->
          Maybe Integer
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> TestCase
TestCase'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"durationInNanoSeconds")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"expired")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"message")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"prefix")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"reportArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"status")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"testRawDataPath")
      )

instance Prelude.Hashable TestCase where
  hashWithSalt :: Int -> TestCase -> Int
hashWithSalt Int
_salt TestCase' {Maybe Integer
Maybe Text
Maybe POSIX
testRawDataPath :: Maybe Text
status :: Maybe Text
reportArn :: Maybe Text
prefix :: Maybe Text
name :: Maybe Text
message :: Maybe Text
expired :: Maybe POSIX
durationInNanoSeconds :: Maybe Integer
$sel:testRawDataPath:TestCase' :: TestCase -> Maybe Text
$sel:status:TestCase' :: TestCase -> Maybe Text
$sel:reportArn:TestCase' :: TestCase -> Maybe Text
$sel:prefix:TestCase' :: TestCase -> Maybe Text
$sel:name:TestCase' :: TestCase -> Maybe Text
$sel:message:TestCase' :: TestCase -> Maybe Text
$sel:expired:TestCase' :: TestCase -> Maybe POSIX
$sel:durationInNanoSeconds:TestCase' :: TestCase -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
durationInNanoSeconds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
expired
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
prefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reportArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
testRawDataPath

instance Prelude.NFData TestCase where
  rnf :: TestCase -> ()
rnf TestCase' {Maybe Integer
Maybe Text
Maybe POSIX
testRawDataPath :: Maybe Text
status :: Maybe Text
reportArn :: Maybe Text
prefix :: Maybe Text
name :: Maybe Text
message :: Maybe Text
expired :: Maybe POSIX
durationInNanoSeconds :: Maybe Integer
$sel:testRawDataPath:TestCase' :: TestCase -> Maybe Text
$sel:status:TestCase' :: TestCase -> Maybe Text
$sel:reportArn:TestCase' :: TestCase -> Maybe Text
$sel:prefix:TestCase' :: TestCase -> Maybe Text
$sel:name:TestCase' :: TestCase -> Maybe Text
$sel:message:TestCase' :: TestCase -> Maybe Text
$sel:expired:TestCase' :: TestCase -> Maybe POSIX
$sel:durationInNanoSeconds:TestCase' :: TestCase -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
durationInNanoSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
expired
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
prefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reportArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
testRawDataPath