use of org.mule.test.heisenberg.extension.HeisenbergExtension 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();
}
}
}
use of org.mule.test.heisenberg.extension.HeisenbergExtension 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();
}
}
}
use of org.mule.test.heisenberg.extension.HeisenbergExtension in project mule by mulesoft.
the class SubTypesMappingParserTestCase method subtypeContributionToOtherExtension.
@Test
public void subtypeContributionToOtherExtension() throws Exception {
HeisenbergExtension heisenberg = lookupHeisenberg("heisenberg");
assertThat(heisenberg, is(notNullValue()));
List<? extends Weapon> wildCardWeapons = heisenberg.getWildCardWeapons();
assertThat(wildCardWeapons, is(notNullValue()));
assertThat(wildCardWeapons, hasSize(2));
assertThat(wildCardWeapons.get(0), instanceOf(Ricin.class));
assertThat(((Ricin) wildCardWeapons.get(0)).getMicrogramsPerKilo(), is(10L));
assertThat(((Ricin) wildCardWeapons.get(0)).getDestination(), is(notNullValue()));
assertThat(((Ricin) wildCardWeapons.get(0)).getDestination().getVictim(), is("Krazy-8"));
assertThat(wildCardWeapons.get(1), instanceOf(Revolver.class));
assertThat(((Revolver) wildCardWeapons.get(1)).getBullets(), is(3));
}
use of org.mule.test.heisenberg.extension.HeisenbergExtension in project mule by mulesoft.
the class DynamicConfigurationProviderTestCase method resolveProviderParamsDifferentInstance.
@Test
public void resolveProviderParamsDifferentInstance() throws Exception {
HeisenbergExtension config = (HeisenbergExtension) provider.get(event).getValue();
mockConfigurationInstance(configurationModel, MODULE_CLASS.newInstance());
ResolverSet providerResolverSet = mock(ResolverSet.class);
when(connectionProviderResolver.getResolverSet()).thenReturn(of(providerResolverSet));
when(connectionProviderResolver.getObjectBuilder()).thenReturn(empty());
when(providerResolverSet.resolve(from(event))).thenReturn(mock(ResolverSetResult.class));
assertThat(provider.get(event).getValue(), is(not(sameInstance(config))));
verify(resolverSet, times(2)).resolve(from(event));
verify(providerResolverSet, times(1)).resolve(from(event));
verify(connectionProviderResolver, times(2)).resolve(from(event));
}
use of org.mule.test.heisenberg.extension.HeisenbergExtension in project mule by mulesoft.
the class DynamicConfigurationProviderTestCase method resolveCached.
@Test
public void resolveCached() throws Exception {
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(resolverSet, times(count)).resolve(from(event));
}
Aggregations