Search in sources :

Example 11 with ClassInformationAnnotation

use of org.mule.metadata.java.api.annotation.ClassInformationAnnotation in project mule by mulesoft.

the class DynamicMetadataDeclarationEnricherTestCase method declareStaticAndDynamicTypesInSource.

@Test
public void declareStaticAndDynamicTypesInSource() {
    List<SourceDeclaration> messageSources = declaration.getConfigurations().get(0).getMessageSources();
    SourceDeclaration sourceDynamicAttributes = getDeclaration(messageSources, "MetadataSource");
    assertOutputType(sourceDynamicAttributes.getOutput(), TYPE_BUILDER.objectType().with(new ClassInformationAnnotation(Map.class, asList(String.class, Object.class))).openWith(TYPE_LOADER.load(Object.class)).build(), true);
    assertOutputType(sourceDynamicAttributes.getOutputAttributes(), toMetadataType(StringAttributes.class), false);
    assertParameterType(getDeclaration(sourceDynamicAttributes.getAllParameters(), "type"), toMetadataType(String.class));
    messageSources = declaration.getMessageSources();
    SourceDeclaration sourceStaticAttributes = getDeclaration(messageSources, "MetadataSourceWithMultilevel");
    assertOutputType(sourceStaticAttributes.getOutput(), TYPE_BUILDER.objectType().with(new ClassInformationAnnotation(Map.class, asList(String.class, Object.class))).openWith(TYPE_LOADER.load(Object.class)).build(), true);
    assertOutputType(sourceStaticAttributes.getOutputAttributes(), toMetadataType(StringAttributes.class), false);
    List<ParameterDeclaration> locationKey = sourceStaticAttributes.getAllParameters();
    assertParameterType(getDeclaration(locationKey, "continent"), toMetadataType(String.class));
    assertParameterType(getDeclaration(locationKey, "country"), toMetadataType(String.class));
    assertParameterType(getDeclaration(locationKey, "city"), toMetadataType(String.class));
}
Also used : StringAttributes(org.mule.tck.message.StringAttributes) ClassInformationAnnotation(org.mule.metadata.java.api.annotation.ClassInformationAnnotation) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) SourceDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.SourceDeclaration) Test(org.junit.Test)

Aggregations

ClassInformationAnnotation (org.mule.metadata.java.api.annotation.ClassInformationAnnotation)11 List (java.util.List)5 Map (java.util.Map)5 ArrayType (org.mule.metadata.api.model.ArrayType)5 Arrays.asList (java.util.Arrays.asList)4 Test (org.junit.Test)4 MetadataType (org.mule.metadata.api.model.MetadataType)4 ParameterDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 ImmutableList (com.google.common.collect.ImmutableList)2 IntrospectionException (java.beans.IntrospectionException)2 Introspector (java.beans.Introspector)2 PropertyDescriptor (java.beans.PropertyDescriptor)2 String.format (java.lang.String.format)2 Annotation (java.lang.annotation.Annotation)2 AccessibleObject (java.lang.reflect.AccessibleObject)2 AnnotatedElement (java.lang.reflect.AnnotatedElement)2 Field (java.lang.reflect.Field)2