use of org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration in project mule by mulesoft.
the class ExtensionDescriptionsEnricher method document.
/**
* Fills all the descriptions in the provided {@link ExtensionDeclaration} based on the
* <strong>extensions-descriptions.xml</strong> file.
*
* @param declaration the declaration to describe.
* @param documentation the extension documentation with its corresponding description.
*/
private void document(ExtensionDeclaration declaration, XmlExtensionDocumentation documentation) {
declaration.setDescription(documentation.getExtension().getDescription());
new DeclarationWalker() {
@Override
protected void onConfiguration(ConfigurationDeclaration declaration) {
document(declaration, documentation.getConfigs());
}
@Override
protected void onOperation(WithOperationsDeclaration owner, OperationDeclaration declaration) {
document(declaration, documentation.getOperations());
}
@Override
protected void onConnectionProvider(ConnectedDeclaration owner, ConnectionProviderDeclaration declaration) {
document(declaration, documentation.getConnections());
}
@Override
protected void onSource(WithSourcesDeclaration owner, SourceDeclaration declaration) {
document(declaration, documentation.getSources());
}
private void document(ParameterizedDeclaration<?> declaration, List<XmlExtensionElementDocumentation> elements) {
elements.stream().filter(e -> e.getName().equals(declaration.getName())).findAny().ifPresent(e -> {
declaration.setDescription(e.getDescription());
declaration.getAllParameters().forEach(param -> e.getParameters().stream().filter(p -> p.getName().equals(param.getName())).findAny().ifPresent(p -> param.setDescription(p.getDescription())));
});
}
}.walk(declaration);
}
use of org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration in project mule by mulesoft.
the class DisplayDeclarationEnricherTestCase method parseClassParameterInOperation.
@Test
public void parseClassParameterInOperation() {
ExtensionDeclaration declaration = marvelDeclarer.getDeclaration();
OperationDeclaration findInstructionsOperation = getOperation(declaration, "findInstructions");
List<ParameterDeclaration> params = findInstructionsOperation.getAllParameters();
assertThat(params, hasSize(2));
ParameterDeclaration pathParam = params.get(1);
Optional<ClassValueModel> classValueModel = pathParam.getDisplayModel().getClassValueModel();
assertThat(classValueModel.isPresent(), is(true));
assertThat(classValueModel.get().getAssignableFrom(), hasSize(1));
assertThat(classValueModel.get().getAssignableFrom().get(0), equalTo("com.starkindustries.Reader"));
}
use of org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration in project mule by mulesoft.
the class DisplayDeclarationEnricherTestCase method parsePathParameterWithFileExtensions.
@Test
public void parsePathParameterWithFileExtensions() {
ExtensionDeclaration declaration = marvelDeclarer.getDeclaration();
OperationDeclaration findInstructionsOperation = getOperation(declaration, "findInstructions");
List<ParameterDeclaration> params = findInstructionsOperation.getAllParameters();
assertThat(params, hasSize(2));
ParameterDeclaration pathParam = params.get(0);
Optional<PathModel> pathModel = pathParam.getDisplayModel().getPathModel();
assertThat(pathModel.isPresent(), is(true));
assertThat(pathModel.get().getType(), is(ANY));
assertThat(pathModel.get().acceptsUrls(), is(false));
assertThat(pathModel.get().getFileExtensions(), hasItem("xml"));
}
use of org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration in project mule by mulesoft.
the class DisplayDeclarationEnricherTestCase method parseDisplayNameAnnotationOnOperationParameter.
@Test
public void parseDisplayNameAnnotationOnOperationParameter() {
ExtensionDeclaration extensionDeclaration = heisenbergDeclarer.getDeclaration();
OperationDeclaration operation = getOperation(extensionDeclaration, HeisenbergOperations.OPERATION_WITH_DISPLAY_NAME_PARAMETER);
assertThat(operation, is(notNullValue()));
List<ParameterDeclaration> parameters = operation.getAllParameters();
assertParameterDisplayName(findParameter(parameters, OPERATION_PARAMETER_ORIGINAL_OVERRIDED_DISPLAY_NAME), OPERATION_PARAMETER_OVERRIDED_DISPLAY_NAME);
}
use of org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration in project mule by mulesoft.
the class DisplayDeclarationEnricherTestCase method parseExampleAnnotationOnOperationParameter.
@Test
public void parseExampleAnnotationOnOperationParameter() {
ExtensionDeclaration extensionDeclaration = heisenbergDeclarer.getDeclaration();
OperationDeclaration operation = getOperation(extensionDeclaration, HeisenbergOperations.OPERATION_WITH_EXAMPLE);
assertThat(operation, is(notNullValue()));
List<ParameterDeclaration> parameters = operation.getAllParameters();
assertParameterExample(findParameter(parameters, GREETING_PARAMETER), OPERATION_PARAMETER_EXAMPLE);
}
Aggregations