use of org.mule.runtime.api.meta.model.ExtensionModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method sourceWithReducedBackPressureStrategies.
@Test
public void sourceWithReducedBackPressureStrategies() {
ExtensionModel extensionModel = createExtension(HeisenbergExtension.class);
SourceModel source = extensionModel.getConfigurationModels().get(0).getSourceModel("ListenPayments").get();
ParameterModel parameter = source.getAllParameterModels().stream().filter(p -> BACK_PRESSURE_STRATEGY_PARAMETER_NAME.equals(p.getName())).findAny().orElseThrow(() -> new IllegalStateException("No backPressureStrategy parameter"));
assertThat(parameter.getType(), is(instanceOf(StringType.class)));
assertThat(parameter.getDefaultValue(), is(FAIL));
EnumAnnotation enumAnnotation = parameter.getType().getAnnotation(EnumAnnotation.class).orElseThrow(() -> new IllegalStateException("No enum annotation"));
assertThat(asList(enumAnnotation.getValues()), containsInAnyOrder(FAIL.name(), DROP.name()));
}
use of org.mule.runtime.api.meta.model.ExtensionModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method nonBlockingExecutionType.
@Test
public void nonBlockingExecutionType() {
ExtensionModel extensionModel = createExtension(MarvelExtension.class);
OperationModel operation = extensionModel.getConfigurationModel(CONFIG_NAME).get().getOperationModel("fireMissile").get();
assertThat(operation.isBlocking(), is(false));
assertThat(operation.getExecutionType(), is(CPU_LITE));
assertThat(operation.getOutput().getType(), instanceOf(StringType.class));
assertThat(operation.getOutputAttributes().getType(), equalTo(typeLoader.load(void.class)));
}
use of org.mule.runtime.api.meta.model.ExtensionModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method customStereotype.
@Test
public void customStereotype() {
ExtensionModel extensionModel = createExtension(HeisenbergExtension.class);
OperationModel operation = extensionModel.getConfigurationModels().get(0).getOperationModel("callSaul").get();
StereotypeModel stereotypeModel = operation.getStereotype();
assertThat(stereotypeModel.isAssignableTo(PROCESSOR), is(true));
assertThat(stereotypeModel.getType(), is(new EmpireStereotype().getName().toUpperCase()));
assertThat(stereotypeModel.getNamespace(), is(HEISENBERG.toUpperCase()));
assertThat(stereotypeModel.getParent().get(), is(PROCESSOR));
}
use of org.mule.runtime.api.meta.model.ExtensionModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method blockingExecutionTypes.
@Test
public void blockingExecutionTypes() {
final List<String> nonBlockingOperations = Arrays.asList("killMany", "executeAnything", "alwaysFailsWrapper", "getChain", "exceptionOnCallbacks", "neverFailsWrapper", "payloadModifier");
ExtensionModel extensionModel = createExtension(HeisenbergExtension.class);
Reference<Boolean> cpuIntensive = new Reference<>(false);
Reference<Boolean> blocking = new Reference<>(false);
new IdempotentExtensionWalker() {
@Override
protected void onOperation(OperationModel operation) {
String operationName = operation.getName();
assertThat(operation.isBlocking(), is(!nonBlockingOperations.contains(operationName)));
if (operationName.equals("approve")) {
assertThat(operation.getExecutionType(), is(CPU_INTENSIVE));
cpuIntensive.set(true);
} else if (operation.requiresConnection()) {
assertThat(operation.getExecutionType(), is(BLOCKING));
blocking.set(true);
} else {
assertThat(operation.getExecutionType(), is(CPU_LITE));
}
}
}.walk(extensionModel);
assertThat(cpuIntensive.get(), is(true));
assertThat(blocking.get(), is(true));
}
use of org.mule.runtime.api.meta.model.ExtensionModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method exportedLibraries.
@Test
public void exportedLibraries() {
ExtensionModel extensionModel = createExtension(HeisenbergExtension.class);
assertExternalLibraries(extensionModel);
new IdempotentExtensionWalker() {
@Override
protected void onConfiguration(ConfigurationModel model) {
assertExternalLibraries(model);
}
@Override
protected void onConnectionProvider(ConnectionProviderModel model) {
assertExternalLibraries(model);
}
}.walk(extensionModel);
}
Aggregations