Search in sources :

Example 1 with HeisenbergExtension

use of org.mule.test.heisenberg.extension.HeisenbergExtension in project mule by mulesoft.

the class OperationExecutionTestCase method operationWhichReturnsListOfMessages.

@Test
public void operationWhichReturnsListOfMessages() throws Exception {
    TypedValue<List<Message>> payload = runFlow("getAllEnemies").getMessage().getPayload();
    assertThat(payload.getDataType(), is(assignableTo(MULE_MESSAGE_COLLECTION)));
    List<Message> enemies = payload.getValue();
    HeisenbergExtension heisenberg = getConfig(HEISENBERG);
    assertThat(enemies, hasSize(heisenberg.getEnemies().size()));
    int index = 0;
    for (Message enemyMessage : enemies) {
        assertEnemyMessage(heisenberg, index, enemyMessage);
        index++;
    }
}
Also used : Message(org.mule.runtime.api.message.Message) List(java.util.List) ArrayList(java.util.ArrayList) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) Test(org.junit.Test)

Example 2 with HeisenbergExtension

use of org.mule.test.heisenberg.extension.HeisenbergExtension in project mule by mulesoft.

the class DynamicConfigExpirationTestCase method expireDynamicConfig.

@Test
public void expireDynamicConfig() throws Exception {
    HeisenbergExtension config = invokeDynamicConfig("dynamic", "heisenberg", "Walt");
    assertExpired(config, 5000, 1000);
    assertInitialised(config);
}
Also used : HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) Test(org.junit.Test)

Example 3 with HeisenbergExtension

use of org.mule.test.heisenberg.extension.HeisenbergExtension in project mule by mulesoft.

the class DynamicConfigExpirationTestCase method invokeDynamicConfig.

private HeisenbergExtension invokeDynamicConfig(String flowName, String configName, String payload) throws Exception {
    FlowRunner runner = flowRunner(flowName).withPayload(payload);
    final CoreEvent event = runner.buildEvent();
    String returnedName = getPayloadAsString(runner.run().getMessage());
    HeisenbergExtension config = (HeisenbergExtension) muleContext.getExtensionManager().getConfiguration(configName, event).getValue();
    // validate we actually hit the correct dynamic config
    assertThat(returnedName, is(payload));
    assertThat(config.getPersonalInfo().getName(), is(payload));
    return config;
}
Also used : FlowRunner(org.mule.functional.api.flow.FlowRunner) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension)

Example 4 with HeisenbergExtension

use of org.mule.test.heisenberg.extension.HeisenbergExtension in project mule by mulesoft.

the class ExtensionAsInjectedDependenciesTestCase method staticHeisenbergWasInjected.

@Test
public void staticHeisenbergWasInjected() throws Exception {
    assertCorrectProviderInjected(STATIC_HEISENBERG, dependent.getStaticHeisenberg());
    HeisenbergExtension heisenberg = ExtensionsTestUtils.getConfigurationFromRegistry(STATIC_HEISENBERG, testEvent(), muleContext);
    assertThat(heisenberg.getPersonalInfo().getAge(), is(50));
}
Also used : HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) Test(org.junit.Test)

Example 5 with HeisenbergExtension

use of org.mule.test.heisenberg.extension.HeisenbergExtension in project mule by mulesoft.

the class ParameterizedConfigParserTestCase 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

HeisenbergExtension (org.mule.test.heisenberg.extension.HeisenbergExtension)28 Test (org.junit.Test)24 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)10 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)6 SmallTest (org.mule.tck.size.SmallTest)6 List (java.util.List)3 ResolverSetResult (org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSetResult)3 ArrayList (java.util.ArrayList)2 ResolverSet (org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet)2 ImmutableList (com.google.common.collect.ImmutableList)1 Arrays.asList (java.util.Arrays.asList)1 HashMap (java.util.HashMap)1 Optional.empty (java.util.Optional.empty)1 Optional.of (java.util.Optional.of)1 MINUTES (java.util.concurrent.TimeUnit.MINUTES)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 CoreMatchers.not (org.hamcrest.CoreMatchers.not)1 CoreMatchers.sameInstance (org.hamcrest.CoreMatchers.sameInstance)1 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)1 After (org.junit.After)1