{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeBuild.Types.TestCase where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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 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 Core.POSIX,
    -- | 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 name of the test case.
    TestCase -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The path to the raw data file that contains the test result.
    TestCase -> Maybe Text
testRawDataPath :: Prelude.Maybe Prelude.Text,
    -- | A message associated with a test case. For example, an error message or
    -- stack trace.
    TestCase -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the report to which the test case belongs.
    TestCase -> Maybe Text
reportArn :: Prelude.Maybe Prelude.Text
  }
  deriving (TestCase -> TestCase -> Bool
(TestCase -> TestCase -> Bool)
-> (TestCase -> TestCase -> Bool) -> Eq TestCase
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]
(Int -> ReadS TestCase)
-> ReadS [TestCase]
-> ReadPrec TestCase
-> ReadPrec [TestCase]
-> Read 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
(Int -> TestCase -> ShowS)
-> (TestCase -> String) -> ([TestCase] -> ShowS) -> Show TestCase
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. TestCase -> Rep TestCase x)
-> (forall x. Rep TestCase x -> TestCase) -> Generic TestCase
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.
--
-- 'status', 'testCase_status' - The status returned by the test case after it was run. Valid statuses
-- are @SUCCEEDED@, @FAILED@, @ERROR@, @SKIPPED@, and @UNKNOWN@.
--
-- '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.
--
-- '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.
--
-- 'name', 'testCase_name' - The name of the test case.
--
-- 'testRawDataPath', 'testCase_testRawDataPath' - The path to the raw data file that contains the test result.
--
-- 'message', 'testCase_message' - A message associated with a test case. For example, an error message or
-- stack trace.
--
-- 'reportArn', 'testCase_reportArn' - The ARN of the report to which the test case belongs.
newTestCase ::
  TestCase
newTestCase :: TestCase
newTestCase =
  TestCase' :: Maybe Integer
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> TestCase
TestCase'
    { $sel:durationInNanoSeconds:TestCase' :: Maybe Integer
durationInNanoSeconds = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:status:TestCase' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expired:TestCase' :: Maybe POSIX
expired = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:TestCase' :: Maybe Text
prefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:TestCase' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:testRawDataPath:TestCase' :: Maybe Text
testRawDataPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:TestCase' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reportArn:TestCase' :: Maybe Text
reportArn = Maybe Text
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 :: (Maybe Integer -> f (Maybe Integer)) -> TestCase -> f TestCase
testCase_durationInNanoSeconds = (TestCase -> Maybe Integer)
-> (TestCase -> Maybe Integer -> TestCase)
-> Lens TestCase TestCase (Maybe Integer) (Maybe Integer)
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 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 :: (Maybe Text -> f (Maybe Text)) -> TestCase -> f TestCase
testCase_status = (TestCase -> Maybe Text)
-> (TestCase -> Maybe Text -> TestCase)
-> Lens TestCase TestCase (Maybe Text) (Maybe Text)
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 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 :: (Maybe UTCTime -> f (Maybe UTCTime)) -> TestCase -> f TestCase
testCase_expired = (TestCase -> Maybe POSIX)
-> (TestCase -> Maybe POSIX -> TestCase)
-> Lens TestCase TestCase (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> TestCase -> f TestCase)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TestCase
-> f TestCase
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> TestCase -> f TestCase
testCase_prefix = (TestCase -> Maybe Text)
-> (TestCase -> Maybe Text -> TestCase)
-> Lens TestCase TestCase (Maybe Text) (Maybe Text)
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 name of the test case.
testCase_name :: Lens.Lens' TestCase (Prelude.Maybe Prelude.Text)
testCase_name :: (Maybe Text -> f (Maybe Text)) -> TestCase -> f TestCase
testCase_name = (TestCase -> Maybe Text)
-> (TestCase -> Maybe Text -> TestCase)
-> Lens TestCase TestCase (Maybe Text) (Maybe Text)
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)

-- | The path to the raw data file that contains the test result.
testCase_testRawDataPath :: Lens.Lens' TestCase (Prelude.Maybe Prelude.Text)
testCase_testRawDataPath :: (Maybe Text -> f (Maybe Text)) -> TestCase -> f TestCase
testCase_testRawDataPath = (TestCase -> Maybe Text)
-> (TestCase -> Maybe Text -> TestCase)
-> Lens TestCase TestCase (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> TestCase -> f TestCase
testCase_message = (TestCase -> Maybe Text)
-> (TestCase -> Maybe Text -> TestCase)
-> Lens TestCase TestCase (Maybe Text) (Maybe Text)
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 ARN of the report to which the test case belongs.
testCase_reportArn :: Lens.Lens' TestCase (Prelude.Maybe Prelude.Text)
testCase_reportArn :: (Maybe Text -> f (Maybe Text)) -> TestCase -> f TestCase
testCase_reportArn = (TestCase -> Maybe Text)
-> (TestCase -> Maybe Text -> TestCase)
-> Lens TestCase TestCase (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable TestCase

instance Prelude.NFData TestCase