n11Tests :: TestTree
n11Tests = decisionTestGroup "n11" "Redirect?"
  [ testCase "True + created + content type accepted ==> 303 See Other" $
      let
        r = resource
          { postAction = return . PostCreateRedir $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/html"] }
        aft = case after n11 r rq of
          (d, rd) -> (d, HashMap.lookup hLocation $_reqDataRespHeaders rd, _reqDataDispPath rd)
      in aft @?= (Done' seeOther303, Just ["http://example.com/webcrank"], ["webcrank"])
   , testCase "True + created + no content type accepted ==> 415 Unsupported Media Type" $
      let
        r = resource
          { postAction = return . PostCreateRedir $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/plain"] }
      in after' n11 r rq @?= error' unsupportedMediaType415
  , testCase "True + process ==> 303 See Other" $
      let r = resource { postAction = return $ PostProcessRedir $ return "http://example.com/webcrank" }
      in afterHdrs n11 r req @?=
        (Done' seeOther303, HashMap.singleton hLocation ["http://example.com/webcrank"])
  , testCase "False + created + content type accepted ==> p11" $
      let
        r = resource
          { postAction = return . PostCreate $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/html"] }
      in afterHdrs n11 r rq @?=
        (Decision' "p11", HashMap.singleton hLocation ["http://example.com/webcrank"])
  , testCase "False + created + no content type accepted ==> p11" $
      let
        r = resource
          { postAction = return . PostCreate $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/plain"] }
      in afterHdrs n11 r rq @?=
        (error' unsupportedMediaType415, HashMap.singleton hLocation ["http://example.com/webcrank"])
  , testCase "False + process ==> p11" $
      let r = resource { postAction = return $ PostProcess $ return () }
      in after' n11 r req @?= Decision' "p11"
  ]
n11Tests :: TestTree
n11Tests = decisionTestGroup "n11" "Redirect?"
  [ testCase "True + created + content type accepted ==> 303 See Other" $
      let
        r = resource
          { postAction = return . PostCreateRedir $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/html"] }
        aft = case after n11 r rq of
          (d, rd) -> (d, HashMap.lookup hLocation $_reqDataRespHeaders rd, _reqDataDispPath rd)
      in aft @?= (Done' seeOther303, Just ["http://example.com/webcrank"], ["webcrank"])
   , testCase "True + created + no content type accepted ==> 415 Unsupported Media Type" $
      let
        r = resource
          { postAction = return . PostCreateRedir $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/plain"] }
      in after' n11 r rq @?= error' unsupportedMediaType415
  , testCase "True + process ==> 303 See Other" $
      let r = resource { postAction = return $ PostProcessRedir $ return "http://example.com/webcrank" }
      in afterHdrs n11 r req @?=
        (Done' seeOther303, HashMap.singleton hLocation ["http://example.com/webcrank"])
  , testCase "False + created + content type accepted ==> p11" $
      let
        r = resource
          { postAction = return . PostCreate $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/html"] }
      in afterHdrs n11 r rq @?=
        (Decision' "p11", HashMap.singleton hLocation ["http://example.com/webcrank"])
  , testCase "False + created + no content type accepted ==> p11" $
      let
        r = resource
          { postAction = return . PostCreate $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/plain"] }
      in afterHdrs n11 r rq @?=
        (error' unsupportedMediaType415, HashMap.singleton hLocation ["http://example.com/webcrank"])
  , testCase "False + process ==> p11" $
      let r = resource { postAction = return $ PostProcess $ return () }
      in after' n11 r req @?= Decision' "p11"
  ]
n11Tests = decisionTestGroup "n11" "Redirect?"
  [ testCase "True + created + content type accepted ==> 303 See Other" $
      let
        r = resource
          { postAction = return . PostCreateRedir $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/html"] }
        aft = case after n11 r rq of
          (d, rd) -> (d, HashMap.lookup hLocation $_reqDataRespHeaders rd, _reqDataDispPath rd)
      in aft @?= (Done' seeOther303, Just ["http://example.com/webcrank"], ["webcrank"])
   , testCase "True + created + no content type accepted ==> 415 Unsupported Media Type" $
      let
        r = resource
          { postAction = return . PostCreateRedir $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/plain"] }
      in after' n11 r rq @?= error' unsupportedMediaType415
  , testCase "True + process ==> 303 See Other" $
      let r = resource { postAction = return $ PostProcessRedir $ return "http://example.com/webcrank" }
      in afterHdrs n11 r req @?=
        (Done' seeOther303, HashMap.singleton hLocation ["http://example.com/webcrank"])
  , testCase "False + created + content type accepted ==> p11" $
      let
        r = resource
          { postAction = return . PostCreate $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/html"] }
      in afterHdrs n11 r rq @?=
        (Decision' "p11", HashMap.singleton hLocation ["http://example.com/webcrank"])
  , testCase "False + created + no content type accepted ==> p11" $
      let
        r = resource
          { postAction = return . PostCreate $ ["webcrank"]
          , contentTypesAccepted = return [("text" // "html", return ())]
          }
        rq = req { reqHeaders = HashMap.singleton hContentType ["text/plain"] }
      in afterHdrs n11 r rq @?=
        (error' unsupportedMediaType415, HashMap.singleton hLocation ["http://example.com/webcrank"])
  , testCase "False + process ==> p11" $
      let r = resource { postAction = return $ PostProcess $ return () }
      in after' n11 r req @?= Decision' "p11"
  ]