use of org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty 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.extension.api.property.MetadataKeyIdModelProperty 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);
}
use of org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty in project mule by mulesoft.
the class MetadataComponentModelValidatorTestCase method before.
@Before
public void before() {
when(extensionModel.getOperationModels()).thenReturn(asList(operationModel));
when(extensionModel.getSourceModels()).thenReturn(asList(sourceModel));
ExtensionTypeDescriptorModelProperty descriptorModelProperty = mock(ExtensionTypeDescriptorModelProperty.class);
when(extensionModel.getModelProperty(ExtensionTypeDescriptorModelProperty.class)).thenReturn(of(descriptorModelProperty));
Type extensionType = mock(Type.class);
when(descriptorModelProperty.getType()).thenReturn(extensionType);
when(extensionType.getDeclaringClass()).thenReturn(of(this.getClass()));
when(operationModel.getOutput()).thenReturn(new ImmutableOutputModel(EMPTY, toMetadataType(String.class), false, emptySet()));
when(operationModel.getOutputAttributes()).thenReturn(new ImmutableOutputModel(StringUtils.EMPTY, create(JAVA).voidType().build(), false, emptySet()));
when(operationModel.getName()).thenReturn("operation");
mockMetadataResolverFactory(operationModel, null);
when(sourceModel.getOutput()).thenReturn(new ImmutableOutputModel(EMPTY, toMetadataType(String.class), false, emptySet()));
when(sourceModel.getOutputAttributes()).thenReturn(new ImmutableOutputModel(StringUtils.EMPTY, create(JAVA).voidType().build(), false, emptySet()));
when(sourceModel.getName()).thenReturn("source");
when(sourceModel.getSuccessCallback()).thenReturn(of(sourceCallbackModel));
when(sourceModel.getErrorCallback()).thenReturn(of(sourceCallbackModel));
mockMetadataResolverFactory(sourceModel, null);
MetadataKeyIdModelProperty keyIdModelProperty = new MetadataKeyIdModelProperty(loader.load(InvalidMetadataKeyIdPojo.class), EMPTY);
when(sourceModel.getModelProperty(MetadataKeyIdModelProperty.class)).thenReturn(of(keyIdModelProperty));
when(operationModel.getModelProperty(MetadataKeyIdModelProperty.class)).thenReturn(empty());
when(sourceModel.getModelProperty(ExtensionOperationDescriptorModelProperty.class)).thenReturn(empty());
when(operationModel.getModelProperty(ExtensionOperationDescriptorModelProperty.class)).thenReturn(empty());
visitableMock(operationModel, sourceModel);
dictionaryType = typeBuilder.objectType().openWith(toMetadataType(Object.class)).build();
}
use of org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty 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);
}
use of org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty in project mule by mulesoft.
the class MetadataComponentModelValidatorTestCase method metadataKeyWithoutDefaultValues.
@Test
public void metadataKeyWithoutDefaultValues() {
ParameterModel param1 = getMockKeyPartParam(null, 1);
ParameterModel param2 = getMockKeyPartParam(null, 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);
}
Aggregations