use of org.apache.metron.stellar.dsl.Stellar in project metron by apache.
the class BaseFunctionResolver method resolveFunction.
/**
* Resolves a Stellar function from a given class.
* @param clazz The class.
*/
public static StellarFunctionInfo resolveFunction(Class<? extends StellarFunction> clazz) {
StellarFunctionInfo info = null;
// the class must be annotated
if (clazz.isAnnotationPresent(Stellar.class)) {
Stellar annotation = clazz.getAnnotation(Stellar.class);
String fullyQualifiedName = getNameFromAnnotation(annotation);
StellarFunction function = createFunction(clazz);
if (fullyQualifiedName != null && function != null) {
info = new StellarFunctionInfo(annotation.description(), fullyQualifiedName, annotation.params(), annotation.returns(), function);
}
}
return info;
}
use of org.apache.metron.stellar.dsl.Stellar 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