private void updateResult(Result result, Machine machine) {
   int completed = 0, failed = 0, notExecuted = 0, incomplete = 0;
   for (Context context : machine.getContexts()) {
     switch (context.getExecutionStatus()) {
       case COMPLETED:
         {
           completed++;
         }
         break;
       case FAILED:
         {
           failed++;
         }
         break;
       case NOT_EXECUTED:
         {
           notExecuted++;
         }
         break;
       case EXECUTING:
         {
           incomplete++;
         }
     }
   }
   result.setCompletedCount(completed);
   result.setFailedCount(failed);
   result.setNotExecutedCount(notExecuted);
   result.setIncompleteCount(incomplete);
   for (MachineException exception : getFailures()) {
     result.addError(getStackTrace(exception.getCause()));
   }
 }
 private void configureContext(Context context) {
   Set<Model> models = AnnotationUtils.getAnnotations(context.getClass(), Model.class);
   GraphWalker annotation = context.getClass().getAnnotation(GraphWalker.class);
   if (!models.isEmpty()) {
     Path path = Paths.get(models.iterator().next().file());
     ContextFactoryScanner.get(reflections, path).create(path, context);
   }
   if (!"".equals(annotation.value())) {
     context.setPathGenerator(GeneratorFactory.parse(annotation.value()));
   } else {
     context.setPathGenerator(PathGeneratorFactory.createPathGenerator(annotation));
   }
   if (!"".equals(annotation.start())) {
     context.setNextElement(getElement(context.getModel(), annotation.start()));
   }
 }
 private List<Element> createConnectedComponent(
     Map<Element, ElementStatus> elementStatusMap, Element root) {
   List<Element> connectedComponent = new ArrayList<>();
   Deque<Element> stack = new ArrayDeque<>();
   stack.push(root);
   while (!stack.isEmpty()) {
     Element element = stack.pop();
     if (ElementStatus.UNREACHABLE.equals(elementStatusMap.get(element))) {
       connectedComponent.add(element);
       elementStatusMap.put(element, ElementStatus.REACHABLE);
       if (element instanceof RuntimeVertex) {
         RuntimeVertex vertex = (RuntimeVertex) element;
         for (RuntimeEdge edge : context.getModel().getOutEdges(vertex)) {
           stack.push(edge);
         }
       } else if (element instanceof RuntimeEdge) {
         RuntimeEdge edge = (RuntimeEdge) element;
         stack.push(edge.getTargetVertex());
       }
     }
   }
   return Collections.unmodifiableList(connectedComponent);
 }
 public List<Element> getConnectedComponent(Element root) {
   return createConnectedComponent(createElementStatusMap(context.getModel().getElements()), root);
 }