use of org.mule.runtime.api.meta.model.ExtensionModel in project mule by mulesoft.
the class ExtensionActivator method registerEnumTransformers.
private void registerEnumTransformers(ExtensionModel extensionModel) {
ClassLoader classLoader = getClassLoader(extensionModel);
Set<Class<?>> parameterClasses = new HashSet<>();
parameterClasses.addAll(getParameterClasses(extensionModel, classLoader));
parameterClasses.addAll(getSubtypeClasses(extensionModel, classLoader));
parameterClasses.stream().filter(type -> Enum.class.isAssignableFrom(type)).forEach(type -> {
final Class<Enum> enumClass = (Class<Enum>) type;
if (enumTypes.add(enumClass)) {
try {
StringToEnum stringToEnum = new StringToEnum(enumClass);
registerObject(muleContext, getName(stringToEnum), stringToEnum, Transformer.class);
} catch (MuleException e) {
throw new MuleRuntimeException(createStaticMessage("Could not register transformer for enum " + enumClass.getName()), e);
}
}
});
}
use of org.mule.runtime.api.meta.model.ExtensionModel in project mule by mulesoft.
the class CoreExtensionModelSerializationTestCase method serializeDeserialize.
@Test
public void serializeDeserialize() throws Exception {
ExtensionModel extensionModel = MuleExtensionModelProvider.getExtensionModel();
ExtensionModelJsonSerializer jsonSerializer = new ExtensionModelJsonSerializer(true);
String serialized = jsonSerializer.serialize(extensionModel);
ExtensionModel deserialized = jsonSerializer.deserialize(serialized);
assertThat(extensionModel, equalTo(deserialized));
}
use of org.mule.runtime.api.meta.model.ExtensionModel in project mule by mulesoft.
the class ErrorsDeclarationEnricherTestCase method operationInheritsExtensionErrorThrows.
@Test
public void operationInheritsExtensionErrorThrows() {
extensionModel = loadExtension(HeisenbergWithExtensionThrows.class);
OperationModel someOperation = extensionModel.getOperationModel("someOperation").get();
Optional<ErrorModel> operationError = someOperation.getErrorModels().stream().filter(errorModel -> errorModel.getType().equals(EXTENSION.getType())).findFirst();
assertThat(operationError.isPresent(), is(true));
}
use of org.mule.runtime.api.meta.model.ExtensionModel in project mule by mulesoft.
the class ParameterLayoutOrderDeclarationEnricherTestCase method parameters.
@Parameterized.Parameters(name = "{1}")
public static List<Object[]> parameters() {
ExtensionModel extensionModel = loadExtension(OrderedExtension.class);
List<Object[]> objects = new ArrayList<>();
objects.add(new Object[] { extensionModel.getOperationModel("implicitOrder").get(), "Operation - Implicit Order" });
objects.add(new Object[] { extensionModel.getOperationModel("explicitOrder").get(), "Operation - Explicit Order" });
objects.add(new Object[] { extensionModel.getOperationModel("mixedOrder").get(), "Operation - Mixed Order" });
objects.add(new Object[] { extensionModel.getConfigurationModel("ImplicitOrderConfig").get(), "Config - Implicit Order" });
objects.add(new Object[] { extensionModel.getConfigurationModel("ExplicitOrderConfig").get(), "Config - Explicit Order" });
objects.add(new Object[] { extensionModel.getConfigurationModel("MixedOrderConfig").get(), "Config - Mixed Order" });
objects.add(new Object[] { extensionModel.getConfigurationModel("InheritsOrderConfig").get(), "Config - Inherited Order" });
objects.add(new Object[] { extensionModel.getConnectionProviderModel("implicit").get(), "Conn Provider - Implicit Order" });
objects.add(new Object[] { extensionModel.getConnectionProviderModel("explicit").get(), "Conn Provider - Explicit Order" });
objects.add(new Object[] { extensionModel.getConnectionProviderModel("mixed").get(), "Conn Provider - Mixed Order" });
objects.add(new Object[] { extensionModel.getSourceModel("ImplicitSourceOrder").get(), "Source - Implicit Order" });
objects.add(new Object[] { extensionModel.getSourceModel("ExplicitSourceOrder").get(), "Source - Explicit Order" });
objects.add(new Object[] { extensionModel.getSourceModel("MixedSourceOrder").get(), "Source - Mixed Order" });
objects.add(new Object[] { extensionModel.getSourceModel("ExplicitSourceOrderWithCallbacks").get(), "Source - With Callbacks Explicit Order" });
objects.add(new Object[] { extensionModel.getSourceModel("MixedSourceOrderWithCallbacks").get(), "Source - With Callbacks Mixed Order" });
return objects;
}
Aggregations