diff --git a/search-app/src/cmr/search/api/association.clj b/search-app/src/cmr/search/api/association.clj index ad8946e206..be0c23e5a2 100644 --- a/search-app/src/cmr/search/api/association.clj +++ b/search-app/src/cmr/search/api/association.clj @@ -19,12 +19,8 @@ "When given a list of response entities, will set the http response status of each response entity based on its content. Ex) If the response entity contains an error message, will set the status as 400." [list] - (let [new-list (atom '())] - (doseq [map-item list] - (if (or (contains? map-item :errors) (contains? map-item :warning)) - (swap! new-list conj (assoc map-item :status 400)) - (swap! new-list conj (assoc map-item :status 200)))) - (reverse @new-list))) + (map #(assoc % :status (if (or (:errors %) (:warning %)) 400 200)) + list)) (defn- api-response "Creates an association response with the given data response" @@ -39,13 +35,9 @@ :headers {"Content-Type" mt/json}}))) (defn num-errors-in-assoc-results - "Counts num of errors in association-results" + "Counts the number of errors in association-results" [results] - (let [err-count (atom 0)] - (doseq [item results] - (if (contains? item :errors) - (swap! err-count inc))) - @err-count)) + (count (filter :errors results))) (defn association-results->status-code "Check for concept-types requiring error status to be returned. diff --git a/system-int-test/src/cmr/system_int_test/utils/association_util.clj b/system-int-test/src/cmr/system_int_test/utils/association_util.clj index b33e08d8b1..bae1f886ee 100644 --- a/system-int-test/src/cmr/system_int_test/utils/association_util.clj +++ b/system-int-test/src/cmr/system_int_test/utils/association_util.clj @@ -101,9 +101,4 @@ (defn add-individual-statuses [list] - (let [new-list (atom '())] - (doseq [map-item list] - (if (or (contains? map-item :errors) (contains? map-item :warning)) - (swap! new-list conj (assoc map-item :status 400)) - (swap! new-list conj (assoc map-item :status 200)))) - (reverse @new-list))) + (map #(assoc % :status (if (or (:errors %) (:warning %)) 400 200)) list)) diff --git a/system-int-test/src/cmr/system_int_test/utils/tag_util.clj b/system-int-test/src/cmr/system_int_test/utils/tag_util.clj index 8ff49ccb3f..9371d42afb 100644 --- a/system-int-test/src/cmr/system_int_test/utils/tag_util.clj +++ b/system-int-test/src/cmr/system_int_test/utils/tag_util.clj @@ -248,12 +248,8 @@ (defn add-individual-statuses [list] - (let [new-list (atom '())] - (doseq [map-item list] - (if (or (contains? map-item :errors) (contains? map-item :warning)) - (swap! new-list conj (assoc map-item :status 400)) - (swap! new-list conj (assoc map-item :status 200)))) - (reverse @new-list))) + [list] + (map #(assoc % :status (if (or (:errors %) (:warning %)) 400 200)) list)) (defn assert-tag-association-response-mixed? "Assert the tag association response when status code is 207 multi-status response."