Search in sources :

Example 1 with ClasspathFunctionResolver

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);
}
Also used : ClasspathFunctionResolver(org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver) JSONParser(org.json.simple.parser.JSONParser) Before(org.junit.Before)

Example 2 with ClasspathFunctionResolver

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;
}
Also used : Context(org.apache.metron.stellar.dsl.Context) ClasspathFunctionResolver(org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver)

Example 3 with ClasspathFunctionResolver

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"));
}
Also used : ClasspathFunctionResolver(org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver) Properties(java.util.Properties) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with ClasspathFunctionResolver

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);
}
Also used : ClasspathFunctionResolver(org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver) Stellar(org.apache.metron.stellar.dsl.Stellar) Test(org.junit.Test)

Aggregations

ClasspathFunctionResolver (org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver)4 Test (org.junit.Test)2 HashSet (java.util.HashSet)1 Properties (java.util.Properties)1 Context (org.apache.metron.stellar.dsl.Context)1 Stellar (org.apache.metron.stellar.dsl.Stellar)1 JSONParser (org.json.simple.parser.JSONParser)1 Before (org.junit.Before)1