Search in sources :

Example 16 with HeisenbergExtension

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

the class DynamicConfigurationProviderTestCase method resolveCachedWithProviderParams.

@Test
public void resolveCachedWithProviderParams() throws Exception {
    ResolverSet providerResolverSet = mock(ResolverSet.class);
    when(connectionProviderResolver.getResolverSet()).thenReturn(of(providerResolverSet));
    when(connectionProviderResolver.getObjectBuilder()).thenReturn(empty());
    when(providerResolverSet.resolve(from(event))).thenReturn(resolverSetResult);
    final int count = 10;
    HeisenbergExtension config = (HeisenbergExtension) provider.get(event).getValue();
    for (int i = 1; i < count; i++) {
        assertThat(provider.get(event).getValue(), is(sameInstance(config)));
    }
    verify(providerResolverSet, times(count)).resolve(from(event));
    verify(resolverSet, times(count)).resolve(from(event));
}
Also used : ResolverSet(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 17 with HeisenbergExtension

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

the class DynamicConfigurationProviderTestCase method resolveDifferentInstances.

@Test
public void resolveDifferentInstances() throws Exception {
    HeisenbergExtension instance1 = (HeisenbergExtension) provider.get(event).getValue();
    HeisenbergExtension instance2 = makeAlternateInstance();
    assertThat(instance2, is(not(sameInstance(instance1))));
}
Also used : HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 18 with HeisenbergExtension

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

the class OperationExecutionTestCase method randomAccessOnOperationWhichReturnsListOfMessages.

@Test
public void randomAccessOnOperationWhichReturnsListOfMessages() throws Exception {
    List<Message> enemies = (List<Message>) runFlow("getAllEnemies").getMessage().getPayload().getValue();
    HeisenbergExtension heisenberg = getConfig(HEISENBERG);
    assertThat(enemies, hasSize(heisenberg.getEnemies().size()));
    int index = enemies.size() - 1;
    assertEnemyMessage(heisenberg, index, enemies.get(index));
    index = 0;
    assertEnemyMessage(heisenberg, index, enemies.get(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 19 with HeisenbergExtension

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

the class DynamicConfigExpirationTestCase method expireDynamicConfigWithCustomExpiration.

@Test
public void expireDynamicConfigWithCustomExpiration() throws Exception {
    HeisenbergExtension config = invokeDynamicConfig("dynamicWithCustomExpiration", "heisenbergWithCustomExpiration", "Walter Jr.");
    try {
        assertExpired(config, 1500, 100);
        fail("Config should not have been expired");
    } catch (AssertionError e) {
    // all good
    }
    assertExpired(config, 5000, 1000);
    assertInitialised(config);
}
Also used : HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) Test(org.junit.Test)

Example 20 with HeisenbergExtension

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

the class ExtensionAsInjectedDependenciesTestCase method dynamicHeisenbergWasInjected.

@Test
public void dynamicHeisenbergWasInjected() throws Exception {
    assertCorrectProviderInjected(DYNAMIC_AGE_HEISENBERG, dependent.getDynamicAgeHeisenberg());
    final int age = 52;
    CoreEvent event = CoreEvent.builder(testEvent()).message(of("")).addVariable("age", age).build();
    HeisenbergExtension heisenberg = ExtensionsTestUtils.getConfigurationFromRegistry(DYNAMIC_AGE_HEISENBERG, event, muleContext);
    assertThat(heisenberg.getPersonalInfo().getAge(), is(age));
}
Also used : 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