Search in sources :

Example 1 with TypeWrapper

use of org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper in project mule by mulesoft.

the class OperationReturnTypeModelValidatorTestCase method muleEventReturnType.

@Test(expected = IllegalModelDefinitionException.class)
public void muleEventReturnType() {
    when(methodElement.getReturnType()).thenReturn(new TypeWrapper(forType(new TypeToken<CoreEvent>() {
    }.getType()), typeLoader));
    validate(extensionModel, validator);
}
Also used : TypeWrapper(org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper) TypeToken(com.google.common.reflect.TypeToken) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 2 with TypeWrapper

use of org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper in project mule by mulesoft.

the class OperationReturnTypeModelValidatorTestCase method before.

@Before
public void before() {
    ExtensionOperationDescriptorModelProperty modelProperty = new ExtensionOperationDescriptorModelProperty(methodElement);
    when(extensionModel.getOperationModels()).thenReturn(asList(operationModel));
    when(operationModel.getOutput()).thenReturn(new ImmutableOutputModel("Message.Payload", toMetadataType(String.class), false, emptySet()));
    when(operationModel.getName()).thenReturn("operation");
    when(operationModel.getModelProperty(ExtensionOperationDescriptorModelProperty.class)).thenReturn(Optional.of(modelProperty));
    when(methodElement.getReturnType()).thenReturn(new TypeWrapper(String.class, typeLoader));
    visitableMock(operationModel);
}
Also used : ImmutableOutputModel(org.mule.runtime.extension.api.model.ImmutableOutputModel) ExtensionOperationDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionOperationDescriptorModelProperty) TypeWrapper(org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper) Before(org.junit.Before)

Example 3 with TypeWrapper

use of org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper in project mule by mulesoft.

the class ParameterGroupModelValidatorTestCase method skipEmptyGroupValidationInRuntimeMode.

@Test
public void skipEmptyGroupValidationInRuntimeMode() {
    when(extensionModel.getModelProperty(CompileTimeModelProperty.class)).thenReturn(empty());
    ParameterGroupDescriptor descriptor = new ParameterGroupDescriptor("name", new TypeWrapper(EmptyGroupPojo.class, typeLoader), null, mock(AnnotatedElement.class), null);
    when(groupModel.getModelProperty(ParameterGroupModelProperty.class)).thenReturn(of(new ParameterGroupModelProperty(descriptor)));
    validate(extensionModel, validator);
}
Also used : TypeWrapper(org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper) ParameterGroupDescriptor(org.mule.runtime.module.extension.internal.loader.ParameterGroupDescriptor) AnnotatedElement(java.lang.reflect.AnnotatedElement) ParameterGroupModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ParameterGroupModelProperty) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 4 with TypeWrapper

use of org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper in project mule by mulesoft.

the class SoapInvokeOperationDeclarer method declareMetadataKeyParameters.

/**
 * Given the Invoke Operation Declarer declares all the parameters that the operation has.
 *
 * @param operation the invoke operation declarer.
 */
private void declareMetadataKeyParameters(OperationDeclarer operation, ClassTypeLoader loader, ReflectionCache reflectionCache) {
    TypeWrapper keyType = new TypeWrapper(WebServiceTypeKey.class, loader);
    ParameterGroupDeclarer group = operation.onParameterGroup(KEYS_GROUP).withModelProperty(new ParameterGroupModelProperty(new ParameterGroupDescriptor(KEYS_GROUP, keyType)));
    StringType stringType = TYPE_BUILDER.stringType().build();
    group.withRequiredParameter(SERVICE_PARAM).withModelProperty(new DeclaringMemberModelProperty(getField(WebServiceTypeKey.class, SERVICE_PARAM, reflectionCache).get())).ofType(stringType).withModelProperty(new MetadataKeyPartModelProperty(1)).withLayout(getLayout(1));
    group.withRequiredParameter(OPERATION_PARAM).ofType(stringType).withModelProperty(new DeclaringMemberModelProperty(getField(WebServiceTypeKey.class, OPERATION_PARAM, reflectionCache).get())).withModelProperty(new MetadataKeyPartModelProperty(2)).withLayout(getLayout(2));
}
Also used : DeclaringMemberModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.DeclaringMemberModelProperty) TypeWrapper(org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper) StringType(org.mule.metadata.api.model.StringType) WebServiceTypeKey(org.mule.runtime.extension.api.soap.WebServiceTypeKey) ParameterGroupDescriptor(org.mule.runtime.module.extension.internal.loader.ParameterGroupDescriptor) ParameterGroupModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ParameterGroupModelProperty) MetadataKeyPartModelProperty(org.mule.runtime.extension.api.property.MetadataKeyPartModelProperty) ParameterGroupDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclarer)

Example 5 with TypeWrapper

use of org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper in project mule by mulesoft.

the class ClusterSupportEnricherTestCase method setSourceClass.

private void setSourceClass(Class<? extends Source> sourceClass) {
    ExtensionTypeDescriptorModelProperty property = new ExtensionTypeDescriptorModelProperty(new TypeWrapper(sourceClass, typeLoader));
    when(sourceDeclaration.getModelProperty(ExtensionTypeDescriptorModelProperty.class)).thenReturn(Optional.of(property));
}
Also used : TypeWrapper(org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper) ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty)

Aggregations

TypeWrapper (org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper)14 Test (org.junit.Test)10 SmallTest (org.mule.tck.size.SmallTest)10 TypeToken (com.google.common.reflect.TypeToken)6 ParameterGroupDescriptor (org.mule.runtime.module.extension.internal.loader.ParameterGroupDescriptor)5 ParameterGroupModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ParameterGroupModelProperty)4 AnnotatedElement (java.lang.reflect.AnnotatedElement)3 Before (org.junit.Before)2 StringType (org.mule.metadata.api.model.StringType)2 Result (org.mule.runtime.extension.api.runtime.operation.Result)2 HashMap (java.util.HashMap)1 AnyType (org.mule.metadata.api.model.AnyType)1 ArrayType (org.mule.metadata.api.model.ArrayType)1 MetadataType (org.mule.metadata.api.model.MetadataType)1 ObjectType (org.mule.metadata.api.model.ObjectType)1 VoidType (org.mule.metadata.api.model.VoidType)1 JavaTypeLoader (org.mule.metadata.java.api.JavaTypeLoader)1 MessageMetadataType (org.mule.metadata.message.api.MessageMetadataType)1 ParameterGroupDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.ParameterGroupDeclarer)1 CollectionDataType (org.mule.runtime.api.metadata.CollectionDataType)1