Search in sources :

Example 26 with ParameterModel

use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.

the class DefaultExtensionModelFactoryTestCase method sourceWithDefaultBackPressureStrategies.

@Test
public void sourceWithDefaultBackPressureStrategies() {
    ExtensionModel extensionModel = createExtension(HeisenbergExtension.class);
    SourceModel source = extensionModel.getConfigurationModels().get(0).getSourceModel("ReconnectableListenPayments").get();
    Optional<ParameterModel> parameter = source.getAllParameterModels().stream().filter(p -> BACK_PRESSURE_STRATEGY_PARAMETER_NAME.equals(p.getName())).findAny();
    assertThat(parameter.isPresent(), is(false));
}
Also used : SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) Arrays(java.util.Arrays) ImportedTypeModel(org.mule.runtime.api.meta.model.ImportedTypeModel) HeisenbergOperations(org.mule.test.heisenberg.extension.HeisenbergOperations) VALIDATOR(org.mule.runtime.extension.api.stereotype.MuleStereotypes.VALIDATOR) HeisenbergScopes(org.mule.test.heisenberg.extension.HeisenbergScopes) DROP(org.mule.runtime.extension.api.runtime.source.BackPressureMode.DROP) VALIDATOR_DEFINITION(org.mule.runtime.extension.api.stereotype.MuleStereotypes.VALIDATOR_DEFINITION) Export(org.mule.runtime.extension.api.annotation.Export) KillingOperations(org.mule.test.heisenberg.extension.KillingOperations) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) CPU_LITE(org.mule.runtime.api.meta.model.operation.ExecutionType.CPU_LITE) Arrays.asList(java.util.Arrays.asList) OnException(org.mule.runtime.extension.api.annotation.OnException) ClassTypeLoader(org.mule.metadata.api.ClassTypeLoader) ObjectStore(org.mule.runtime.api.store.ObjectStore) MuleExtensionUtils.loadExtension(org.mule.runtime.module.extension.api.util.MuleExtensionUtils.loadExtension) SELECT(org.mule.runtime.api.meta.Category.SELECT) EmpireStereotype(org.mule.test.heisenberg.extension.stereotypes.EmpireStereotype) HeisenbergConnectionExceptionEnricher(org.mule.test.heisenberg.extension.exception.HeisenbergConnectionExceptionEnricher) CarDealer(org.mule.test.heisenberg.extension.model.CarDealer) EnumAnnotation(org.mule.metadata.api.annotation.EnumAnnotation) StringType(org.mule.metadata.api.model.StringType) Sources(org.mule.runtime.extension.api.annotation.Sources) MarvelExtension(org.mule.test.marvel.MarvelExtension) Operations(org.mule.runtime.extension.api.annotation.Operations) StereotypeModel(org.mule.runtime.api.meta.model.stereotype.StereotypeModel) Extension(org.mule.runtime.extension.api.annotation.Extension) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) Ricin(org.mule.test.heisenberg.extension.model.Ricin) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) ExternalLibraryModel(org.mule.runtime.api.meta.model.ExternalLibraryModel) PaulMcCartneySource(org.mule.test.vegan.extension.PaulMcCartneySource) EmitsResponse(org.mule.runtime.extension.api.annotation.source.EmitsResponse) BackPressure(org.mule.runtime.extension.api.annotation.source.BackPressure) SecureHeisenbergConnectionProvider(org.mule.test.heisenberg.extension.SecureHeisenbergConnectionProvider) AbstractMuleTestCase(org.mule.tck.junit4.AbstractMuleTestCase) PAYLOAD(org.mule.runtime.extension.api.annotation.param.Optional.PAYLOAD) Matchers.hasSize(org.hamcrest.Matchers.hasSize) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) CONFIG_NAME(org.mule.test.marvel.ironman.IronMan.CONFIG_NAME) HasExternalLibraries(org.mule.runtime.api.meta.model.HasExternalLibraries) Investment(org.mule.test.heisenberg.extension.model.Investment) Test(org.junit.Test) HEISENBERG_LIB_DESCRIPTION(org.mule.test.heisenberg.extension.HeisenbergExtension.HEISENBERG_LIB_DESCRIPTION) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) BLOCKING(org.mule.runtime.api.meta.model.operation.ExecutionType.BLOCKING) VeganExtension(org.mule.test.vegan.extension.VeganExtension) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) MoneyLaunderingOperation(org.mule.test.heisenberg.extension.MoneyLaunderingOperation) STREAMING_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.STREAMING_STRATEGY_PARAMETER_NAME) Streaming(org.mule.runtime.extension.api.annotation.Streaming) MediaType(org.mule.runtime.extension.api.annotation.param.MediaType) HeisenbergErrors(org.mule.test.heisenberg.extension.HeisenbergErrors) Reference(org.mule.runtime.api.util.Reference) HEISENBERG_LIB_FILE_NAME(org.mule.test.heisenberg.extension.HeisenbergExtension.HEISENBERG_LIB_FILE_NAME) NOT_SUPPORTED(org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED) CoreMatchers.is(org.hamcrest.CoreMatchers.is) TEXT_PLAIN(org.mule.runtime.extension.api.annotation.param.MediaType.TEXT_PLAIN) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) Assert.assertThat(org.junit.Assert.assertThat) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) APPLE(org.mule.test.vegan.extension.VeganExtension.APPLE) SmallTest(org.mule.tck.size.SmallTest) WAIT(org.mule.runtime.extension.api.runtime.source.BackPressureMode.WAIT) MetadataTypeUtils.getTypeId(org.mule.metadata.api.utils.MetadataTypeUtils.getTypeId) HEISENBERG(org.mule.test.heisenberg.extension.HeisenbergExtension.HEISENBERG) IdempotentExtensionWalker(org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker) SubTypeMapping(org.mule.runtime.extension.api.annotation.SubTypeMapping) StreamingStrategyTypeBuilder(org.mule.runtime.extension.api.declaration.type.StreamingStrategyTypeBuilder) Weapon(org.mule.test.heisenberg.extension.model.Weapon) ConnectionProviders(org.mule.runtime.extension.api.annotation.connectivity.ConnectionProviders) HeisenbergException(org.mule.test.heisenberg.extension.exception.HeisenbergException) PROCESSOR_DEFINITION(org.mule.runtime.extension.api.stereotype.MuleStereotypes.PROCESSOR_DEFINITION) BACK_PRESSURE_STRATEGY_PARAMETER_NAME(org.mule.runtime.extension.api.ExtensionConstants.BACK_PRESSURE_STRATEGY_PARAMETER_NAME) PRIMARY_CONTENT(org.mule.runtime.api.meta.model.parameter.ParameterRole.PRIMARY_CONTENT) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Optional(java.util.Optional) HeisenbergRouters(org.mule.test.heisenberg.extension.HeisenbergRouters) IllegalModelDefinitionException(org.mule.runtime.extension.api.exception.IllegalModelDefinitionException) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) Alias(org.mule.runtime.extension.api.annotation.Alias) HeisenbergSource(org.mule.test.heisenberg.extension.HeisenbergSource) CPU_INTENSIVE(org.mule.runtime.api.meta.model.operation.ExecutionType.CPU_INTENSIVE) ExpectedException.none(org.junit.rules.ExpectedException.none) HeisenbergConnectionProvider(org.mule.test.heisenberg.extension.HeisenbergConnectionProvider) HEISENBERG_LIB_CLASS_NAME(org.mule.test.heisenberg.extension.HeisenbergExtension.HEISENBERG_LIB_CLASS_NAME) NoSuchElementException(java.util.NoSuchElementException) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) ExpectedException(org.junit.rules.ExpectedException) ErrorTypes(org.mule.runtime.extension.api.annotation.error.ErrorTypes) CoreMatchers.sameInstance(org.hamcrest.CoreMatchers.sameInstance) OBJECT_STORE(org.mule.runtime.extension.api.stereotype.MuleStereotypes.OBJECT_STORE) HEISENBERG_LIB_NAME(org.mule.test.heisenberg.extension.HeisenbergExtension.HEISENBERG_LIB_NAME) BANANA(org.mule.test.vegan.extension.VeganExtension.BANANA) ExtensionModelUtils(org.mule.runtime.extension.api.util.ExtensionModelUtils) Collectors.toList(java.util.stream.Collectors.toList) Rule(org.junit.Rule) PROCESSOR(org.mule.runtime.extension.api.stereotype.MuleStereotypes.PROCESSOR) CarWash(org.mule.test.heisenberg.extension.model.CarWash) FAIL(org.mule.runtime.extension.api.runtime.source.BackPressureMode.FAIL) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 27 with ParameterModel

use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.

the class DefaultExtensionManagerTestCase method enumTransformer.

@Test
public void enumTransformer() throws Exception {
    DefaultExtensionManager extensionsManager = new DefaultExtensionManager();
    extensionsManager.setMuleContext(muleContext);
    extensionsManager.initialise();
    ParameterModel parameter = mock(ParameterModel.class);
    when(parameter.getType()).thenReturn(toMetadataType(TimeUnit.class));
    ParameterModel parameterOfRepeatedEnumType = mock(ParameterModel.class);
    when(parameterOfRepeatedEnumType.getType()).thenReturn(toMetadataType(TimeUnit.class));
    mockParameters(extension1ConfigurationModel, parameter, parameterOfRepeatedEnumType);
    extensionsManager.registerExtension(extensionModel1);
    verify(muleContext.getRegistry()).registerObject(anyString(), any(StringToEnum.class), eq(Transformer.class));
}
Also used : Transformer(org.mule.runtime.core.api.transformer.Transformer) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) TimeUnit(java.util.concurrent.TimeUnit) StringToEnum(org.mule.runtime.core.internal.transformer.simple.StringToEnum) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 28 with ParameterModel

use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.

the class MetadataComponentModelValidatorTestCase method stringMetadataKeyWithDefaultValue.

@Test
public void stringMetadataKeyWithDefaultValue() {
    ParameterModel param = getMockKeyPartParam("default", 1);
    MetadataKeyIdModelProperty keyIdModelProperty = new MetadataKeyIdModelProperty(loader.load(String.class), EMPTY);
    when(sourceModel.getModelProperty(MetadataKeyIdModelProperty.class)).thenReturn(of(keyIdModelProperty));
    when(sourceModel.getAllParameterModels()).thenReturn(singletonList(param));
    validate(extensionModel, validator);
}
Also used : MetadataKeyIdModelProperty(org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) StringContains.containsString(org.hamcrest.core.StringContains.containsString) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 29 with ParameterModel

use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.

the class MetadataComponentModelValidatorTestCase method metadataKeyWithValidDefaultValues.

@Test
public void metadataKeyWithValidDefaultValues() {
    ParameterModel param1 = getMockKeyPartParam("Value", 1);
    ParameterModel param2 = getMockKeyPartParam("SomeValue", 2);
    MetadataKeyIdModelProperty keyIdModelProperty = new MetadataKeyIdModelProperty(loader.load(InvalidMetadataKeyIdPojo.class), EMPTY);
    when(sourceModel.getModelProperty(MetadataKeyIdModelProperty.class)).thenReturn(of(keyIdModelProperty));
    when(sourceModel.getAllParameterModels()).thenReturn(asList(param1, param2));
    validate(extensionModel, validator);
}
Also used : MetadataKeyIdModelProperty(org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 30 with ParameterModel

use of org.mule.runtime.api.meta.model.parameter.ParameterModel in project mule by mulesoft.

the class MetadataComponentModelValidatorTestCase method metadataResolverWithRepeatedResolverName.

@Test
public void metadataResolverWithRepeatedResolverName() {
    exception.expect(IllegalModelDefinitionException.class);
    exception.expectMessage(containsString("Resolver names should be unique for a given category"));
    Map<String, Supplier<? extends InputTypeResolver>> inputResolvers = new HashedMap();
    ParameterModel parameterModel = mock(ParameterModel.class);
    when(parameterModel.getName()).thenReturn(PARAMETER_NAME);
    when(parameterModel.getModelProperty(MetadataKeyIdModelProperty.class)).thenReturn(java.util.Optional.empty());
    when(sourceModel.getModelProperty(MetadataKeyIdModelProperty.class)).thenReturn(java.util.Optional.empty());
    mockParameters(sourceModel, parameterModel);
    inputResolvers.put(PARAMETER_NAME, ResolverSupplier.of(SimpleInputResolver.class));
    mockMetadataResolverFactory(sourceModel, new DefaultMetadataResolverFactory(NULL_RESOLVER_SUPPLIER, inputResolvers, SIMPLE_OUTPUT_RESOLVER, NULL_RESOLVER_SUPPLIER));
    validate(extensionModel, validator);
}
Also used : DefaultMetadataResolverFactory(org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory) InputTypeResolver(org.mule.runtime.api.metadata.resolving.InputTypeResolver) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) NullMetadataResolverSupplier(org.mule.runtime.core.internal.metadata.NullMetadataResolverSupplier) ResolverSupplier(org.mule.runtime.module.extension.internal.metadata.ResolverSupplier) Supplier(java.util.function.Supplier) StringContains.containsString(org.hamcrest.core.StringContains.containsString) HashedMap(org.apache.commons.collections.map.HashedMap) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)133 Test (org.junit.Test)91 SmallTest (org.mule.tck.size.SmallTest)68 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)29 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)21 List (java.util.List)19 ParameterGroupModel (org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)19 Optional (java.util.Optional)16 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)15 Collectors.toList (java.util.stream.Collectors.toList)13 ObjectType (org.mule.metadata.api.model.ObjectType)13 String.format (java.lang.String.format)12 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)12 ParameterizedModel (org.mule.runtime.api.meta.model.parameter.ParameterizedModel)12 ExtensionsTypeLoaderFactory (org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory)12 StringType (org.mule.metadata.api.model.StringType)11 ClassTypeLoader (org.mule.metadata.api.ClassTypeLoader)10 ArrayType (org.mule.metadata.api.model.ArrayType)10 MetadataType (org.mule.metadata.api.model.MetadataType)10 Map (java.util.Map)9