Search in sources :

Example 1 with ConfigurationDeclaration

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

the class ParameterLayoutOrderDeclarationEnricher method enrich.

@Override
public void enrich(ExtensionLoadingContext extensionLoadingContext) {
    ExtensionDeclaration declaration = extensionLoadingContext.getExtensionDeclarer().getDeclaration();
    new IdempotentDeclarationWalker() {

        @Override
        public void onOperation(OperationDeclaration declaration) {
            establishOrder(declaration);
        }

        @Override
        public void onConfiguration(ConfigurationDeclaration declaration) {
            establishOrder(declaration);
        }

        @Override
        public void onSource(SourceDeclaration declaration) {
            establishOrder(declaration);
        }

        @Override
        protected void onConnectionProvider(ConnectionProviderDeclaration declaration) {
            establishOrder(declaration);
        }
    }.walk(declaration);
}
Also used : ConfigurationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration) ConnectionProviderDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConnectionProviderDeclaration) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) IdempotentDeclarationWalker(org.mule.runtime.extension.api.declaration.fluent.util.IdempotentDeclarationWalker) OperationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration) SourceDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.SourceDeclaration)

Example 2 with ConfigurationDeclaration

use of org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration 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 3 with ConfigurationDeclaration

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

the class DisplayDeclarationEnricherTestCase method parseSimplePathParameter.

@Test
public void parseSimplePathParameter() {
    ExtensionDeclaration declaration = marvelDeclarer.getDeclaration();
    ConfigurationDeclaration config = findConfigByName(declaration, IronMan.CONFIG_NAME);
    List<ParameterDeclaration> params = config.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(true));
    assertThat(pathModel.get().getFileExtensions(), empty());
}
Also used : ConfigurationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration) PathModel(org.mule.runtime.api.meta.model.display.PathModel) 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 4 with ConfigurationDeclaration

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

the class DisplayDeclarationEnricherTestCase method parsePathParameterThatIsDirectory.

@Test
public void parsePathParameterThatIsDirectory() {
    ExtensionDeclaration declaration = marvelDeclarer.getDeclaration();
    ConfigurationDeclaration config = findConfigByName(declaration, IronMan.CONFIG_NAME);
    ConnectionProviderDeclaration missileProvider = findProviderByName(config, MissileProvider.NAME);
    List<ParameterDeclaration> params = missileProvider.getAllParameters();
    assertThat(params, hasSize(1));
    ParameterDeclaration pathParam = params.get(0);
    Optional<PathModel> pathModel = pathParam.getDisplayModel().getPathModel();
    assertThat(pathModel.isPresent(), is(true));
    assertThat(pathModel.get().getType(), is(DIRECTORY));
    assertThat(pathModel.get().acceptsUrls(), is(false));
    assertThat(pathModel.get().getFileExtensions(), empty());
}
Also used : ConfigurationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration) PathModel(org.mule.runtime.api.meta.model.display.PathModel) ConnectionProviderDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConnectionProviderDeclaration) 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 5 with ConfigurationDeclaration

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

the class ComplexExtensionLoadingTestCase method assertOperation.

private void assertOperation(String configName, String operationName) {
    ConfigurationDeclaration config = extensionDeclaration.getConfigurations().stream().filter(c -> c.getName().equals(configName)).findFirst().orElseThrow(() -> new IllegalArgumentException("No config with name " + configName));
    OperationDeclaration operation = config.getOperations().stream().filter(model -> model.getName().equals(operationName)).findFirst().orElseThrow(() -> new IllegalArgumentException("No operation with name " + operationName));
    assertThat(operation.getName(), is(operationName));
}
Also used : ConfigurationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration) OperationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration)

Aggregations

ConfigurationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration)12 ExtensionDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration)9 Test (org.junit.Test)7 OperationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration)4 ParameterDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration)4 SourceDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.SourceDeclaration)4 SmallTest (org.mule.tck.size.SmallTest)4 ConnectionProviderDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ConnectionProviderDeclaration)3 ExtensionDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer)3 List (java.util.List)2 PathModel (org.mule.runtime.api.meta.model.display.PathModel)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 URL (java.net.URL)1 LocalDateTime (java.time.LocalDateTime)1 Arrays.asList (java.util.Arrays.asList)1 Calendar (java.util.Calendar)1 Collections.emptySet (java.util.Collections.emptySet)1 Date (java.util.Date)1 Map (java.util.Map)1