Search in sources :

Example 1 with StellarResult

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

the class AssignmentCommandTest method testBadAssignmentExpr.

@Test
public void testBadAssignmentExpr() {
    StellarResult result = command.execute("x := 2 + ", executor);
    // validate the result
    assertTrue(result.isError());
    assertTrue(result.getException().isPresent());
    // no assignment should have happened
    assertFalse(executor.getState().containsKey("x"));
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Example 2 with StellarResult

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

the class AssignmentCommandTest method testAssignment.

@Test
public void testAssignment() {
    StellarResult result = command.execute("x := 2 + 2", executor);
    // validate the result
    assertTrue(result.isSuccess());
    assertTrue(result.getValue().isPresent());
    assertEquals(4, result.getValue().get());
    // validate assignment
    assertEquals(4, executor.getState().get("x").getResult());
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Example 3 with StellarResult

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

the class AssignmentCommandTest method testAssignmentWithOddWhitespace.

@Test
public void testAssignmentWithOddWhitespace() {
    StellarResult result = command.execute("        x   :=    2 +      2", executor);
    // validate the result
    assertTrue(result.isSuccess());
    assertTrue(result.getValue().isPresent());
    assertEquals(4, result.getValue().get());
    // validate assignment
    assertEquals(4, executor.getState().get("x").getResult());
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Example 4 with StellarResult

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

the class DocCommandTest method testFunctionNotDefined.

@Test
public void testFunctionNotDefined() {
    StellarResult result = command.execute("?INVALID", 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)

Example 5 with StellarResult

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

the class DocCommandTest method testWithFunction.

@Test
public void testWithFunction() {
    StellarResult result = command.execute("?TO_STRING", executor);
    // validate the result
    assertTrue(result.isSuccess());
    assertTrue(result.getValue().isPresent());
    // validate that we have some sort of doc string
    assertTrue(result.getValue().toString().length() > 0);
}
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