code: public static Event validateEventIdForMatchingTransitionInContext(final String eventId,
                                                                        final Optional<RequestContext> context,
                                                                        final Map<String, Object> attributes) {
          val attributesMap = new LocalAttributeMap<Object>(attributes);
          val event = new Event(eventId, eventId, attributesMap);
  
          return context.map(ctx -> {
              val def = ctx.getMatchingTransition(event.getId());
              if (def == null) {
                  throw new AuthenticationException("Transition definition cannot be found for event " + event.getId());
              }
              return event;
          }).orElse(event);
      }
docs: Validate event id for matching transition in context event.
  
  @param eventId    the event id
  @param context    the context
  @param attributes the attributes
  @return the event