Tabnine Logo
CoreEvent.getError
Code IndexAdd Tabnine to your IDE (free)

How to use
getError
method
in
org.mule.runtime.core.api.event.CoreEvent

Best Java code snippets using org.mule.runtime.core.api.event.CoreEvent.getError (Showing top 20 results out of 315)

origin: mulesoft/mule

 @Override
 public Supplier<Error> resolve(ExecutionContext executionContext) {
  return () -> ((ExecutionContextAdapter) executionContext).getEvent().getError().orElse(null);
 }
}
origin: mulesoft/mule

@Override
protected boolean matchesSafely(CoreEvent item) {
 return (messageMatcher != null ? messageMatcher.matches(item.getMessage()) : true)
   && (variablesMatcher != null ? variablesMatcher.matches(item.getVariables()) : true)
   && (securityContextMatcher != null ? securityContextMatcher.matches(item.getSecurityContext()) : true)
   && (errorTypeMatcher != null ? errorTypeMatcher.matches(item.getError().get().getErrorType()) : true);
}
origin: mulesoft/mule

@Override
public CoreEvent process(CoreEvent event) throws MuleException {
 event.getError().ifPresent(theError -> exception = theError.getCause());
 TypedValue<Object> payload = event.getMessage().getPayload();
 if (payload.getValue() != null) {
  messages.add((TestTransactionalConnection) payload.getValue());
 }
 return event;
}
origin: mulesoft/mule

@Before
public void setUp() {
 when(event.getError()).thenReturn(empty());
 when(event.getAuthentication()).thenReturn(empty());
 Message msg = of(null);
 when(event.getMessage()).thenReturn(msg);
 when(event.asBindingContext()).thenReturn(getTargetBindingContext(msg));
 when(event.getItemSequenceInfo()).thenReturn(empty());
}
origin: mulesoft/mule

private CoreEvent getEventWithError(Optional<Error> error) {
 CoreEvent event = mock(CoreEvent.class, RETURNS_DEEP_STUBS);
 doReturn(error).when(event).getError();
 when(event.getMessage().getPayload()).thenReturn(new TypedValue<>(null, OBJECT));
 when(event.getMessage().getAttributes()).thenReturn(new TypedValue<>(null, OBJECT));
 when(event.getAuthentication()).thenReturn(empty());
 when(event.getItemSequenceInfo()).thenReturn(empty());
 return event;
}
origin: mulesoft/mule

private void assertExceptionErrorType(MessagingException me, ErrorType expected) {
 Optional<Error> error = me.getEvent().getError();
 assertThat("No error found, expecting error with error type [" + expected + "]", error.isPresent(), is(true));
 assertThat(error.get().getErrorType(), is(expected));
}
origin: mulesoft/mule

@Test
public void payloadInfoConsumable() throws Exception {
 MuleException.verboseExceptions = true;
 CoreEvent testEvent = mock(CoreEvent.class);
 when(testEvent.getError()).thenReturn(empty());
 final ByteArrayInputStream payload = new ByteArrayInputStream(new byte[] {});
 Message muleMessage = of(payload);
 when(testEvent.getMessage()).thenReturn(muleMessage);
 MessagingException e = new MessagingException(createStaticMessage(message), testEvent);
 assertThat((String) e.getInfo().get(PAYLOAD_INFO_KEY), containsString(ByteArrayInputStream.class.getName() + "@"));
 verify(transformationService, never()).transform(muleMessage, DataType.STRING);
}
origin: mulesoft/mule

 @Override
 protected boolean matchesSafely(MessagingException item) {
  errorTypeId = item.getEvent().getError().get().getErrorType().getIdentifier();
  return FLOW_BACK_PRESSURE_ERROR_IDENTIFIER.equals(errorTypeId);
 }
};
origin: mulesoft/mule

@Test
public void payloadInfoNonVerbose() throws Exception {
 MuleException.verboseExceptions = false;
 CoreEvent testEvent = mock(CoreEvent.class);
 Message muleMessage = spy(of(""));
 when(testEvent.getMessage()).thenReturn(muleMessage);
 when(testEvent.getError()).thenReturn(empty());
 MessagingException e = new MessagingException(createStaticMessage(message), testEvent);
 assertThat(e.getInfo().get(PAYLOAD_INFO_KEY), nullValue());
 verify(muleMessage, never()).getPayload();
 verify(transformationService, never()).transform(muleMessage, DataType.STRING);
}
origin: mulesoft/mule

@Test
public void onException() {
 callback.onException(exception);
 verify(responseCallback).responseSentWithFailure(
                          argThat(e -> e.getRootCause().equals(exception)),
                          argThat(event -> event.getError().isPresent()
                            && event.getError().get().getErrorType().equals(errorType)));
}
origin: mulesoft/mule

/**
 * Runs the specified flow with the provided event and configuration expecting a failure with an error type that matches the
 * given {@code matcher}.
 * <p>
 * Will fail if there's no failure running the flow.
 */
public void runExpectingException(ErrorTypeMatcher matcher) throws Exception {
 try {
  runNoVerify();
  fail("Flow executed successfully. Expecting exception");
 } catch (EventProcessingException e) {
  verify(getFlowConstructName());
  assertThat(e.getEvent().getError().get().getErrorType(), matcher);
 }
}
origin: mulesoft/mule

/**
 * Runs the specified flow with the provided event and configuration expecting a failure with a cause that matches the given
 * {@code matcher}.
 * <p>
 * Will fail if there's no failure running the flow.
 */
public void runExpectingException(Matcher<Throwable> causeMatcher) throws Exception {
 try {
  runNoVerify();
  fail("Flow executed successfully. Expecting exception");
 } catch (EventProcessingException e) {
  verify(getFlowConstructName());
  assertThat(e.getEvent().getError().get().getCause(), causeMatcher);
 }
}
origin: mulesoft/mule

@Test
public void resolveExceptionWithUnknownUnderlyingError() {
 Optional<Error> surfaceError = mockError(CONNECTION, null);
 when(event.getError()).thenReturn(surfaceError);
 MessagingException me = newMessagingException(new Exception(), event, processor);
 MessagingException resolved = resolver.resolve(me, context);
 assertExceptionErrorType(resolved, CONNECTION);
}
origin: mulesoft/mule

@Test
public void resolveExceptionWithCriticalUnderlyingError() {
 Optional<Error> surfaceError = mockError(CONNECTION, null);
 when(event.getError()).thenReturn(surfaceError);
 MessagingException me = newMessagingException(ERROR, event, processor);
 MessagingException resolved = resolver.resolve(me, context);
 assertExceptionErrorType(resolved, CONNECTION);
}
origin: mulesoft/mule

@Test
public void testHandleExceptionWithConfiguredMessageProcessors() throws Exception {
 onErrorContinueHandler
   .setMessageProcessors(asList(createSetStringMessageProcessor("A"), createSetStringMessageProcessor("B")));
 initialiseIfNeeded(onErrorContinueHandler, muleContext);
 when(mockException.handled()).thenReturn(true);
 when(mockException.getDetailedMessage()).thenReturn(DEFAULT_LOG_MESSAGE);
 when(mockException.getEvent()).thenReturn(muleEvent);
 final CoreEvent result = onErrorContinueHandler.handleException(mockException, muleEvent);
 verify(mockException).setHandled(true);
 assertThat(result.getMessage().getPayload().getValue(), is("B"));
 assertThat(result.getError().isPresent(), is(false));
}
origin: mulesoft/mule

@Test
public void resolveWithAnEventThatCarriesError() {
 Optional<Error> surfaceError = mockError(TRANSFORMER, null);
 when(event.getError()).thenReturn(surfaceError);
 MessagingException me = newMessagingException(new Exception(), event, processor);
 MessagingException resolved = resolver.resolve(me, context);
 assertExceptionErrorType(resolved, TRANSFORMER);
 assertExceptionMessage(resolved.getMessage(), ERROR_MESSAGE);
}
origin: mulesoft/mule

@Test
public void resolveWithParentInChain() {
 ErrorType withParent = ErrorTypeBuilder.builder().parentErrorType(CONNECTION).identifier("CONNECT").namespace("TEST").build();
 Optional<Error> surfaceError = mockError(withParent, new Exception());
 when(event.getError()).thenReturn(surfaceError);
 Exception cause = new ConnectionException("Some Connection Error", new Exception());
 MessagingException me = newMessagingException(cause, event, processor);
 MessagingException resolved = resolver.resolve(me, context);
 assertExceptionErrorType(resolved, withParent);
 assertExceptionMessage(resolved.getMessage(), ERROR_MESSAGE);
}
origin: mulesoft/mule

@Test
public void resolveWithMultipleErrors() {
 Optional<Error> surfaceError = mockError(TRANSFORMER, TRANSFORMER_EXCEPTION);
 when(event.getError()).thenReturn(surfaceError);
 Exception cause = new Exception(new ConnectionException(FATAL_EXCEPTION));
 MessagingException me = newMessagingException(cause, event, processor);
 MessagingException resolved = resolver.resolve(me, context);
 assertExceptionErrorType(resolved, FATAL);
 assertExceptionMessage(resolved.getMessage(), FATAL_EXCEPTION.getMessage());
}
origin: mulesoft/mule

@Test
public void resolveTopExceptionWithSameError() {
 Optional<Error> surfaceError = mockError(TRANSFORMER, TRANSFORMER_EXCEPTION);
 when(event.getError()).thenReturn(surfaceError);
 Exception cause = new MuleFatalException(createStaticMessage(EXPECTED_MESSAGE), new LinkageError("!"));
 MessagingException me = newMessagingException(cause, event, processor);
 MessagingException resolved = resolver.resolve(me, context);
 assertExceptionErrorType(resolved, FATAL);
 assertExceptionMessage(resolved.getMessage(), EXPECTED_MESSAGE);
}
origin: mulesoft/mule

private String getPayload(Processor mp, MuleSession session, String message) throws Exception {
 Message msg = of(message);
 try {
  CoreEvent event = mp.process(this.<PrivilegedEvent.Builder>getEventBuilder().message(msg).session(session).build());
  Message returnedMessage = event.getMessage();
  if (event.getError().isPresent()) {
   return EXCEPTION_SEEN;
  } else {
   return getPayloadAsString(returnedMessage);
  }
 } catch (Exception ex) {
  return EXCEPTION_SEEN;
 }
}
org.mule.runtime.core.api.eventCoreEventgetError

Popular methods of CoreEvent

  • getMessage
  • builder
    Create new Builder based on an existing CoreEvent instance. The existing EventContext is conserved.
  • getContext
  • getVariables
  • getSecurityContext
    The security context for this session. If not null outbound, inbound and/or method invocations will
  • asBindingContext
  • getCorrelationId
  • getFlowCallStack
    Events have a stack of executed flows (same as a call stack), so that at any given instant an applic
  • getItemSequenceInfo
  • getAuthentication
  • getGroupCorrelation
    Returns the correlation metadata of this message. See GroupCorrelation.
  • getVariableValueOrNull
    Helper method to get the value of a given variable in a null-safe manner such that null is returned
  • getGroupCorrelation,
  • getVariableValueOrNull

Popular in Java

  • Making http post requests using okhttp
  • getExternalFilesDir (Context)
  • setScale (BigDecimal)
  • getSharedPreferences (Context)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now