use of org.mule.metadata.api.builder.ObjectTypeBuilder in project mule by mulesoft.
the class IntrospectionUtilsTestCase method getDataTypeFromMap.
@Test
public void getDataTypeFromMap() {
Class<Date> dateClass = Date.class;
Class<Map> mapClass = Map.class;
ObjectTypeBuilder objectTypeBuilder = BaseTypeBuilder.create(JAVA).objectType().with(new ClassInformationAnnotation(Map.class));
objectTypeBuilder.openWith().objectType().id(dateClass.getName());
MapDataType dataType = (MapDataType) toDataType(objectTypeBuilder.build());
assertThat(dataType.getType(), is(equalTo(mapClass)));
assertThat(dataType.getKeyDataType().getType(), is(equalTo(String.class)));
assertThat(dataType.getValueDataType().getType(), is(equalTo(dateClass)));
}
use of org.mule.metadata.api.builder.ObjectTypeBuilder in project mule by mulesoft.
the class NativeQueryOutputResolver method getOutputType.
@Override
public MetadataType getOutputType(MetadataContext context, String key) throws MetadataResolvingException, ConnectionException {
if (!key.equals(NATIVE_QUERY)) {
throw new IllegalArgumentException("Native Query Key was not the expected one");
}
final ObjectTypeBuilder objectType = context.getTypeBuilder().objectType();
objectType.addField().key("id").value().numberType();
return objectType.build();
}
use of org.mule.metadata.api.builder.ObjectTypeBuilder in project mule by mulesoft.
the class JsonInputStaticTypeResolver method getStaticMetadata.
@Override
public MetadataType getStaticMetadata() {
ObjectTypeBuilder object = BaseTypeBuilder.create(MetadataFormat.JSON).objectType();
object.id("json-object");
object.addField().key("name").value().stringType();
object.addField().key("last-name").value().stringType();
return object.build();
}
use of org.mule.metadata.api.builder.ObjectTypeBuilder in project mule by mulesoft.
the class TestOutputAttributesResolverWithKeyResolver method getAttributesType.
@Override
public MetadataType getAttributesType(MetadataContext context, String key) throws MetadataResolvingException, ConnectionException {
ObjectTypeBuilder builder = BaseTypeBuilder.create(JAVA).objectType();
builder.openWith().stringType();
return builder.build();
}
use of org.mule.metadata.api.builder.ObjectTypeBuilder in project mule by mulesoft.
the class TestMetadataResolverUtils method getMetadata.
public static MetadataType getMetadata(String key) throws MetadataResolvingException {
final ObjectTypeBuilder objectBuilder = BaseTypeBuilder.create(JAVA).objectType();
switch(key) {
case MetadataConnection.CAR:
objectBuilder.addField().key(TIRES).value().numberType();
objectBuilder.addField().key(BRAND).value().stringType();
break;
case MetadataConnection.HOUSE:
objectBuilder.addField().key(DIRECTION).value().stringType();
objectBuilder.addField().key(SIZE).value().numberType();
break;
case MetadataConnection.PERSON:
objectBuilder.addField().key(NAME).value().stringType();
objectBuilder.addField().key(AGE).value().numberType();
break;
case MetadataConnection.NULL:
return BaseTypeBuilder.create(JAVA).nullType().build();
case MetadataConnection.VOID:
return BaseTypeBuilder.create(JAVA).voidType().build();
default:
throw new MetadataResolvingException("Unknown key " + key, INVALID_METADATA_KEY);
}
return objectBuilder.build();
}
Aggregations