use of org.mule.metadata.message.api.MessageMetadataType in project mule by mulesoft.
the class MetadataOutputDelegate method adaptToListIfNecessary.
private MetadataType adaptToListIfNecessary(MetadataType resolvedType, Object key, MetadataContext metadataContext) throws MetadataResolvingException {
MetadataType componentOutputType = ((HasOutputModel) component).getOutput().getType();
if (!isCollection(componentOutputType) || isVoid(resolvedType) || isNullType(resolvedType)) {
return resolvedType;
}
MetadataType collectionValueType = ((ArrayType) componentOutputType).getType();
Class<?> collectionType = getCollectionType(collectionValueType);
if (Message.class.equals(collectionType)) {
MessageMetadataType message = (MessageMetadataType) collectionValueType;
resolvedType = wrapInMessageType(resolvedType, key, metadataContext, message.getAttributesType());
}
return metadataContext.getTypeBuilder().arrayType().with(new ClassInformationAnnotation(getCollectionType(componentOutputType))).of(resolvedType).build();
}
use of org.mule.metadata.message.api.MessageMetadataType in project mule by mulesoft.
the class ExtensionsTestUtils method assertMessageType.
public static void assertMessageType(MetadataType type, MetadataType payloadType, MetadataType attributesType) {
assertThat(type, is(instanceOf(MessageMetadataType.class)));
assertThat(getId(type).get(), is(Message.class.getName()));
MessageMetadataType messageType = (MessageMetadataType) type;
assertThat(messageType.getPayloadType().get(), equalTo(payloadType));
assertThat(messageType.getAttributesType().get(), equalTo(attributesType));
}
use of org.mule.metadata.message.api.MessageMetadataType in project mule by mulesoft.
the class ExtensionsTestUtils method assertMessageType.
public static void assertMessageType(MetadataType type, Matcher payloadMatch, Matcher attributesMatcher) {
assertThat(type, is(instanceOf(MessageMetadataType.class)));
assertThat(getId(type).get(), is(Message.class.getName()));
MessageMetadataType messageType = (MessageMetadataType) type;
assertThat(messageType.getPayloadType().get(), payloadMatch);
assertThat(messageType.getAttributesType().get(), attributesMatcher);
}
use of org.mule.metadata.message.api.MessageMetadataType in project mule by mulesoft.
the class IntrospectionUtilsTestCase method getPagingProviderImplementationTypesReturnType.
@Test
public void getPagingProviderImplementationTypesReturnType() throws Exception {
OperationElement getPagingProvider = getMethod("getPagingProvider");
MetadataType methodReturnType = IntrospectionUtils.getMethodReturnType(getPagingProvider);
assertThat(methodReturnType, instanceOf(ArrayType.class));
MetadataType valueType = ((ArrayType) methodReturnType).getType();
assertThat(valueType, instanceOf(MessageMetadataType.class));
MessageMetadataType messageType = (MessageMetadataType) valueType;
MetadataType payloadType = messageType.getPayloadType().get();
MetadataType attributesTypes = messageType.getAttributesType().get();
// These assertions are too simple, but AST Loader doesn't enrich with the same annotations as the Java does
// making impossible to do an equals assertion.
assertThat(payloadType.getAnnotation(TypeIdAnnotation.class).get().getValue(), is(Banana.class.getName()));
assertThat(attributesTypes.getAnnotation(TypeIdAnnotation.class).get().getValue(), is(Apple.class.getName()));
}
Aggregations