Search in sources :

Example 1 with DefaultMetadataResolverFactory

use of org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory in project mule by mulesoft.

the class SoapInvokeOperationDeclarer method declareMetadata.

private void declareMetadata(OperationDeclarer operation, ClassTypeLoader loader) {
    ImmutableMap.Builder<String, Supplier<? extends InputTypeResolver>> inputResolver = ImmutableMap.builder();
    inputResolver.put(BODY_PARAM, InvokeRequestTypeResolver::new);
    inputResolver.put(HEADERS_PARAM, InvokeInputHeadersTypeResolver::new);
    inputResolver.put(ATTACHMENTS_PARAM, InvokeInputAttachmentsTypeResolver::new);
    DefaultMetadataResolverFactory factory = new DefaultMetadataResolverFactory(InvokeKeysResolver::new, inputResolver.build(), InvokeOutputTypeResolver::new, NullMetadataResolver::new);
    operation.withModelProperty(new MetadataResolverFactoryModelProperty(() -> factory));
    operation.withModelProperty(new MetadataKeyIdModelProperty(loader.load(WebServiceTypeKey.class), KEYS_GROUP));
}
Also used : NullMetadataResolver(org.mule.runtime.extension.api.metadata.NullMetadataResolver) DefaultMetadataResolverFactory(org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory) MetadataKeyIdModelProperty(org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty) InvokeKeysResolver(org.mule.runtime.module.extension.soap.internal.metadata.InvokeKeysResolver) InvokeRequestTypeResolver(org.mule.runtime.module.extension.soap.internal.metadata.InvokeRequestTypeResolver) InvokeInputHeadersTypeResolver(org.mule.runtime.module.extension.soap.internal.metadata.InvokeInputHeadersTypeResolver) MetadataResolverFactoryModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.MetadataResolverFactoryModelProperty) InvokeOutputTypeResolver(org.mule.runtime.module.extension.soap.internal.metadata.InvokeOutputTypeResolver) ImmutableMap(com.google.common.collect.ImmutableMap) InvokeInputAttachmentsTypeResolver(org.mule.runtime.module.extension.soap.internal.metadata.InvokeInputAttachmentsTypeResolver) InputTypeResolver(org.mule.runtime.api.metadata.resolving.InputTypeResolver) Supplier(java.util.function.Supplier)

Example 2 with DefaultMetadataResolverFactory

use of org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory in project mule by mulesoft.

the class MetadataComponentModelValidatorTestCase method valid.

@Test
public void valid() {
    mockMetadataResolverFactory(sourceModel, new DefaultMetadataResolverFactory(MOCK_RESOLVER_SUPPLIER, emptyMap(), MOCK_RESOLVER_SUPPLIER, NULL_RESOLVER_SUPPLIER));
    validate(extensionModel, validator);
}
Also used : DefaultMetadataResolverFactory(org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 3 with DefaultMetadataResolverFactory

use of org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory in project mule by mulesoft.

the class MetadataComponentModelValidatorTestCase method metadataResolverWithDifferentCategories.

@Test
public void metadataResolverWithDifferentCategories() {
    exception.expect(IllegalModelDefinitionException.class);
    exception.expectMessage(containsString("specifies metadata resolvers that doesn't belong to the same category"));
    mockMetadataResolverFactory(sourceModel, new DefaultMetadataResolverFactory(ResolverSupplier.of(DifferentCategoryResolver.class), emptyMap(), SIMPLE_OUTPUT_RESOLVER, NULL_RESOLVER_SUPPLIER));
    validate(extensionModel, validator);
}
Also used : DefaultMetadataResolverFactory(org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 4 with DefaultMetadataResolverFactory

use of org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory in project mule by mulesoft.

the class MetadataComponentModelValidatorTestCase method metadataResolverWithEmptyCategoryName.

@Test
public void metadataResolverWithEmptyCategoryName() {
    exception.expect(IllegalModelDefinitionException.class);
    exception.expectMessage(containsString("which has an empty category name"));
    mockMetadataResolverFactory(sourceModel, new DefaultMetadataResolverFactory(ResolverSupplier.of(EmptyCategoryName.class), emptyMap(), SIMPLE_OUTPUT_RESOLVER, NULL_RESOLVER_SUPPLIER));
    validate(extensionModel, validator);
}
Also used : DefaultMetadataResolverFactory(org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 5 with DefaultMetadataResolverFactory

use of org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory 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

DefaultMetadataResolverFactory (org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory)11 Test (org.junit.Test)10 SmallTest (org.mule.tck.size.SmallTest)10 ImmutableOutputModel (org.mule.runtime.extension.api.model.ImmutableOutputModel)5 Supplier (java.util.function.Supplier)2 InputTypeResolver (org.mule.runtime.api.metadata.resolving.InputTypeResolver)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 HashedMap (org.apache.commons.collections.map.HashedMap)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)1 NullMetadataResolverSupplier (org.mule.runtime.core.internal.metadata.NullMetadataResolverSupplier)1 NullMetadataResolver (org.mule.runtime.extension.api.metadata.NullMetadataResolver)1 MetadataKeyIdModelProperty (org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty)1 MetadataResolverFactoryModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.MetadataResolverFactoryModelProperty)1 ResolverSupplier (org.mule.runtime.module.extension.internal.metadata.ResolverSupplier)1 InvokeInputAttachmentsTypeResolver (org.mule.runtime.module.extension.soap.internal.metadata.InvokeInputAttachmentsTypeResolver)1 InvokeInputHeadersTypeResolver (org.mule.runtime.module.extension.soap.internal.metadata.InvokeInputHeadersTypeResolver)1 InvokeKeysResolver (org.mule.runtime.module.extension.soap.internal.metadata.InvokeKeysResolver)1 InvokeOutputTypeResolver (org.mule.runtime.module.extension.soap.internal.metadata.InvokeOutputTypeResolver)1 InvokeRequestTypeResolver (org.mule.runtime.module.extension.soap.internal.metadata.InvokeRequestTypeResolver)1