use of org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver in project metron by apache.
the class DefaultStellarStatefulExecutorTest method setup.
@Before
public void setup() throws ParseException {
// parse the input message
JSONParser parser = new JSONParser();
message = (JSONObject) parser.parse(input);
// create the executor to test
executor = new DefaultStellarStatefulExecutor();
executor.setContext(Context.EMPTY_CONTEXT());
ClasspathFunctionResolver resolver = new ClasspathFunctionResolver();
executor.setFunctionResolver(resolver);
}
use of org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver in project metron by apache.
the class StellarClasspathFunctionResolver method create.
public static ClasspathFunctionResolver create(Properties config) {
ClasspathFunctionResolver resolver = new ClasspathFunctionResolver();
Context context = new Context.Builder().with(Context.Capabilities.STELLAR_CONFIG, () -> config).build();
resolver.initialize(context);
return resolver;
}
use of org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver in project metron by apache.
the class StellarClasspathFunctionResolver method test.
@Test
public void test() throws Exception {
Properties config = new Properties();
config.put(STELLAR_VFS_PATHS.param(), configuration.get("fs.defaultFS") + "/classpath-resources/.*.jar");
ClasspathFunctionResolver resolver = create(config);
HashSet<String> functions = new HashSet<>(Lists.newArrayList(resolver.getFunctions()));
Assert.assertTrue(functions.contains("NOW"));
}
use of org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver in project metron by apache.
the class BasicStellarTest method ensureDocumentation.
@Test
public void ensureDocumentation() {
ClassLoader classLoader = getClass().getClassLoader();
int numFound = 0;
for (Class<?> clazz : new ClasspathFunctionResolver().resolvables()) {
if (clazz.isAnnotationPresent(Stellar.class)) {
numFound++;
Stellar annotation = clazz.getAnnotation(Stellar.class);
Assert.assertFalse("Must specify a name for " + clazz.getName(), StringUtils.isEmpty(annotation.name()));
Assert.assertFalse("Must specify a description annotation for " + clazz.getName(), StringUtils.isEmpty(annotation.description()));
Assert.assertFalse("Must specify a returns annotation for " + clazz.getName(), StringUtils.isEmpty(annotation.returns()));
}
}
Assert.assertTrue(numFound > 0);
}
Aggregations