Search in sources :

Example 16 with StellarResult

use of org.apache.metron.stellar.common.shell.StellarResult in project metron by apache.

the class AssignmentCommandTest method testErrorMessageWhenAssignmentFails.

/**
 * If an assignment expression fails, the error message should explain
 * why the expression fails.
 */
@Test
public void testErrorMessageWhenAssignmentFails() {
    StellarResult result = command.execute("x := 0/0", executor);
    // validate the result
    assertTrue(result.isError());
    assertTrue(result.getException().isPresent());
    assertEquals(ArithmeticException.class, result.getException().get().getClass());
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Example 17 with StellarResult

use of org.apache.metron.stellar.common.shell.StellarResult in project metron by apache.

the class AssignmentCommandTest method testAssignmentOfEmptyVar.

@Test
public void testAssignmentOfEmptyVar() {
    // z is not defined
    StellarResult result = command.execute("x := z", executor);
    // validate the result
    assertTrue(result.isSuccess());
    assertTrue(result.isValueNull());
    assertFalse(result.getValue().isPresent());
    // the value of x is null
    assertNull(executor.getState().get("x").getResult());
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Example 18 with StellarResult

use of org.apache.metron.stellar.common.shell.StellarResult in project metron by apache.

the class AssignmentCommandTest method testNoAssignmentExpr.

/**
 * Assignment with no expression results in an empty string.  Is this
 * what we would expect?
 */
@Test
public void testNoAssignmentExpr() {
    StellarResult result = command.execute("x := ", executor);
    // validate the result
    assertTrue(result.isSuccess());
    assertTrue(result.getValue().isPresent());
    // validate assignment
    assertEquals("", executor.getState().get("x").getResult());
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Example 19 with StellarResult

use of org.apache.metron.stellar.common.shell.StellarResult in project metron by apache.

the class CommentTest method testComment.

@Test
public void testComment() {
    StellarResult result = magic.execute("#  this is a comment ", executor);
    // validate the result
    assertTrue(result.isSuccess());
    assertTrue(result.getValue().isPresent());
    assertEquals("", result.getValue().get());
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Example 20 with StellarResult

use of org.apache.metron.stellar.common.shell.StellarResult in project metron by apache.

the class DocCommandTest method testNoFunction.

@Test
public void testNoFunction() {
    StellarResult result = command.execute("?", executor);
    // validate the result
    assertTrue(result.isError());
    assertTrue(result.getException().isPresent());
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Aggregations

StellarResult (org.apache.metron.stellar.common.shell.StellarResult)28 Test (org.junit.Test)23 Optional (java.util.Optional)2 StellarAssignment (org.apache.metron.stellar.common.StellarAssignment)2 Spliterator (java.util.Spliterator)1 Function (java.util.function.Function)1 StreamSupport (java.util.stream.StreamSupport)1 StringUtils (org.apache.commons.lang3.StringUtils)1 StellarResult.error (org.apache.metron.stellar.common.shell.StellarResult.error)1 StellarResult.success (org.apache.metron.stellar.common.shell.StellarResult.success)1 StellarShellExecutor (org.apache.metron.stellar.common.shell.StellarShellExecutor)1 StellarFunctionInfo (org.apache.metron.stellar.dsl.StellarFunctionInfo)1 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)1