use of org.mule.runtime.api.metadata.DataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method buildCollection.
@Test
public void buildCollection() {
final DataType dataType = DataType.fromType(Set.class);
assertThat(dataType, instanceOf(DefaultCollectionDataType.class));
assertThat(dataType.getType(), is(equalTo(Set.class)));
assertThat(((DefaultCollectionDataType) dataType).getItemDataType(), is(OBJECT));
}
use of org.mule.runtime.api.metadata.DataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method cglibSpyProxy.
@Test
public void cglibSpyProxy() {
final Message muleMessageProxy = spy(new MessageTestImpl());
final DataType dataType = DataType.fromObject(muleMessageProxy);
assertThat(dataType.getType(), is(equalTo(MessageTestImpl.class)));
}
use of org.mule.runtime.api.metadata.DataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method templateTypedCollection.
@Test
public void templateTypedCollection() {
final DataType template = DataType.builder().collectionType(List.class).itemType(String.class).itemMediaType("application/json;charset=UTF-8").mediaType("text/plain;charset=ASCII").build();
final DataType dataType = DataType.builder(template).build();
assertThat(dataType, instanceOf(DefaultCollectionDataType.class));
assertThat(dataType.getType(), is(equalTo(List.class)));
assertThat(((DefaultCollectionDataType) dataType).getItemDataType(), is(assignableTo(STRING)));
assertThat(((DefaultCollectionDataType) dataType).getItemDataType().getMediaType().getPrimaryType(), is("application"));
assertThat(((DefaultCollectionDataType) dataType).getItemDataType().getMediaType().getSubType(), is("json"));
assertThat(((DefaultCollectionDataType) dataType).getItemDataType().getMediaType().getCharset().get(), is(UTF_8));
assertThat(dataType.getMediaType().getPrimaryType(), is("text"));
assertThat(dataType.getMediaType().getSubType(), is("plain"));
assertThat(dataType.getMediaType().getCharset().get(), is(US_ASCII));
}
use of org.mule.runtime.api.metadata.DataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method mimeTypeWithEncoding.
@Test
public void mimeTypeWithEncoding() {
final DataType dataType = DataType.builder().mediaType("text/plain;charset=ASCII").build();
assertThat(dataType.getMediaType().getPrimaryType(), is("text"));
assertThat(dataType.getMediaType().getSubType(), is("plain"));
assertThat(dataType.getMediaType().getCharset().get(), is(US_ASCII));
}
use of org.mule.runtime.api.metadata.DataType in project mule by mulesoft.
the class DataTypeFactoryTestCase method createsDataTypeForNullPayload.
@Test
public void createsDataTypeForNullPayload() throws Exception {
DataType dataType = DataType.fromObject(null);
assertThat(dataType, like(Object.class, MediaType.ANY, null));
}
Aggregations