Search in sources :

Example 71 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class DefaultExpressionManagerTestCase method parseLogXml.

@Test
@Description("Verifies that XML content can be used for logging in DW.")
public void parseLogXml() throws MuleException {
    CoreEvent event = getEventBuilder().message(Message.builder().value("<?xml version='1.0' encoding='US-ASCII'?>\n" + "<wsc_fields>\n" + "  <operation>echo</operation>\n" + "  <body_test>test</body_test>\n" + "</wsc_fields>").mediaType(XML).build()).build();
    assertThat(expressionManager.parseLogTemplate("this is #[payload.wsc_fields.operation]", event, TEST_CONNECTOR_LOCATION, NULL_BINDING_CONTEXT), is("this is \"echo\""));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 72 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class DefaultExpressionManagerTestCase method simpleCustomVariable.

@Test
@Description("Verifies that custom variables are considered.")
public void simpleCustomVariable() {
    Object object = new Object();
    BindingContext context = builder().addBinding(MY_VAR, new TypedValue(object, OBJECT)).build();
    assertThat(expressionManager.evaluate("#[myVar]", context).getValue(), equalTo(object));
}
Also used : BindingContext(org.mule.runtime.api.el.BindingContext) TypedValue(org.mule.runtime.api.metadata.TypedValue) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 73 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class DefaultExpressionManagerTestCase method parseLogMessage.

@Test
@Description("Verifies that parsing works for log template scenarios for both DW and MVEL using the message.")
public void parseLogMessage() throws MuleException {
    String expectedOutput = "current message is \norg.mule.runtime.core.internal.message.DefaultMessageBuilder$MessageImplementation\n{" + "\n  payload=test\n  mediaType=*/*\n  attributes=<not set>\n  attributesMediaType=*/*\n}";
    assertThat(expressionManager.parseLogTemplate("current message is #[mel:message]", testEvent(), TEST_CONNECTOR_LOCATION, NULL_BINDING_CONTEXT), is(expectedOutput));
    assertThat(expressionManager.parseLogTemplate("current message is #[message]", testEvent(), TEST_CONNECTOR_LOCATION, NULL_BINDING_CONTEXT), is(expectedOutput));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 74 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class DefaultExpressionManagerTestCase method flowName.

@Test
@Description("Verifies that the flow variable exposing it's name works.")
public void flowName() throws MuleException {
    FlowConstruct mockFlowConstruct = mock(FlowConstruct.class);
    when(mockFlowConstruct.getName()).thenReturn("myFlowName");
    String result = (String) expressionManager.evaluate("#[flow.name]", testEvent(), fromSingleComponent(mockFlowConstruct.getName())).getValue();
    assertThat(result, is(mockFlowConstruct.getName()));
}
Also used : FlowConstruct(org.mule.runtime.core.api.construct.FlowConstruct) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 75 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class DefaultExpressionManagerTestCase method map.

@Test
@Description("Verifies that a map expression is successful.")
public void map() {
    String expression = "{\'name\' : \'Sarah\', \'surname\' : \'Manning\'}";
    Object result = expressionManager.evaluate(expression).getValue();
    assertThat(result, is(instanceOf(Map.class)));
    assertThat((Map<String, String>) result, hasEntry("name", "Sarah"));
    assertThat((Map<String, String>) result, hasEntry("surname", "Manning"));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Description(io.qameta.allure.Description) Test(org.junit.Test)

Aggregations

Description (io.qameta.allure.Description)117 Test (org.junit.Test)111 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)41 Matchers.containsString (org.hamcrest.Matchers.containsString)15 Message (org.mule.runtime.api.message.Message)13 TypedValue (org.mule.runtime.api.metadata.TypedValue)13 RoutingPair (org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair)12 MessageProcessorChain (org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain)12 OperationParameters (org.mule.runtime.extension.api.client.OperationParameters)12 Matchers.anyString (org.mockito.Matchers.anyString)8 List (java.util.List)7 MavenConfiguration (org.mule.maven.client.api.model.MavenConfiguration)7 Processor (org.mule.runtime.core.api.processor.Processor)7 RemoteRepository (org.mule.maven.client.api.model.RemoteRepository)6 Event (org.mule.runtime.api.event.Event)6 ReactiveProcessor (org.mule.runtime.core.api.processor.ReactiveProcessor)6 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)6 InternalProcessor (org.mule.runtime.core.privileged.processor.InternalProcessor)6 SmallTest (org.mule.tck.size.SmallTest)6 TestTransaction (org.mule.tck.testmodels.mule.TestTransaction)6