use of org.mule.runtime.extension.api.runtime.parameter.ParameterResolver in project mule by mulesoft.
the class StackableTypesTestCase method parameterResolverOfTypedValueOnOperation.
@Test
public void parameterResolverOfTypedValueOnOperation() throws Exception {
ParameterResolver<TypedValue<InputStream>> lazyValue = (ParameterResolver<TypedValue<InputStream>>) flowRunner("parameterResolverOfTypedValueOnOperation").run().getMessage().getPayload().getValue();
TypedValue<InputStream> resolve = lazyValue.resolve();
InputStream jsonValue = resolve.getValue();
Optional<String> expression = lazyValue.getExpression();
String stringValue = IOUtils.toString(jsonValue);
assertThat(expression, is(not(empty())));
assertThat(expression.get(), is("#[output application/json --- {key : 'a nice looking json'}]"));
assertThat(stringValue, is("{\n \"key\": \"a nice looking json\"\n}"));
}
use of org.mule.runtime.extension.api.runtime.parameter.ParameterResolver in project mule by mulesoft.
the class ParameterResolverOperationExecutionTestCase method assertExpressionResolverWeapon.
private void assertExpressionResolverWeapon(String flowName, String expression, Matcher weaponMatcher) throws Exception {
ParameterResolver weaponInfo = (ParameterResolver) flowRunner(flowName).run().getMessage().getPayload().getValue();
assertThat(weaponInfo.getExpression(), is(ofNullable(expression)));
assertThat(weaponInfo.resolve(), weaponMatcher);
}
use of org.mule.runtime.extension.api.runtime.parameter.ParameterResolver in project mule by mulesoft.
the class StackableTypesTestCase method configurationWithDynamicParameterResolvers.
@Test
public void configurationWithDynamicParameterResolvers() throws Exception {
NestedWrapperTypesConfig config = getPayload("configurationWithDynamicParameterResolvers");
ParameterResolver<TypedValue<KnockeableDoor>> doorResolver = config.getDoorResolver();
TypedValue<KnockeableDoor> doorTypedValue = doorResolver.resolve();
KnockeableDoor door = doorTypedValue.getValue();
assertThat(door.getVictim(), is("Victim's Name"));
ParameterResolver<TypedValue<InputStream>> lazyParameter = config.getLazyParameter();
Optional<String> expression = lazyParameter.getExpression();
TypedValue<InputStream> resolve = lazyParameter.resolve();
InputStream value = resolve.getValue();
String stringValue = IOUtils.toString(value);
assertThat(expression, is(not(empty())));
assertThat(expression.get(), is("#[output application/json --- {key : 'a nice looking json'}]"));
assertThat(stringValue, is("{\n \"key\": \"a nice looking json\"\n}"));
ParameterResolver<ParameterResolver<ParameterResolver<ParameterResolver<TypedValue<InputStream>>>>> nestedParameter = config.getNestedParameter();
TypedValue<InputStream> nestedTypedValue = nestedParameter.resolve().resolve().resolve().resolve();
InputStream nestedValue = nestedTypedValue.getValue();
String nestedString = IOUtils.toString(nestedValue);
assertThat(nestedString, is("{\n \"key\": \"pretty nested\"\n}"));
ParameterResolver<Literal<String>> resolverOfLiteral = config.getResolverOfLiteral();
Literal<String> stringLiteral = resolverOfLiteral.resolve();
Optional<String> literalValue = stringLiteral.getLiteralValue();
assertThat(literalValue, is(not(empty())));
assertThat(literalValue.get(), is("#['this doesn't make sense']"));
}
Aggregations