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