|
137 | 137 | :condition combined}) |
138 | 138 | result (gcrf/extract-spatial-conditions query)] |
139 | 139 | (is (= [or-group cond3] result))))) |
| 140 | + |
| 141 | +(deftest extract-spatial-conditions-validates-parent-path-test |
| 142 | + (testing "Rejects SpatialCondition under NegatedCondition" |
| 143 | + (let [spatial-cond (make-spatial-condition 10 0) |
| 144 | + negated (q/negated-condition spatial-cond) |
| 145 | + query (q/query {:concept-type :collection |
| 146 | + :condition negated})] |
| 147 | + (is (thrown? Exception |
| 148 | + (gcrf/extract-spatial-conditions query))))) |
| 149 | + |
| 150 | + (testing "Rejects SpatialCondition nested under NegatedCondition in AND group" |
| 151 | + (let [spatial-cond (make-spatial-condition 10 0) |
| 152 | + title-cond (q/string-condition :entry-title "test") |
| 153 | + negated (q/negated-condition spatial-cond) |
| 154 | + combined (gc/and-conds [title-cond negated]) |
| 155 | + query (q/query {:concept-type :collection |
| 156 | + :condition combined})] |
| 157 | + (is (thrown? Exception |
| 158 | + (gcrf/extract-spatial-conditions query))))) |
| 159 | + |
| 160 | + (testing "Accepts valid SpatialCondition in AND group" |
| 161 | + (let [spatial-cond (make-spatial-condition 10 0) |
| 162 | + title-cond (q/string-condition :entry-title "test") |
| 163 | + combined (gc/and-conds [title-cond spatial-cond]) |
| 164 | + query (q/query {:concept-type :collection |
| 165 | + :condition combined})] |
| 166 | + (is (seq (gcrf/extract-spatial-conditions query))))) |
| 167 | + |
| 168 | + (testing "Accepts valid SpatialCondition at top level" |
| 169 | + (let [spatial-cond (make-spatial-condition 10 0) |
| 170 | + query (q/query {:concept-type :collection |
| 171 | + :condition spatial-cond})] |
| 172 | + (is (seq (gcrf/extract-spatial-conditions query))))) |
| 173 | + |
| 174 | + (testing "Preserves MultiPolygon OR groups with validation" |
| 175 | + (let [spatial-cond-1 (make-spatial-condition 10 0) |
| 176 | + spatial-cond-2 (make-spatial-condition 20 10) |
| 177 | + or-group (gc/or-conds [spatial-cond-1 spatial-cond-2]) |
| 178 | + query (q/query {:concept-type :collection |
| 179 | + :condition or-group})] |
| 180 | + (is (= [or-group] (gcrf/extract-spatial-conditions query)))))) |
0 commit comments