prop_queryJob_noUnknown :: Property
prop_queryJob_noUnknown =
  forAll (listOf (arbitrary::Gen (Positive Integer))) $ \ids ->
  forAll (elements (Map.keys Job.fieldsMap)) $ \field -> monadicIO $ do
  let qtype = ItemTypeLuxi QRJob
      flt = makeSimpleFilter (nameField qtype) $
            map (\(Positive i) -> Right i) ids
  QueryResult fdefs fdata <-
    run (query undefined False (Query qtype [field] flt)) >>= resultProp
  QueryFieldsResult fdefs' <-
    resultProp $ queryFields (QueryFields qtype [field])
  _ <- stop $ conjoin
              [ counterexample ("Got unknown fields via query (" ++
                                show fdefs ++ ")") (hasUnknownFields fdefs)
              , counterexample ("Got unknown result status via query (" ++
                                show fdata ++ ")")
                (all (all ((/= RSUnknown) . rentryStatus)) fdata)
              , counterexample ("Got unknown fields via query fields (" ++
                                show fdefs'++ ")") (hasUnknownFields fdefs')
              ]
  return ()

-- | Tests that an unknown field is returned as such.
prop_queryJob_noUnknown :: Property
prop_queryJob_noUnknown =
  forAll (listOf (arbitrary::Gen (Positive Integer))) $ \ids ->
  forAll (elements (Map.keys Job.fieldsMap)) $ \field -> monadicIO $ do
  let qtype = ItemTypeLuxi QRJob
      flt = makeSimpleFilter (nameField qtype) $
            map (\(Positive i) -> Right i) ids
  QueryResult fdefs fdata <-
    run (query undefined False (Query qtype [field] flt)) >>= resultProp
  QueryFieldsResult fdefs' <-
    resultProp $ queryFields (QueryFields qtype [field])
  _ <- stop $ conjoin
              [ counterexample ("Got unknown fields via query (" ++
                                show fdefs ++ ")") (hasUnknownFields fdefs)
              , counterexample ("Got unknown result status via query (" ++
                                show fdata ++ ")")
                (all (all ((/= RSUnknown) . rentryStatus)) fdata)
              , counterexample ("Got unknown fields via query fields (" ++
                                show fdefs'++ ")") (hasUnknownFields fdefs')
              ]
  return ()

-- | Tests that an unknown field is returned as such.
prop_queryJob_noUnknown =
  forAll (listOf (arbitrary::Gen (Positive Integer))) $ \ids ->
  forAll (elements (Map.keys Job.fieldsMap)) $ \field -> monadicIO $ do
  let qtype = ItemTypeLuxi QRJob
      flt = makeSimpleFilter (nameField qtype) $
            map (\(Positive i) -> Right i) ids
  QueryResult fdefs fdata <-
    run (query undefined False (Query qtype [field] flt)) >>= resultProp
  QueryFieldsResult fdefs' <-
    resultProp $ queryFields (QueryFields qtype [field])
  _ <- stop $ conjoin
              [ counterexample ("Got unknown fields via query (" ++
                                show fdefs ++ ")") (hasUnknownFields fdefs)
              , counterexample ("Got unknown result status via query (" ++
                                show fdata ++ ")")
                (all (all ((/= RSUnknown) . rentryStatus)) fdata)
              , counterexample ("Got unknown fields via query fields (" ++
                                show fdefs'++ ")") (hasUnknownFields fdefs')
              ]
  return ()

-- | Tests that an unknown field is returned as such.