{-# 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.TestReportSummary
-- 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.TestReportSummary 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 report.
--
-- /See:/ 'newTestReportSummary' smart constructor.
data TestReportSummary = TestReportSummary'
  { -- | The number of test cases in this @TestReportSummary@. The total includes
    -- truncated test cases.
    TestReportSummary -> Int
total :: Prelude.Int,
    -- | A map that contains the number of each type of status returned by the
    -- test results in this @TestReportSummary@.
    TestReportSummary -> HashMap Text Int
statusCounts :: Prelude.HashMap Prelude.Text Prelude.Int,
    -- | The number of nanoseconds it took to run all of the test cases in this
    -- report.
    TestReportSummary -> Integer
durationInNanoSeconds :: Prelude.Integer
  }
  deriving (TestReportSummary -> TestReportSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestReportSummary -> TestReportSummary -> Bool
$c/= :: TestReportSummary -> TestReportSummary -> Bool
== :: TestReportSummary -> TestReportSummary -> Bool
$c== :: TestReportSummary -> TestReportSummary -> Bool
Prelude.Eq, ReadPrec [TestReportSummary]
ReadPrec TestReportSummary
Int -> ReadS TestReportSummary
ReadS [TestReportSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestReportSummary]
$creadListPrec :: ReadPrec [TestReportSummary]
readPrec :: ReadPrec TestReportSummary
$creadPrec :: ReadPrec TestReportSummary
readList :: ReadS [TestReportSummary]
$creadList :: ReadS [TestReportSummary]
readsPrec :: Int -> ReadS TestReportSummary
$creadsPrec :: Int -> ReadS TestReportSummary
Prelude.Read, Int -> TestReportSummary -> ShowS
[TestReportSummary] -> ShowS
TestReportSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestReportSummary] -> ShowS
$cshowList :: [TestReportSummary] -> ShowS
show :: TestReportSummary -> String
$cshow :: TestReportSummary -> String
showsPrec :: Int -> TestReportSummary -> ShowS
$cshowsPrec :: Int -> TestReportSummary -> ShowS
Prelude.Show, forall x. Rep TestReportSummary x -> TestReportSummary
forall x. TestReportSummary -> Rep TestReportSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestReportSummary x -> TestReportSummary
$cfrom :: forall x. TestReportSummary -> Rep TestReportSummary x
Prelude.Generic)

-- |
-- Create a value of 'TestReportSummary' 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:
--
-- 'total', 'testReportSummary_total' - The number of test cases in this @TestReportSummary@. The total includes
-- truncated test cases.
--
-- 'statusCounts', 'testReportSummary_statusCounts' - A map that contains the number of each type of status returned by the
-- test results in this @TestReportSummary@.
--
-- 'durationInNanoSeconds', 'testReportSummary_durationInNanoSeconds' - The number of nanoseconds it took to run all of the test cases in this
-- report.
newTestReportSummary ::
  -- | 'total'
  Prelude.Int ->
  -- | 'durationInNanoSeconds'
  Prelude.Integer ->
  TestReportSummary
newTestReportSummary :: Int -> Integer -> TestReportSummary
newTestReportSummary Int
pTotal_ Integer
pDurationInNanoSeconds_ =
  TestReportSummary'
    { $sel:total:TestReportSummary' :: Int
total = Int
pTotal_,
      $sel:statusCounts:TestReportSummary' :: HashMap Text Int
statusCounts = forall a. Monoid a => a
Prelude.mempty,
      $sel:durationInNanoSeconds:TestReportSummary' :: Integer
durationInNanoSeconds = Integer
pDurationInNanoSeconds_
    }

-- | The number of test cases in this @TestReportSummary@. The total includes
-- truncated test cases.
testReportSummary_total :: Lens.Lens' TestReportSummary Prelude.Int
testReportSummary_total :: Lens' TestReportSummary Int
testReportSummary_total = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestReportSummary' {Int
total :: Int
$sel:total:TestReportSummary' :: TestReportSummary -> Int
total} -> Int
total) (\s :: TestReportSummary
s@TestReportSummary' {} Int
a -> TestReportSummary
s {$sel:total:TestReportSummary' :: Int
total = Int
a} :: TestReportSummary)

-- | A map that contains the number of each type of status returned by the
-- test results in this @TestReportSummary@.
testReportSummary_statusCounts :: Lens.Lens' TestReportSummary (Prelude.HashMap Prelude.Text Prelude.Int)
testReportSummary_statusCounts :: Lens' TestReportSummary (HashMap Text Int)
testReportSummary_statusCounts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestReportSummary' {HashMap Text Int
statusCounts :: HashMap Text Int
$sel:statusCounts:TestReportSummary' :: TestReportSummary -> HashMap Text Int
statusCounts} -> HashMap Text Int
statusCounts) (\s :: TestReportSummary
s@TestReportSummary' {} HashMap Text Int
a -> TestReportSummary
s {$sel:statusCounts:TestReportSummary' :: HashMap Text Int
statusCounts = HashMap Text Int
a} :: TestReportSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The number of nanoseconds it took to run all of the test cases in this
-- report.
testReportSummary_durationInNanoSeconds :: Lens.Lens' TestReportSummary Prelude.Integer
testReportSummary_durationInNanoSeconds :: Lens' TestReportSummary Integer
testReportSummary_durationInNanoSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestReportSummary' {Integer
durationInNanoSeconds :: Integer
$sel:durationInNanoSeconds:TestReportSummary' :: TestReportSummary -> Integer
durationInNanoSeconds} -> Integer
durationInNanoSeconds) (\s :: TestReportSummary
s@TestReportSummary' {} Integer
a -> TestReportSummary
s {$sel:durationInNanoSeconds:TestReportSummary' :: Integer
durationInNanoSeconds = Integer
a} :: TestReportSummary)

instance Data.FromJSON TestReportSummary where
  parseJSON :: Value -> Parser TestReportSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TestReportSummary"
      ( \Object
x ->
          Int -> HashMap Text Int -> Integer -> TestReportSummary
TestReportSummary'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"total")
            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
"statusCounts" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"durationInNanoSeconds")
      )

instance Prelude.Hashable TestReportSummary where
  hashWithSalt :: Int -> TestReportSummary -> Int
hashWithSalt Int
_salt TestReportSummary' {Int
Integer
HashMap Text Int
durationInNanoSeconds :: Integer
statusCounts :: HashMap Text Int
total :: Int
$sel:durationInNanoSeconds:TestReportSummary' :: TestReportSummary -> Integer
$sel:statusCounts:TestReportSummary' :: TestReportSummary -> HashMap Text Int
$sel:total:TestReportSummary' :: TestReportSummary -> Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
total
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text Int
statusCounts
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
durationInNanoSeconds

instance Prelude.NFData TestReportSummary where
  rnf :: TestReportSummary -> ()
rnf TestReportSummary' {Int
Integer
HashMap Text Int
durationInNanoSeconds :: Integer
statusCounts :: HashMap Text Int
total :: Int
$sel:durationInNanoSeconds:TestReportSummary' :: TestReportSummary -> Integer
$sel:statusCounts:TestReportSummary' :: TestReportSummary -> HashMap Text Int
$sel:total:TestReportSummary' :: TestReportSummary -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
total
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text Int
statusCounts
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
durationInNanoSeconds