{-# 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-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.TestReportSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(TestReportSummary -> TestReportSummary -> Bool)
-> (TestReportSummary -> TestReportSummary -> Bool)
-> Eq TestReportSummary
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]
(Int -> ReadS TestReportSummary)
-> ReadS [TestReportSummary]
-> ReadPrec TestReportSummary
-> ReadPrec [TestReportSummary]
-> Read 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
(Int -> TestReportSummary -> ShowS)
-> (TestReportSummary -> String)
-> ([TestReportSummary] -> ShowS)
-> Show TestReportSummary
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. TestReportSummary -> Rep TestReportSummary x)
-> (forall x. Rep TestReportSummary x -> TestReportSummary)
-> Generic TestReportSummary
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' :: Int -> HashMap Text Int -> Integer -> TestReportSummary
TestReportSummary'
    { $sel:total:TestReportSummary' :: Int
total = Int
pTotal_,
      $sel:statusCounts:TestReportSummary' :: HashMap Text Int
statusCounts = HashMap Text Int
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 :: (Int -> f Int) -> TestReportSummary -> f TestReportSummary
testReportSummary_total = (TestReportSummary -> Int)
-> (TestReportSummary -> Int -> TestReportSummary)
-> Lens TestReportSummary TestReportSummary Int Int
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 :: (HashMap Text Int -> f (HashMap Text Int))
-> TestReportSummary -> f TestReportSummary
testReportSummary_statusCounts = (TestReportSummary -> HashMap Text Int)
-> (TestReportSummary -> HashMap Text Int -> TestReportSummary)
-> Lens
     TestReportSummary
     TestReportSummary
     (HashMap Text Int)
     (HashMap Text Int)
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) ((HashMap Text Int -> f (HashMap Text Int))
 -> TestReportSummary -> f TestReportSummary)
-> ((HashMap Text Int -> f (HashMap Text Int))
    -> HashMap Text Int -> f (HashMap Text Int))
-> (HashMap Text Int -> f (HashMap Text Int))
-> TestReportSummary
-> f TestReportSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Int -> f (HashMap Text Int))
-> HashMap Text Int -> f (HashMap Text Int)
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 :: (Integer -> f Integer) -> TestReportSummary -> f TestReportSummary
testReportSummary_durationInNanoSeconds = (TestReportSummary -> Integer)
-> (TestReportSummary -> Integer -> TestReportSummary)
-> Lens TestReportSummary TestReportSummary Integer Integer
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 Core.FromJSON TestReportSummary where
  parseJSON :: Value -> Parser TestReportSummary
parseJSON =
    String
-> (Object -> Parser TestReportSummary)
-> Value
-> Parser TestReportSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TestReportSummary"
      ( \Object
x ->
          Int -> HashMap Text Int -> Integer -> TestReportSummary
TestReportSummary'
            (Int -> HashMap Text Int -> Integer -> TestReportSummary)
-> Parser Int
-> Parser (HashMap Text Int -> Integer -> TestReportSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"total")
            Parser (HashMap Text Int -> Integer -> TestReportSummary)
-> Parser (HashMap Text Int)
-> Parser (Integer -> TestReportSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (HashMap Text Int))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"statusCounts" Parser (Maybe (HashMap Text Int))
-> HashMap Text Int -> Parser (HashMap Text Int)
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= HashMap Text Int
forall a. Monoid a => a
Prelude.mempty)
            Parser (Integer -> TestReportSummary)
-> Parser Integer -> Parser TestReportSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Integer
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"durationInNanoSeconds")
      )

instance Prelude.Hashable TestReportSummary

instance Prelude.NFData TestReportSummary