use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class ComplexExtensionDeclarationTestCase method staticResourceOperation.
@Test
public void staticResourceOperation() {
OperationModel operation = extensionModel.getOperationModel(STATIC_RESOURCE_OPERATION_NAME).get();
assertThat(operation.getName(), is(STATIC_RESOURCE_OPERATION_NAME));
assertType(operation.getOutput().getType(), InputStream.class, BinaryType.class);
final List<ParameterModel> parameters = operation.getAllParameterModels();
assertThat(parameters, hasSize(4));
assertStreamingStrategyParameter(parameters.get(0));
ParameterModel parameter = parameters.get(1);
assertThat(parameter.getName(), is(PATH));
assertType(parameter.getType(), String.class, StringType.class);
assertTargetParameter(parameters.get(2), parameters.get(3));
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class ComplexExtensionDeclarationTestCase method requestOperation.
@Test
public void requestOperation() {
OperationModel operation = extensionModel.getConfigurationModel(REQUESTER_CONFIG_NAME).get().getOperationModel(REQUEST_OPERATION_NAME).get();
assertThat(operation.getName(), is(REQUEST_OPERATION_NAME));
assertType(operation.getOutput().getType(), InputStream.class, BinaryType.class);
List<ParameterModel> parameterModels = operation.getAllParameterModels();
assertThat(parameterModels, hasSize(4));
ParameterModel parameter = parameterModels.get(0);
assertStreamingStrategyParameter(parameter);
parameter = parameterModels.get(1);
assertThat(parameter.getName(), is(PATH));
assertType(parameter.getType(), String.class, StringType.class);
assertTargetParameter(parameterModels.get(2), parameterModels.get(3));
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method flyweight.
@Test
public void flyweight() {
ExtensionModel extensionModel = createExtension(VeganExtension.class);
final ConfigurationModel appleConfiguration = aggressiveGet(extensionModel.getConfigurationModel(APPLE));
final ConfigurationModel bananaConfiguration = aggressiveGet(extensionModel.getConfigurationModel(BANANA));
final String sourceName = PaulMcCartneySource.class.getSimpleName();
SourceModel appleSource = aggressiveGet(appleConfiguration.getSourceModel(sourceName));
SourceModel bananaSource = aggressiveGet(bananaConfiguration.getSourceModel(sourceName));
assertThat(appleSource, is(sameInstance(appleSource)));
assertThat(bananaSource, is(sameInstance(bananaSource)));
final String operationName = "spreadTheWord";
OperationModel appleOperation = aggressiveGet(appleConfiguration.getOperationModel(operationName));
OperationModel bananaOperation = aggressiveGet(bananaConfiguration.getOperationModel(operationName));
assertThat(appleOperation, is(sameInstance(bananaOperation)));
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method streamingHintOnOperation.
@Test
public void streamingHintOnOperation() throws Exception {
ExtensionModel extensionModel = createExtension(HeisenbergExtension.class);
OperationModel operationModel = extensionModel.getConfigurationModels().get(0).getOperationModel("sayMyName").get();
ParameterModel streamingParameter = operationModel.getAllParameterModels().stream().filter(p -> p.getName().equals(STREAMING_STRATEGY_PARAMETER_NAME)).findFirst().get();
assertStreamingStrategy(streamingParameter);
}
use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.
the class ExportedArtifactsCollectorTestCase method setup.
@Before
public void setup() {
ClassLoaderModelProperty classLoaderModelProperty = new ClassLoaderModelProperty(getClass().getClassLoader());
when(extensionModel.getModelProperty(ClassLoaderModelProperty.class)).thenReturn(of(classLoaderModelProperty));
OutputModel appleList = mockOutputModel(new TypeToken<List<Apple>>() {
}.getType());
OperationModel firstOperation = mockOperationModel(appleList, mockOutputModel(List.class));
withMethod(firstOperation, getApiMethods(HeisenbergOperations.class).stream().filter(m -> m.getName().equals("callGusFring")).findFirst());
ParameterModel parameter = mockParameterModel(Shape.class);
OutputModel resultList = mockOutputModel(new TypeToken<List<Result<Apple, VeganAttributes>>>() {
}.getType());
OperationModel secondOperation = mockOperationModel(resultList, mockOutputModel(List.class), parameter);
withMethod(secondOperation, empty());
when(extensionModel.getOperationModels()).thenReturn(asList(firstOperation, secondOperation));
visitableMock(firstOperation, secondOperation);
collector = new ExportedArtifactsCollector(extensionModel);
}
Aggregations