Add better validation error message and a dedicated test
This commit is contained in:
parent
0ed0fea558
commit
9f382da5d3
|
@ -94,7 +94,7 @@ public class PutMappingRequest extends AcknowledgedRequest<PutMappingRequest> im
|
||||||
validationException = addValidationError("mapping source is empty", validationException);
|
validationException = addValidationError("mapping source is empty", validationException);
|
||||||
}
|
}
|
||||||
if (concreteIndex != null && (indices != null && indices.length > 0)) {
|
if (concreteIndex != null && (indices != null && indices.length > 0)) {
|
||||||
validationException = addValidationError("either concreteIndices or unresolved indices can be set", validationException);
|
validationException = addValidationError("either concreteIndices or unresolved indices can be set concrete: [" + concreteIndex + "] and indices: " + indices , validationException);
|
||||||
}
|
}
|
||||||
return validationException;
|
return validationException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.action.admin.indices.mapping.put;
|
package org.elasticsearch.action.admin.indices.mapping.put;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
import org.elasticsearch.action.ActionRequestValidationException;
|
||||||
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
public class PutMappingRequestTests extends ESTestCase {
|
public class PutMappingRequestTests extends ESTestCase {
|
||||||
|
@ -48,5 +49,10 @@ public class PutMappingRequestTests extends ESTestCase {
|
||||||
r.source("somevalidmapping");
|
r.source("somevalidmapping");
|
||||||
ex = r.validate();
|
ex = r.validate();
|
||||||
assertNull("validation should succeed", ex);
|
assertNull("validation should succeed", ex);
|
||||||
|
|
||||||
|
r.setConcreteIndex(new Index("foo", "bar"));
|
||||||
|
ex = r.validate();
|
||||||
|
assertNotNull("source validation should fail", ex);
|
||||||
|
assertTrue(ex.getMessage().contains("either concreteIndices or unresolved indices can be set"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue