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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations