congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
CoreEvent.builder
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: mulesoft/mule

private CoreEvent createMuleEvent(Message message, int numProperties) {
 final Builder builder;
 try {
  builder = CoreEvent.builder(create(flow, CONNECTOR_LOCATION)).message(message);
 } catch (Exception e) {
  throw new RuntimeException(e);
 }
 for (int i = 1; i <= numProperties; i++) {
  builder.addVariable("FlOwVaRiAbLeKeY" + i, "val");
 }
 return builder.build();
}
origin: mulesoft/mule

@Benchmark
@Threads(Threads.MAX)
public Either<SourcePolicyFailureResult, SourcePolicySuccessResult> source() {
 CoreEvent event;
 Message.Builder messageBuilder = Message.builder().value(PAYLOAD);
 CoreEvent.Builder eventBuilder =
   CoreEvent.builder(create("", "", CONNECTOR_LOCATION, NullExceptionHandler.getInstance())).message(messageBuilder.build());
 event = eventBuilder.build();
 return from(handler.process(event, sourceRpp)).block();
}
origin: mulesoft/mule

@Benchmark
@Threads(Threads.MAX)
public Either<SourcePolicyFailureResult, SourcePolicySuccessResult> source() {
 CoreEvent event;
 Message.Builder messageBuilder = Message.builder().value(PAYLOAD);
 CoreEvent.Builder eventBuilder =
   CoreEvent.builder(create("", "", CONNECTOR_LOCATION, NullExceptionHandler.getInstance())).message(messageBuilder.build());
 event = eventBuilder.build();
 return from(handler.process(event, sourceRpp)).block();
}
origin: mulesoft/mule

@Test
public void operationReturnsOperationResultThatOnlySpecifiesPayload() throws Exception {
 Object payload = "hello world!";
 when(operationExecutor.execute(any(ExecutionContext.class))).thenReturn(just(builder().output(payload).build()));
 event =
   CoreEvent.builder(event).message(Message.builder().value("").attributesValue(mock(Object.class)).build()).build();
 Message message = messageProcessor.process(event).getMessage();
 assertThat(message, is(notNullValue()));
 assertThat(message.getPayload().getValue(), is(sameInstance(payload)));
 assertThat(message.getAttributes().getValue(), is(nullValue()));
 assertThat(message.getPayload().getDataType().getType().equals(String.class), is(true));
}
origin: mulesoft/mule

protected TypedValue evaluateTyped(String expression, CoreEvent event) throws Exception {
 if (variant.equals(Variant.EXPRESSION_WITH_DELIMITER)) {
  return mvel.evaluate("#[mel:" + expression + "]", event, CoreEvent.builder(event),
             ((Component) flowConstruct).getLocation(),
             BindingContext.builder().build());
 } else {
  return mvel.evaluate(expression, event, CoreEvent.builder(event), ((Component) flowConstruct).getLocation(),
             BindingContext.builder().build());
 }
}
origin: mulesoft/mule

private void assertRemainingMoney(String configName, String name, long expectedAmount) throws Exception {
 CoreEvent event = CoreEvent.builder(testEvent()).message(of("")).addVariable("myName", name).build();
 HeisenbergExtension heisenbergExtension = ExtensionsTestUtils.getConfigurationFromRegistry(configName, event, muleContext);
 assertThat(heisenbergExtension.getMoney(), equalTo(BigDecimal.valueOf(expectedAmount)));
}
origin: mulesoft/mule

 private CoreEvent createTestEvent() {
  when(mockFlowConstruct.getUniqueIdString()).thenReturn(executionId);
  return CoreEvent.builder(create(mockFlowConstruct, fromSingleComponent("http")))
    .message(Message.builder().nullValue().build())
    .build();
 }
}
origin: mulesoft/mule

@SuppressWarnings("unchecked")
@Test
public void inboundValues() throws Exception {
 Message message = event.getMessage();
 event = CoreEvent.builder(event)
   .message(InternalMessage.builder(message).addInboundProperty("foo", "abc").addInboundProperty("bar", "xyz").build())
   .build();
 Collection<DataHandler> values = (Collection<DataHandler>) evaluate("message.inboundProperties.values()", event);
 assertEquals(2, values.size());
 values.contains("abc");
 values.contains("xyz");
}
origin: mulesoft/mule

@Test
public void setsDefaultFlowVariableDataType() throws Exception {
 CoreEvent muleEvent = CoreEvent.builder(testEvent()).addVariable(TEST_PROPERTY, TEST_PAYLOAD).build();
 assertVariableDataType(muleEvent, STRING);
}
origin: mulesoft/mule

@SuppressWarnings("unchecked")
@Test
public void outboundEntrySet() throws Exception {
 event = CoreEvent.builder(event).message(InternalMessage.builder(event.getMessage()).addOutboundProperty("foo", "abc")
   .addOutboundProperty("bar", "xyz").build()).build();
 Set<Map.Entry<String, Object>> entrySet =
   (Set<Entry<String, Object>>) evaluate("message.outboundProperties.entrySet()", event);
 assertEquals(2, entrySet.size());
 entrySet.contains(new DefaultMapEntry("foo", "abc"));
 entrySet.contains(new DefaultMapEntry("bar", "xyz"));
}
origin: mulesoft/mule

@Test
public void assignValueToNewOutboundProperty() throws Exception {
 CoreEvent.Builder eventBuilder = CoreEvent.builder(event);
 evaluate("message.outboundProperties['foo']='bar'", event, eventBuilder);
 assertEquals("bar", ((InternalMessage) eventBuilder.build().getMessage()).getOutboundProperty("foo"));
}
origin: mulesoft/mule

private Processor createSetStringMessageProcessor(final String appendText) {
 return event -> {
  return CoreEvent.builder(event).message(InternalMessage.builder(event.getMessage()).value(appendText).build()).build();
 };
}
origin: mulesoft/mule

private MessagingException buildFailingFlowException(final CoreEvent event, final Exception exception) {
 return new MessagingException(CoreEvent.builder(event)
   .error(ErrorBuilder.builder(exception).errorType(ERROR_FROM_FLOW).build())
   .build(), exception);
}
origin: mulesoft/mule

@Test
public void setFlowVariableCustomDataType() throws Exception {
 DataType dataType = DataType.builder().type(String.class).mediaType(APPLICATION_XML).charset(CUSTOM_ENCODING).build();
 muleEvent = (PrivilegedEvent) CoreEvent.builder(muleEvent).addVariable(PROPERTY_NAME, PROPERTY_VALUE, dataType).build();
 DataType actualDataType = muleEvent.getVariables().get(PROPERTY_NAME).getDataType();
 assertThat(actualDataType, like(String.class, APPLICATION_XML, CUSTOM_ENCODING));
}
origin: mulesoft/mule

@Test
public void inboundSize() throws Exception {
 Message message = event.getMessage();
 mock(DataHandler.class);
 event = CoreEvent.builder(event)
   .message(InternalMessage.builder(message).addInboundProperty("foo", "abc").addInboundProperty("bar", "xyz").build())
   .build();
 assertEquals(2, evaluate("message.inboundProperties.size()", event));
}
origin: mulesoft/mule

@Test
public void inboundContainsKey() throws Exception {
 Message message = event.getMessage();
 mock(DataHandler.class);
 event =
   CoreEvent.builder(event).message(InternalMessage.builder(message).addInboundProperty("foo", "abc").build()).build();
 assertTrue((Boolean) evaluate("message.inboundProperties.containsKey('foo')", event));
 assertFalse((Boolean) evaluate("message.inboundProperties.containsKey('bar')", event));
}
origin: mulesoft/mule

@Test
public void assignValueToFlowVariable() throws Exception {
 Message message = of("");
 CoreEvent event = InternalEvent.builder(context).message(message).addVariable("foo", "bar_old").build();
 CoreEvent.Builder eventBuilder = CoreEvent.builder(event);
 evaluate("flowVars['foo']='bar'", event, eventBuilder);
 assertEquals("bar", eventBuilder.build().getVariables().get("foo").getValue());
}
origin: mulesoft/mule

private CoreEvent createStreamPayloadEventWithLength(OptionalLong length) throws MuleException {
 return builder(testEvent())
   .message(Message.builder().payload(new TypedValue(new NullInputStream(length.orElse(-1l)), INPUT_STREAM, length))
     .build())
   .build();
}
origin: mulesoft/mule

private CoreEvent createStreamPayloadEventWithLength(OptionalLong length) throws MuleException {
 return builder(testEvent())
   .message(Message.builder().payload(new TypedValue(new NullInputStream(length.orElse(-1l)), INPUT_STREAM, length))
     .build())
   .build();
}
origin: mulesoft/mule

@Test
public void outboundIsEmpty() throws Exception {
 assertTrue((Boolean) evaluate("message.outboundProperties.isEmpty()", event));
 event = CoreEvent.builder(event).message(InternalMessage.builder(event.getMessage()).addOutboundProperty("foo", "abc")
   .addOutboundProperty("bar", "xyz").build()).build();
 assertFalse((Boolean) evaluate("message.outboundProperties.isEmpty()", event));
}
org.mule.runtime.core.api.eventCoreEventbuilder

Javadoc

Create new Builder.

Popular methods of CoreEvent

  • getMessage
  • getContext
  • getError
  • 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

  • Reading from database using SQL prepared statement
  • putExtra (Intent)
  • requestLocationUpdates (LocationManager)
  • notifyDataSetChanged (ArrayAdapter)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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