Search in sources :

Example 6 with OperationDeclaration

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

the class TargetParameterDeclarationEnricherTestCase method verifyTargetValueParameterOnOperation.

@Test
public void verifyTargetValueParameterOnOperation() {
    OperationDeclaration operationDeclaration = getNamedObject(declaration.getOperations(), "transform");
    ParameterDeclaration parameterDeclaration = getNamedObject(operationDeclaration.getAllParameters(), "targetValue");
    assertThat(parameterDeclaration.getName(), is("targetValue"));
    assertThat(parameterDeclaration.getExpressionSupport(), is(REQUIRED));
    assertThat(parameterDeclaration.getType(), instanceOf(StringType.class));
    assertThat(parameterDeclaration.isRequired(), is(false));
}
Also used : StringType(org.mule.metadata.api.model.StringType) 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 7 with OperationDeclaration

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

the class TargetParameterDeclarationEnricherTestCase method verifyTargetParameterOnOperation.

@Test
public void verifyTargetParameterOnOperation() {
    OperationDeclaration operationDeclaration = getNamedObject(declaration.getOperations(), "transform");
    ParameterDeclaration parameterDeclaration = getNamedObject(operationDeclaration.getAllParameters(), "target");
    assertThat(parameterDeclaration.getName(), is("target"));
    assertThat(parameterDeclaration.getExpressionSupport(), is(NOT_SUPPORTED));
    assertThat(parameterDeclaration.getType(), instanceOf(StringType.class));
    assertThat(parameterDeclaration.isRequired(), is(false));
}
Also used : StringType(org.mule.metadata.api.model.StringType) 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 8 with OperationDeclaration

use of org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration 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)

Example 9 with OperationDeclaration

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

the class ExclusiveOptionalModelTestCase method exclusiveOptionals.

@Test
public void exclusiveOptionals() {
    OperationDeclaration operation = getOperation(extensionDeclaration, "convinceAnimalKiller");
    assertThat(operation.getParameterGroups(), hasSize(2));
    ParameterGroupDeclaration group = operation.getParameterGroups().get(0);
    assertThat(group.getName(), equalTo("arguments"));
    assertThat(group.getExclusiveParameters(), hasSize(1));
    ExclusiveParametersDeclaration exclusive = group.getExclusiveParameters().get(0);
    assertThat(exclusive.isRequiresOne(), is(false));
    assertThat(exclusive.getParameterNames(), containsInAnyOrder("argument1", "argument2", "argument3"));
}
Also used : ExclusiveParametersDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExclusiveParametersDeclaration) ParameterGroupDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclaration) OperationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration) Test(org.junit.Test)

Example 10 with OperationDeclaration

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

the class LayoutModelTestCase method parseLayoutAnnotationsOnOperationParameter.

@Test
public void parseLayoutAnnotationsOnOperationParameter() {
    ExtensionDeclarer declarer = declareExtension();
    ExtensionDeclaration extensionDeclaration = declarer.getDeclaration();
    OperationDeclaration operation = getOperation(extensionDeclaration, KILL_CUSTOM_OPERATION);
    assertThat(operation, is(notNullValue()));
    assertParameterPlacement(findParameterInGroup(operation, "victim"), KILL_WITH_GROUP, 1);
    assertParameterPlacement(findParameterInGroup(operation, "goodbyeMessage"), KILL_WITH_GROUP, 2);
}
Also used : ExtensionDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer) ExtensionDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration) OperationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Aggregations

OperationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration)26 Test (org.junit.Test)18 ExtensionDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration)12 ParameterDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration)9 ExtensionDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer)6 SmallTest (org.mule.tck.size.SmallTest)5 ConfigurationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration)4 SourceDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.SourceDeclaration)4 WithOperationsDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.WithOperationsDeclaration)4 List (java.util.List)3 DeclarationEnricher (org.mule.runtime.extension.api.loader.DeclarationEnricher)3 ExtensionLoadingContext (org.mule.runtime.extension.api.loader.ExtensionLoadingContext)3 DefaultExtensionLoadingContext (org.mule.runtime.extension.internal.loader.DefaultExtensionLoadingContext)3 String.format (java.lang.String.format)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Optional.ofNullable (java.util.Optional.ofNullable)2 MetadataType (org.mule.metadata.api.model.MetadataType)2 StringType (org.mule.metadata.api.model.StringType)2 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)2