Search in sources :

Example 1 with ClassValueModel

use of org.mule.runtime.api.meta.model.display.ClassValueModel in project mule by mulesoft.

the class DisplayDeclarationEnricherTestCase method parseClassParameter.

@Test
public void parseClassParameter() {
    ExtensionDeclaration declaration = marvelDeclarer.getDeclaration();
    ConfigurationDeclaration config = findConfigByName(declaration, IronMan.CONFIG_NAME);
    List<ParameterDeclaration> params = config.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.AIEngine"));
}
Also used : ConfigurationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration) ClassValueModel(org.mule.runtime.api.meta.model.display.ClassValueModel) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) Test(org.junit.Test)

Example 2 with ClassValueModel

use of org.mule.runtime.api.meta.model.display.ClassValueModel in project mule by mulesoft.

the class DisplayDeclarationEnricher method createDisplayModelProperty.

private void createDisplayModelProperty(BaseDeclaration declaration, Summary summaryAnnotation, DisplayName displayNameAnnotation, Example exampleAnnotation, Path pathAnnotation, ClassValue classValue) {
    String summary = summaryAnnotation != null ? summaryAnnotation.value() : null;
    String displayName = displayNameAnnotation != null ? displayNameAnnotation.value() : null;
    String example = exampleAnnotation != null ? exampleAnnotation.value() : null;
    PathModel pathModel = null;
    ClassValueModel classValueModel = null;
    if (pathAnnotation != null) {
        pathModel = new PathModel(pathAnnotation.type(), pathAnnotation.acceptsUrls(), pathAnnotation.location(), pathAnnotation.acceptedFileExtensions());
    }
    if (classValue != null) {
        classValueModel = toClassValueModel(classValue);
    }
    if (summary != null || displayName != null || example != null || pathModel != null || classValueModel != null) {
        declaration.setDisplayModel(DisplayModel.builder().displayName(displayName).summary(summary).example(example).path(pathModel).classValue(classValueModel).build());
    }
}
Also used : PathModel(org.mule.runtime.api.meta.model.display.PathModel) ClassValueModel(org.mule.runtime.api.meta.model.display.ClassValueModel) ExtensionModelUtils.toClassValueModel(org.mule.runtime.extension.api.util.ExtensionModelUtils.toClassValueModel)

Example 3 with ClassValueModel

use of org.mule.runtime.api.meta.model.display.ClassValueModel 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)

Aggregations

ClassValueModel (org.mule.runtime.api.meta.model.display.ClassValueModel)3 Test (org.junit.Test)2 ExtensionDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration)2 ParameterDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration)2 ConfigurationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration)1 OperationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration)1 PathModel (org.mule.runtime.api.meta.model.display.PathModel)1 ExtensionModelUtils.toClassValueModel (org.mule.runtime.extension.api.util.ExtensionModelUtils.toClassValueModel)1