Search in sources :

Example 6 with TypeWrapper

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

the class IntrospectionUtilsTestCase method getPagingProviderImplementationTypes.

@Test
public void getPagingProviderImplementationTypes() {
    ResolvableType pagingProvider = ResolvableType.forClass(TestPagingProvider.class);
    Pair<Type, Type> pagingProviderTypes = getPagingProviderTypes(new TypeWrapper(pagingProvider, TYPE_LOADER));
    assertThat(pagingProviderTypes.getFirst().getDeclaringClass().get(), equalTo(Object.class));
    assertThat(pagingProviderTypes.getSecond().getDeclaringClass().get(), equalTo(Result.class));
}
Also used : IntrospectionUtils.getFieldMetadataType(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getFieldMetadataType) VoidType(org.mule.metadata.api.model.VoidType) Type(org.mule.runtime.module.extension.api.loader.java.type.Type) MapDataType(org.mule.runtime.api.metadata.MapDataType) ArrayType(org.mule.metadata.api.model.ArrayType) ResolvableType(org.springframework.core.ResolvableType) ObjectType(org.mule.metadata.api.model.ObjectType) StringType(org.mule.metadata.api.model.StringType) IntrospectionUtils.toDataType(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.toDataType) MetadataType(org.mule.metadata.api.model.MetadataType) AnyType(org.mule.metadata.api.model.AnyType) MessageMetadataType(org.mule.metadata.message.api.MessageMetadataType) DataType(org.mule.runtime.api.metadata.DataType) CollectionDataType(org.mule.runtime.api.metadata.CollectionDataType) ExtensionsTestUtils.assertMessageType(org.mule.test.module.extension.internal.util.ExtensionsTestUtils.assertMessageType) TypeWrapper(org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper) ResolvableType(org.springframework.core.ResolvableType) Result(org.mule.runtime.extension.api.runtime.operation.Result) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 7 with TypeWrapper

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

the class GroupValueSetterTestCase method before.

@Before
public void before() throws Exception {
    final String personalInfo = "personalInfo";
    ParameterGroupDescriptor group = new ParameterGroupDescriptor("group", new TypeWrapper(PersonalInfo.class, new JavaTypeLoader(Thread.currentThread().getContextClassLoader())), ExtensionsTypeLoaderFactory.getDefault().createTypeLoader().load(PersonalInfo.class), getField(HeisenbergExtension.class, personalInfo, reflectionCache).get(), null);
    Map<String, Object> resultMap = new HashMap<>();
    resultMap.put("name", NAME);
    resultMap.put("age", AGE);
    resultMap.put("dateOfBirth", DATE);
    when(result.asMap()).thenReturn(resultMap);
    valueSetter = new GroupValueSetter(group, () -> reflectionCache);
}
Also used : TypeWrapper(org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper) PersonalInfo(org.mule.test.heisenberg.extension.model.PersonalInfo) HashMap(java.util.HashMap) ParameterGroupDescriptor(org.mule.runtime.module.extension.internal.loader.ParameterGroupDescriptor) JavaTypeLoader(org.mule.metadata.java.api.JavaTypeLoader) Before(org.junit.Before)

Example 8 with TypeWrapper

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

the class OperationReturnTypeModelValidatorTestCase method resultWithGenerics.

@Test
public void resultWithGenerics() {
    when(methodElement.getReturnType()).thenReturn(new TypeWrapper(forType(new TypeToken<Result<?, ?>>() {
    }.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 9 with TypeWrapper

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

the class OperationReturnTypeModelValidatorTestCase method muleMessageReturnType.

@Test(expected = IllegalModelDefinitionException.class)
public void muleMessageReturnType() {
    when(methodElement.getReturnType()).thenReturn(new TypeWrapper(forType(new TypeToken<Message>() {
    }.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 10 with TypeWrapper

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

the class OperationReturnTypeModelValidatorTestCase method resultListWithoutGenerics.

@Test(expected = IllegalModelDefinitionException.class)
public void resultListWithoutGenerics() {
    when(methodElement.getReturnType()).thenReturn(new TypeWrapper(forType(new TypeToken<List<Result>>() {
    }.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) Result(org.mule.runtime.extension.api.runtime.operation.Result) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

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