|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | +package org.elasticsearch.action.delete; |
| 20 | + |
| 21 | +import org.elasticsearch.action.ActionRequestValidationException; |
| 22 | +import org.elasticsearch.test.ESTestCase; |
| 23 | + |
| 24 | +import static org.hamcrest.CoreMatchers.hasItems; |
| 25 | +import static org.hamcrest.CoreMatchers.not; |
| 26 | +import static org.hamcrest.CoreMatchers.nullValue; |
| 27 | + |
| 28 | +public class DeleteRequestTests extends ESTestCase { |
| 29 | + |
| 30 | + public void testValidation() { |
| 31 | + { |
| 32 | + final DeleteRequest request = new DeleteRequest("index4", "_doc", "0"); |
| 33 | + final ActionRequestValidationException validate = request.validate(); |
| 34 | + |
| 35 | + assertThat(validate, nullValue()); |
| 36 | + } |
| 37 | + |
| 38 | + { |
| 39 | + final DeleteRequest request = new DeleteRequest("index4", randomBoolean() ? "" : null, randomBoolean() ? "" : null); |
| 40 | + final ActionRequestValidationException validate = request.validate(); |
| 41 | + |
| 42 | + assertThat(validate, not(nullValue())); |
| 43 | + assertThat(validate.validationErrors(), hasItems("type is missing", "id is missing")); |
| 44 | + } |
| 45 | + } |
| 46 | +} |
0 commit comments