fix empty results
This commit is contained in:
parent
8955eeb70a
commit
9fee8f8a7e
@ -47,19 +47,22 @@ public class CompilerService {
|
|||||||
final Class<?> clazz = classLoader.loadClass(qualifiedClassName);
|
final Class<?> clazz = classLoader.loadClass(qualifiedClassName);
|
||||||
Map<String, Boolean> results = Map.of();
|
Map<String, Boolean> results = Map.of();
|
||||||
|
|
||||||
|
try {
|
||||||
Method[] methods = clazz.getMethods();
|
Method[] methods = clazz.getMethods();
|
||||||
for (Method m : methods) {
|
for (Method m : methods) {
|
||||||
if ("run".equals(m.getName())) {
|
if ("run".equals(m.getName())) {
|
||||||
try {
|
|
||||||
results = (Map<String, Boolean>) m.invoke(null, new Object[]{});
|
results = (Map<String, Boolean>) m.invoke(null, new Object[]{});
|
||||||
} catch (Exception e) {
|
|
||||||
results = Map.of("Exception: " + ExceptionUtils.getStackTrace(ExceptionUtils.getRootCause(e)), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (results.isEmpty()) {
|
||||||
|
results = Map.of("No existe ningun resultado. Verifique el metodo 'run()'.", false);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
results = Map.of("Exception: " + ExceptionUtils.getStackTrace(ExceptionUtils.getRootCause(e)), false);
|
||||||
|
}
|
||||||
|
|
||||||
return Optional.of(results.entrySet().stream()
|
return Optional.of(results.entrySet().stream()
|
||||||
.map(e -> String.format("%-50s ... %4s", e.getKey(), RESULT_MESSAGE.get(e.getValue())))
|
.map(e -> String.format("%-50s ... %4s", e.getKey(), RESULT_MESSAGE.get(e.getValue())))
|
||||||
.collect(Collectors.joining("\n")));
|
.collect(Collectors.joining("\n")));
|
||||||
|
Loading…
Reference in New Issue
Block a user