Search in sources :

Example 86 with TypedValue

use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.

the class TypedValueParameterOperationExecutionTestCase method typedValueForObject.

@Test
public void typedValueForObject() throws Exception {
    CoreEvent event = flowRunner("typedValueForObject").keepStreamsOpen().run();
    TypedValue jsonObject = (TypedValue) event.getMessage().getPayload().getValue();
    InputStream content = (InputStream) jsonObject.getValue();
    assertThat(IOUtils.toString(content), is(JSON_OBJECT));
    assertThat(jsonObject.getDataType(), is(like(jsonObject.getDataType().getType(), APPLICATION_JSON, UTF8)));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) InputStream(java.io.InputStream) TypedValue(org.mule.runtime.api.metadata.TypedValue) Test(org.junit.Test)

Example 87 with TypedValue

use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.

the class TypedValueParameterOperationExecutionTestCase method typedValueForInputStream.

@Test
public void typedValueForInputStream() throws Exception {
    CoreEvent event = flowRunner("typedValueForInputStream").run();
    TypedValue jsonObject = (TypedValue) event.getMessage().getPayload().getValue();
    assertThat(IOUtils.toString((InputStream) jsonObject.getValue()), is(JSON_OBJECT));
    assertThat(jsonObject.getDataType(), is(like(jsonObject.getDataType().getType(), APPLICATION_JSON, UTF8)));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) InputStream(java.io.InputStream) TypedValue(org.mule.runtime.api.metadata.TypedValue) Test(org.junit.Test)

Example 88 with TypedValue

use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.

the class AbstractAddVariablePropertyProcessorTestCase method setUpTest.

@Before
public void setUpTest() throws Exception {
    when(mockMuleContext.getExpressionManager()).thenReturn(mockExpressionManager);
    when(mockMuleContext.getConfiguration()).thenReturn(mock(MuleConfiguration.class));
    typedValue = new TypedValue(EXPRESSION_VALUE, STRING);
    when(mockExpressionManager.evaluate(eq(EXPRESSION), eq(STRING), any(), any(CoreEvent.class))).thenReturn(typedValue);
    when(mockExpressionManager.evaluate(eq(EXPRESSION), any(CoreEvent.class))).thenReturn(typedValue);
    addVariableProcessor.setMuleContext(mockMuleContext);
    message = of("");
    event = createTestEvent(message);
}
Also used : MuleConfiguration(org.mule.runtime.core.api.config.MuleConfiguration) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) TypedValue(org.mule.runtime.api.metadata.TypedValue) Before(org.junit.Before)

Example 89 with TypedValue

use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.

the class AbstractAddVariablePropertyProcessorTestCase method testAddVariableWithNullPayloadExpressionValueResult.

@Test
public void testAddVariableWithNullPayloadExpressionValueResult() throws MuleException {
    addVariableProcessor.setIdentifier(PLAIN_STRING_KEY);
    addVariableProcessor.setValue(EXPRESSION);
    TypedValue typedValue = new TypedValue(null, DataType.OBJECT);
    when(mockExpressionManager.evaluate(EXPRESSION, event)).thenReturn(typedValue);
    addVariableProcessor.initialise();
    event = addVariableProcessor.process(event);
    verifyRemoved(event, PLAIN_STRING_KEY);
}
Also used : TypedValue(org.mule.runtime.api.metadata.TypedValue) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 90 with TypedValue

use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.

the class AbstractAddVariablePropertyProcessorTestCase method testAddVariableWithNullExpressionKeyResult.

@Test
public void testAddVariableWithNullExpressionKeyResult() throws MuleException {
    TypedValue typedValue = new TypedValue(null, OBJECT);
    when(mockExpressionManager.evaluate(eq(NULL_EXPRESSION), eq(DataType.STRING), any(), eq(event))).thenReturn(typedValue);
    addVariableProcessor.setIdentifier(NULL_EXPRESSION);
    addVariableProcessor.setValue(PLAIN_STRING_VALUE);
    addVariableProcessor.initialise();
    event = addVariableProcessor.process(event);
    verifyNotAdded(event);
}
Also used : TypedValue(org.mule.runtime.api.metadata.TypedValue) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

TypedValue (org.mule.runtime.api.metadata.TypedValue)97 Test (org.junit.Test)74 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)47 DataType (org.mule.runtime.api.metadata.DataType)17 Message (org.mule.runtime.api.message.Message)16 Description (io.qameta.allure.Description)13 Matchers.containsString (org.hamcrest.Matchers.containsString)13 List (java.util.List)11 SmallTest (org.mule.tck.size.SmallTest)10 BindingContext (org.mule.runtime.api.el.BindingContext)9 Map (java.util.Map)8 Optional (java.util.Optional)8 InputStream (java.io.InputStream)6 HashMap (java.util.HashMap)6 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)5 ArrayList (java.util.ArrayList)4 Matchers.anyString (org.mockito.Matchers.anyString)4 MuleException (org.mule.runtime.api.exception.MuleException)4 Error (org.mule.runtime.api.message.Error)4 ErrorType (org.mule.runtime.api.message.ErrorType)4