Search in sources :

Example 16 with BaseEventContext

use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.

the class ParameterizedConfigParserTestCase method configWithExpressionFunctionIsSameInstanceForDifferentEvents.

@Test
public void configWithExpressionFunctionIsSameInstanceForDifferentEvents() throws Exception {
    CoreEvent event = null;
    try {
        event = getHeisenbergEvent();
        CoreEvent anotherEvent = testEvent();
        HeisenbergExtension config = lookupHeisenberg(HEISENBERG_BYNAME, event);
        HeisenbergExtension anotherConfig = lookupHeisenberg(HEISENBERG_BYNAME, anotherEvent);
        assertThat(config, is(sameInstance(anotherConfig)));
    } finally {
        if (event != null) {
            ((BaseEventContext) event.getContext()).success();
        }
    }
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) Test(org.junit.Test)

Example 17 with BaseEventContext

use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.

the class ParameterizedConfigParserTestCase method sameInstanceForEquivalentEvent.

@Test
public void sameInstanceForEquivalentEvent() throws Exception {
    CoreEvent event = null;
    try {
        event = getHeisenbergEvent();
        HeisenbergExtension heisenberg = lookupHeisenberg(testConfig, event);
        assertThat(heisenberg, is(sameInstance(lookupHeisenberg(testConfig, event))));
    } finally {
        if (event != null) {
            ((BaseEventContext) event.getContext()).success();
        }
    }
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) Test(org.junit.Test)

Example 18 with BaseEventContext

use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.

the class SingleConfigParserTestCase method getHealthProgression.

@Test
public void getHealthProgression() throws Exception {
    CoreEvent event = null;
    try {
        event = getHeisenbergEvent();
        HeisenbergExtension config = lookupHeisenberg(HEISENBERG_BYNAME, event);
        assertThat(config.getHealthProgression(), is(not(nullValue())));
        assertThat(config.getHealthProgression().size(), is(3));
        assertThat(config.getHealthProgression(), contains(HEALTHY, CANCER, DEAD));
    } finally {
        if (event != null) {
            ((BaseEventContext) event.getContext()).success();
        }
    }
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) Test(org.junit.Test)

Example 19 with BaseEventContext

use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.

the class SingleConfigParserTestCase method initializedOptionalValueWithoutDefaultValue.

@Test
public void initializedOptionalValueWithoutDefaultValue() throws Exception {
    CoreEvent event = null;
    try {
        event = getHeisenbergEvent();
        HeisenbergExtension config = lookupHeisenberg(HEISENBERG_EXPRESSION_BYREF, event);
        assertThat(config.getWeapon(), is(not(nullValue())));
        assertThat(config.getWeapon(), is(instanceOf(Ricin.class)));
    } finally {
        if (event != null) {
            ((BaseEventContext) event.getContext()).success();
        }
    }
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) Test(org.junit.Test)

Example 20 with BaseEventContext

use of org.mule.runtime.core.privileged.event.BaseEventContext in project mule by mulesoft.

the class SingleConfigParserTestCase method configWithExpressionFunctionStillDynamic.

@Test
public void configWithExpressionFunctionStillDynamic() throws Exception {
    CoreEvent event = null;
    CoreEvent anotherEvent = null;
    try {
        event = getHeisenbergEvent();
        anotherEvent = CoreEvent.builder(getHeisenbergEvent()).addVariable("age", 40).build();
        HeisenbergExtension config = lookupHeisenberg(HEISENBERG_EXPRESSION, event);
        HeisenbergExtension anotherConfig = lookupHeisenberg(HEISENBERG_EXPRESSION, anotherEvent);
        assertThat(config, is(not(sameInstance(anotherConfig))));
    } finally {
        if (event != null) {
            ((BaseEventContext) event.getContext()).success();
        }
        if (anotherEvent != null) {
            ((BaseEventContext) anotherEvent.getContext()).success();
        }
    }
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) Test(org.junit.Test)

Aggregations

BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)45 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)34 Test (org.junit.Test)24 MuleException (org.mule.runtime.api.exception.MuleException)10 Message (org.mule.runtime.api.message.Message)10 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)8 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)7 Description (io.qameta.allure.Description)6 Optional.of (java.util.Optional.of)6 HeisenbergExtension (org.mule.test.heisenberg.extension.HeisenbergExtension)6 Optional (java.util.Optional)5 CompletableFuture (java.util.concurrent.CompletableFuture)5 EventContext (org.mule.runtime.api.event.EventContext)5 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)5 Publisher (org.reactivestreams.Publisher)5 Mono.from (reactor.core.publisher.Mono.from)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 Processor (org.mule.runtime.core.api.processor.Processor)4 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)4 String.format (java.lang.String.format)3