use of org.mule.runtime.api.meta.model.operation.OperationModel 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.operation.OperationModel 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.operation.OperationModel 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.operation.OperationModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method assertSinglePrimaryContentParameter.
private void assertSinglePrimaryContentParameter(ExtensionModel extensionModel, String operationName, String defaultValue) {
OperationModel appleOperation = aggressiveGet(extensionModel.getOperationModel(operationName));
List<ParameterModel> contentParameters = appleOperation.getAllParameterModels().stream().filter(ExtensionModelUtils::isContent).collect(toList());
assertThat(contentParameters, hasSize(1));
ParameterModel contentParameter = contentParameters.get(0);
assertThat(contentParameter.isRequired(), is(false));
assertThat(contentParameter.getDefaultValue(), is(defaultValue));
assertThat(contentParameter.getRole(), is(PRIMARY_CONTENT));
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method validatorStereotype.
@Test
public void validatorStereotype() {
ExtensionModel extensionModel = createExtension(HeisenbergExtension.class);
OperationModel operation = extensionModel.getOperationModel("validateMoney").get();
StereotypeModel stereotypeModel = operation.getStereotype();
assertThat(stereotypeModel.isAssignableTo(PROCESSOR), is(true));
assertThat(stereotypeModel.isAssignableTo(VALIDATOR), is(true));
assertThat(stereotypeModel.getType(), is(VALIDATOR_DEFINITION.getName()));
assertThat(stereotypeModel.getNamespace(), is(HEISENBERG.toUpperCase()));
assertThat(stereotypeModel.getParent().get(), is(VALIDATOR));
}
Aggregations