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++;
}
}
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);
}
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;
}
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));
}
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();
}
}
}
Aggregations