use of org.mule.runtime.extension.api.runtime.parameter.Literal in project mule by mulesoft.
the class StackableTypesTestCase method configurationWithStaticParameterResolvers.
@Test
public void configurationWithStaticParameterResolvers() throws Exception {
NestedWrapperTypesConfig config = getPayload("configurationWithStaticParameterResolvers");
ParameterResolver<TypedValue<KnockeableDoor>> doorResolver = config.getDoorResolver();
TypedValue<KnockeableDoor> doorTypedValue = doorResolver.resolve();
KnockeableDoor door = doorTypedValue.getValue();
assertThat(door.getVictim(), is("Victim's Name"));
ParameterResolver<TypedValue<String>> lazyParameter = config.getLazyString();
Optional<String> expression = lazyParameter.getExpression();
TypedValue<String> resolve = lazyParameter.resolve();
assertThat(expression, is(empty()));
assertThat(resolve.getValue(), is("a nice looking string"));
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"));
}
use of org.mule.runtime.extension.api.runtime.parameter.Literal 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