Search in sources :

Example 1 with MetadataKeyIdModelProperty

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));
}
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 MetadataKeyIdModelProperty

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);
}
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 3 with MetadataKeyIdModelProperty

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();
}
Also used : ImmutableOutputModel(org.mule.runtime.extension.api.model.ImmutableOutputModel) Type(org.mule.runtime.module.extension.api.loader.java.type.Type) ArrayType(org.mule.metadata.api.model.ArrayType) ObjectType(org.mule.metadata.api.model.ObjectType) MetadataType(org.mule.metadata.api.model.MetadataType) ExtensionsTestUtils.toMetadataType(org.mule.test.module.extension.internal.util.ExtensionsTestUtils.toMetadataType) MetadataKeyIdModelProperty(org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty) ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty) Before(org.junit.Before)

Example 4 with MetadataKeyIdModelProperty

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);
}
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 5 with MetadataKeyIdModelProperty

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

Aggregations

MetadataKeyIdModelProperty (org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty)9 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)4 Before (org.junit.Before)3 Test (org.junit.Test)3 MetadataType (org.mule.metadata.api.model.MetadataType)3 SmallTest (org.mule.tck.size.SmallTest)3 Field (java.lang.reflect.Field)2 Map (java.util.Map)2 ObjectType (org.mule.metadata.api.model.ObjectType)2 NullMetadataResolver (org.mule.runtime.extension.api.metadata.NullMetadataResolver)2 ImmutableOutputModel (org.mule.runtime.extension.api.model.ImmutableOutputModel)2 MetadataKeyPartModelProperty (org.mule.runtime.extension.api.property.MetadataKeyPartModelProperty)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 String.format (java.lang.String.format)1 String.valueOf (java.lang.String.valueOf)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Optional (java.util.Optional)1 Function.identity (java.util.function.Function.identity)1 Supplier (java.util.function.Supplier)1