use of org.opensearch.script.ScriptException in project OpenSearch by opensearch-project.
the class ExpressionFieldScriptTests method testCompileError.
public void testCompileError() {
ScriptException e = expectThrows(ScriptException.class, () -> {
compile("doc['field'].value * *@#)(@$*@#$ + 4");
});
assertTrue(e.getCause() instanceof ParseException);
}
use of org.opensearch.script.ScriptException in project OpenSearch by opensearch-project.
the class ExpressionFieldScriptTests method testLinkError.
public void testLinkError() {
ScriptException e = expectThrows(ScriptException.class, () -> {
compile("doc['nonexistent'].value * 5");
});
assertTrue(e.getCause() instanceof ParseException);
}
use of org.opensearch.script.ScriptException in project OpenSearch by opensearch-project.
the class ExpressionTermsSetQueryTests method testLinkError.
public void testLinkError() {
ScriptException e = expectThrows(ScriptException.class, () -> {
compile("doc['nonexistent'].value * 5");
});
assertTrue(e.getCause() instanceof ParseException);
}
use of org.opensearch.script.ScriptException in project OpenSearch by opensearch-project.
the class ExpressionTermsSetQueryTests method testCompileError.
public void testCompileError() {
ScriptException e = expectThrows(ScriptException.class, () -> {
compile("doc['field'].value * *@#)(@$*@#$ + 4");
});
assertTrue(e.getCause() instanceof ParseException);
}
use of org.opensearch.script.ScriptException in project OpenSearch by opensearch-project.
the class DebugTests method testPainlessExplainErrorSerialization.
/**
* {@link PainlessExplainError} doesn't serialize but the headers still make it.
*/
public void testPainlessExplainErrorSerialization() throws IOException {
Map<String, Object> params = singletonMap("a", "jumped over the moon");
ScriptException e = expectThrows(ScriptException.class, () -> exec("Debug.explain(params.a)", params, true));
assertEquals(singletonList("jumped over the moon"), e.getMetadata("opensearch.to_string"));
assertEquals(singletonList("java.lang.String"), e.getMetadata("opensearch.java_class"));
assertEquals(singletonList("java.lang.String"), e.getMetadata("opensearch.painless_class"));
try (BytesStreamOutput out = new BytesStreamOutput()) {
out.writeException(e);
try (StreamInput in = out.bytes().streamInput()) {
OpenSearchException read = (ScriptException) in.readException();
assertEquals(singletonList("jumped over the moon"), read.getMetadata("opensearch.to_string"));
assertEquals(singletonList("java.lang.String"), read.getMetadata("opensearch.java_class"));
assertEquals(singletonList("java.lang.String"), read.getMetadata("opensearch.painless_class"));
}
}
}
Aggregations