use of org.mule.runtime.api.metadata.FunctionDataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method buildFunction.
@Test
public void buildFunction() {
FunctionDataType dataType = (FunctionDataType) DataType.fromFunction(new SomeFunction());
// Return type
assertThat(dataType.getReturnType().isPresent(), is(true));
assertThat(dataType.getReturnType().get(), equalTo(STRING));
// Parameters
assertThat(dataType.getParameters(), hasSize(2));
FunctionParameter first = dataType.getParameters().get(0);
assertThat(first.getName(), is("fst"));
assertThat(first.getType(), equalTo(NUMBER));
assertThat(first.getDefaultValueResolver(), nullValue());
FunctionParameter second = dataType.getParameters().get(1);
assertThat(second.getName(), is("snd"));
assertThat(second.getType(), equalTo(OBJECT));
// Default
assertThat(second.getDefaultValueResolver().getDefaultValue(builder().build()), is("wow"));
}
Aggregations