Search in sources :

Example 31 with ExtensionDeclaration

use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration 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"));
}
Also used : ClassValueModel(org.mule.runtime.api.meta.model.display.ClassValueModel) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) OperationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) Test(org.junit.Test)

Example 32 with ExtensionDeclaration

use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration 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"));
}
Also used : PathModel(org.mule.runtime.api.meta.model.display.PathModel) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) OperationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) Test(org.junit.Test)

Example 33 with ExtensionDeclaration

use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration 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);
}
Also used : ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) OperationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) Test(org.junit.Test)

Example 34 with ExtensionDeclaration

use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration 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);
}
Also used : ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) OperationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) Test(org.junit.Test)

Example 35 with ExtensionDeclaration

use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration in project mule by mulesoft.

the class DisplayDeclarationEnricherTestCase method parseDisplayAnnotationsOnParameter.

@Test
public void parseDisplayAnnotationsOnParameter() {
    ExtensionDeclaration extensionDeclaration = heisenbergDeclarer.getDeclaration();
    List<ParameterDeclaration> parameters = extensionDeclaration.getConfigurations().get(0).getAllParameters();
    assertParameterDisplayName(findParameter(parameters, PARAMETER_ORIGINAL_OVERRIDED_DISPLAY_NAME), PARAMETER_OVERRIDED_DISPLAY_NAME);
}
Also used : ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) Test(org.junit.Test)

Aggregations

ExtensionDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration)36 Test (org.junit.Test)24 ExtensionDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer)14 ParameterDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration)14 OperationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration)12 SmallTest (org.mule.tck.size.SmallTest)12 ConfigurationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration)9 SourceDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.SourceDeclaration)6 IdempotentDeclarationWalker (org.mule.runtime.extension.api.declaration.fluent.util.IdempotentDeclarationWalker)6 Type (org.mule.runtime.module.extension.api.loader.java.type.Type)5 ExtensionTypeDescriptorModelProperty (org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty)5 List (java.util.List)3 Optional (java.util.Optional)3 ClassTypeLoader (org.mule.metadata.api.ClassTypeLoader)3 ObjectType (org.mule.metadata.api.model.ObjectType)3 WithOperationsDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.WithOperationsDeclaration)3 IllegalModelDefinitionException (org.mule.runtime.extension.api.exception.IllegalModelDefinitionException)3 DeclarationEnricher (org.mule.runtime.extension.api.loader.DeclarationEnricher)3 String.format (java.lang.String.format)2 Optional.ofNullable (java.util.Optional.ofNullable)2