Search in sources :

Example 21 with StellarResult

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

the class MagicDefineGlobalTest method testMissingExpression.

@Test
public void testMissingExpression() {
    StellarResult result = magic.execute("%define", executor);
    // validate the result
    assertTrue(result.isError());
    assertFalse(result.getValue().isPresent());
    assertTrue(result.getException().isPresent());
    // the global config should not have changed
    assertEquals(0, executor.getGlobalConfig().size());
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Example 22 with StellarResult

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

the class MagicDefineGlobalTest method testNotAssignmentExpression.

@Test
public void testNotAssignmentExpression() {
    StellarResult result = magic.execute("%define 2 + 2", executor);
    // validate the result
    assertTrue(result.isError());
    assertFalse(result.getValue().isPresent());
    assertTrue(result.getException().isPresent());
    // the global config should not have changed
    assertEquals(0, executor.getGlobalConfig().size());
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Example 23 with StellarResult

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

the class MagicListFunctionsTest method testFunctionsWithMatch.

@Test
public void testFunctionsWithMatch() {
    StellarResult result = magic.execute("%functions UPPER", executor);
    // validate the result
    assertTrue(result.isSuccess());
    assertTrue(result.getValue().isPresent());
    // only 1 function; TO_UPPER should be returned
    String value = ConversionUtils.convert(result.getValue().get(), String.class);
    String[] functions = value.split(", ");
    assertEquals(1, functions.length);
    assertEquals("TO_UPPER", functions[0]);
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Example 24 with StellarResult

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

the class MagicListFunctionsTest method testFunctions.

@Test
public void testFunctions() {
    StellarResult result = magic.execute("%functions", executor);
    // validate the result
    assertTrue(result.isSuccess());
    assertTrue(result.getValue().isPresent());
    // there are 3 functions that should be returned
    String value = ConversionUtils.convert(result.getValue().get(), String.class);
    String[] functions = value.split(", ");
    assertEquals(3, functions.length);
}
Also used : StellarResult(org.apache.metron.stellar.common.shell.StellarResult) Test(org.junit.Test)

Example 25 with StellarResult

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

the class MagicListFunctionsTest method testFunctionsWithNoMatch.

@Test
public void testFunctionsWithNoMatch() {
    StellarResult result = magic.execute("%functions NOMATCH", executor);
    // validate the result
    assertTrue(result.isSuccess());
    assertTrue(result.getValue().isPresent());
    // no functions should be returned
    String value = ConversionUtils.convert(result.getValue().get(), String.class);
    String[] functions = value.trim().split(", ");
    assertEquals(1, functions.length);
    assertEquals("", functions[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