Search in sources :

Example 1 with InputTypeResolver

use of org.mule.runtime.api.metadata.resolving.InputTypeResolver 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 InputTypeResolver

use of org.mule.runtime.api.metadata.resolving.InputTypeResolver 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)

Example 3 with InputTypeResolver

use of org.mule.runtime.api.metadata.resolving.InputTypeResolver in project mule by mulesoft.

the class MetadataScopeAdapter method getCategoryName.

private String getCategoryName(Supplier<? extends OutputTypeResolver> outputResolver, Supplier<? extends AttributesTypeResolver> attributesResolver, Map<String, Supplier<? extends InputTypeResolver>> inputResolvers) {
    OutputTypeResolver outputTypeResolver = outputResolver.get();
    if (!(outputTypeResolver instanceof NullMetadataResolver)) {
        return outputTypeResolver.getCategoryName();
    }
    AttributesTypeResolver attributesTypeResolver = attributesResolver.get();
    if (!(attributesTypeResolver instanceof NullMetadataResolver)) {
        return attributesTypeResolver.getCategoryName();
    }
    for (Supplier<? extends InputTypeResolver> supplier : inputResolvers.values()) {
        InputTypeResolver inputTypeResolver = supplier.get();
        if (!(inputTypeResolver instanceof NullMetadataResolver)) {
            return inputTypeResolver.getCategoryName();
        }
    }
    throw new IllegalModelDefinitionException("Unable to create Keys Resolver. A Keys Resolver is being defined " + "without defining an Output Resolver, Input Resolver nor Attributes Resolver");
}
Also used : NullMetadataResolver(org.mule.runtime.extension.api.metadata.NullMetadataResolver) IllegalModelDefinitionException(org.mule.runtime.extension.api.exception.IllegalModelDefinitionException) OutputTypeResolver(org.mule.runtime.api.metadata.resolving.OutputTypeResolver) InputTypeResolver(org.mule.runtime.api.metadata.resolving.InputTypeResolver) AttributesTypeResolver(org.mule.runtime.api.metadata.resolving.AttributesTypeResolver)

Aggregations

InputTypeResolver (org.mule.runtime.api.metadata.resolving.InputTypeResolver)3 Supplier (java.util.function.Supplier)2 DefaultMetadataResolverFactory (org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory)2 NullMetadataResolver (org.mule.runtime.extension.api.metadata.NullMetadataResolver)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 HashedMap (org.apache.commons.collections.map.HashedMap)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 Test (org.junit.Test)1 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)1 AttributesTypeResolver (org.mule.runtime.api.metadata.resolving.AttributesTypeResolver)1 OutputTypeResolver (org.mule.runtime.api.metadata.resolving.OutputTypeResolver)1 NullMetadataResolverSupplier (org.mule.runtime.core.internal.metadata.NullMetadataResolverSupplier)1 IllegalModelDefinitionException (org.mule.runtime.extension.api.exception.IllegalModelDefinitionException)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