Search in sources :

Example 11 with ParameterDeclaration

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

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

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

the class JavaDeclarationDelegateTestCase method assertTestModuleConfiguration.

private void assertTestModuleConfiguration(ExtensionDeclaration extensionDeclaration) throws Exception {
    assertThat(extensionDeclaration.getConfigurations(), hasSize(1));
    ConfigurationDeclaration conf = extensionDeclaration.getConfigurations().get(0);
    assertThat(conf.getName(), equalTo(DEFAULT_CONFIG_NAME));
    List<ParameterDeclaration> parameters = conf.getAllParameters();
    assertThat(parameters, hasSize(31));
    assertParameter(parameters, "myName", "", STRING_TYPE, false, SUPPORTED, HEISENBERG);
    assertParameter(parameters, "age", "", toMetadataType(Integer.class), false, SUPPORTED, AGE);
    assertParameter(parameters, "enemies", "", listOfString(), true, SUPPORTED, null);
    assertParameter(parameters, "money", "", toMetadataType(BigDecimal.class), true, SUPPORTED, null);
    assertParameter(parameters, "cancer", "", toMetadataType(boolean.class), true, SUPPORTED, null);
    assertParameter(parameters, "cancer", "", toMetadataType(boolean.class), true, SUPPORTED, null);
    assertParameter(parameters, "dateOfBirth", "", toMetadataType(Date.class), false, SUPPORTED, null);
    assertParameter(parameters, "dateOfDeath", "", toMetadataType(Calendar.class), false, SUPPORTED, null);
    assertParameter(parameters, "dateOfConception", "", toMetadataType(LocalDateTime.class), false, SUPPORTED, null);
    assertParameter(parameters, "dateOfGraduation", "", toMetadataType(Calendar.class), false, NOT_SUPPORTED, null);
    assertParameter(parameters, "recipe", "", TYPE_BUILDER.objectType().openWith(TYPE_BUILDER.numberType().integer().with(new ClassInformationAnnotation(Long.class))).with(new ClassInformationAnnotation(Map.class, asList(String.class, Long.class))).build(), false, SUPPORTED, null);
    assertParameter(parameters, "ricinPacks", "", arrayOf(Set.class, objectTypeBuilder(Ricin.class)), false, SUPPORTED, null);
    assertParameter(parameters, "nextDoor", "", toMetadataType(KnockeableDoor.class), false, SUPPORTED, null);
    assertParameter(parameters, "candidateDoors", "", TYPE_BUILDER.objectType().openWith((objectTypeBuilder(KnockeableDoor.class)).build()).with(new ClassInformationAnnotation(Map.class, asList(String.class, KnockeableDoor.class))).build(), false, SUPPORTED, null);
    assertParameter(parameters, "initialHealth", "", toMetadataType(HealthStatus.class), false, SUPPORTED, "CANCER");
    assertParameter(parameters, "finalHealth", "", toMetadataType(HealthStatus.class), true, SUPPORTED, null);
    assertParameter(parameters, "labAddress", "", STRING_TYPE, false, REQUIRED, null);
    assertParameter(parameters, "firstEndevour", "", STRING_TYPE, false, NOT_SUPPORTED, null);
    assertParameter(parameters, "weapon", "", toMetadataType(Weapon.class), false, SUPPORTED, null);
    assertParameter(parameters, "wildCardWeapons", "", arrayOf(List.class, objectTypeBuilder(Weapon.class)), false, SUPPORTED, null);
    assertParameter(parameters, "wildCards", "", arrayOf(List.class, objectTypeBuilder(Object.class)), false, SUPPORTED, null);
    assertParameter(parameters, "worksAtDEA", "", toMetadataType(boolean.class), false, SUPPORTED, valueOf(TRUE));
    assertParameter(parameters, "lovesMinerals", "", toMetadataType(boolean.class), true, SUPPORTED, null);
    assertParameter(parameters, "monthlyIncomes", "", arrayOf(List.class, longTypeBuilder()), true, SUPPORTED, null);
    assertParameter(parameters, "labeledRicin", "", TYPE_BUILDER.objectType().openWith(objectTypeBuilder(Ricin.class)).with(new ClassInformationAnnotation(Map.class, asList(String.class, Ricin.class))).build(), false, SUPPORTED, null);
    assertParameter(parameters, "deathsBySeasons", "", TYPE_BUILDER.objectType().with(new ClassInformationAnnotation(Map.class, asList(String.class, List.class))).openWith(TYPE_BUILDER.arrayType().of(TYPE_BUILDER.stringType())).build(), false, SUPPORTED, null);
    assertParameter(parameters, "weaponValueMap", "", TYPE_BUILDER.objectType().with(new ClassInformationAnnotation(Map.class, asList(String.class, Weapon.class))).openWith(WEAPON_TYPE).build(), false, SUPPORTED, null);
    assertParameter(parameters, "healthProgressions", "", TYPE_BUILDER.arrayType().of(TYPE_LOADER.load(HealthStatus.class)).build(), false, SUPPORTED, null);
}
Also used : LocalDateTime(java.time.LocalDateTime) Set(java.util.Set) Collections.emptySet(java.util.Collections.emptySet) ConfigurationDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration) Calendar(java.util.Calendar) HealthStatus(org.mule.test.heisenberg.extension.model.HealthStatus) BigDecimal(java.math.BigDecimal) Date(java.util.Date) ClassInformationAnnotation(org.mule.metadata.java.api.annotation.ClassInformationAnnotation) Weapon(org.mule.test.heisenberg.extension.model.Weapon) KnockeableDoor(org.mule.test.heisenberg.extension.model.KnockeableDoor) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Map(java.util.Map) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration)

Example 14 with ParameterDeclaration

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

the class JavaDeclarationDelegateTestCase method assertHeisenbergSource.

private void assertHeisenbergSource(SourceDeclaration source, String sourceName, Class<? extends Source> type) {
    assertThat(source.getName(), is(sourceName));
    List<ParameterDeclaration> parameters = source.getAllParameters();
    assertThat(parameters, hasSize(31));
    assertParameter(parameters, SOURCE_PARAMETER, "", INT_TYPE, true, NOT_SUPPORTED, null);
    assertParameter(parameters, SOURCE_CALLBACK_PARAMETER, "", toMetadataType(Long.class), false, SUPPORTED, "#[payload]");
    assertParameter(parameters, SOURCE_REPEATED_CALLBACK_PARAMETER, "", STRING_TYPE, false, SUPPORTED, null);
    assertParameter(parameters, "methylamine", "", toMetadataType(Methylamine.class), false, SUPPORTED, null);
    ImplementingTypeModelProperty typeModelProperty = source.getModelProperty(ImplementingTypeModelProperty.class).get();
    assertThat(typeModelProperty.getType(), equalTo(type));
}
Also used : Methylamine(org.mule.test.heisenberg.extension.model.Methylamine) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty)

Example 15 with ParameterDeclaration

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

the class BooleanParameterDeclarationEnricherTestCase method verifyConfigurationModelPropertyOnOperation.

@Test
public void verifyConfigurationModelPropertyOnOperation() {
    ParameterDeclaration booleanDeclaration = getNamedObject(declaration.getConfigurations().get(0).getAllParameters(), "lovesMinerals");
    assertThat(booleanDeclaration.isRequired(), is(FALSE));
    assertThat(booleanDeclaration.getDefaultValue(), is(valueOf(FALSE)));
    booleanDeclaration = getNamedObject(declaration.getConfigurations().get(0).getAllParameters(), "worksAtDEA");
    assertThat(booleanDeclaration.isRequired(), is(FALSE));
    assertThat(booleanDeclaration.getDefaultValue(), is(valueOf(TRUE)));
}
Also used : ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) Test(org.junit.Test)

Aggregations

ParameterDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration)28 Test (org.junit.Test)18 ExtensionDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclaration)15 OperationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclaration)9 ConfigurationDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclaration)4 ParameterGroupDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclaration)3 PathModel (org.mule.runtime.api.meta.model.display.PathModel)3 List (java.util.List)2 ClassTypeLoader (org.mule.metadata.api.ClassTypeLoader)2 MetadataType (org.mule.metadata.api.model.MetadataType)2 ObjectType (org.mule.metadata.api.model.ObjectType)2 StringType (org.mule.metadata.api.model.StringType)2 ClassInformationAnnotation (org.mule.metadata.java.api.annotation.ClassInformationAnnotation)2 ImportedTypeModel (org.mule.runtime.api.meta.model.ImportedTypeModel)2 ConnectionProviderDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ConnectionProviderDeclaration)2 SourceDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.SourceDeclaration)2 ClassValueModel (org.mule.runtime.api.meta.model.display.ClassValueModel)2 Reference (org.mule.runtime.api.util.Reference)2 IdempotentDeclarationWalker (org.mule.runtime.extension.api.declaration.fluent.util.IdempotentDeclarationWalker)2 BigDecimal (java.math.BigDecimal)1