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));
}
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);
}
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");
}
Aggregations