use of org.mule.runtime.core.internal.metadata.DefaultCollectionDataType 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.core.internal.metadata.DefaultCollectionDataType 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.core.internal.metadata.DefaultCollectionDataType in project mule by mulesoft.
the class DefaultMuleMessageBuilderTestCase method createNewMessageCollectionViaMessageInterface.
@Test
public void createNewMessageCollectionViaMessageInterface() {
List<String> htmlStringList = new ArrayList<>();
htmlStringList.add("HTML1");
htmlStringList.add("HTML2");
htmlStringList.add("HTML3");
Message message = InternalMessage.builder().collectionValue(htmlStringList, String.class).itemMediaType(HTML).build();
assertThat(message.getPayload().getValue(), is(htmlStringList));
assertThat(message.getPayload().getDataType().getType(), equalTo(ArrayList.class));
assertThat(message.getPayload().getDataType().getMediaType(), is(ANY));
assertThat(message.getPayload().getDataType(), instanceOf(DefaultCollectionDataType.class));
assertThat(((DefaultCollectionDataType) message.getPayload().getDataType()).getItemDataType().getMediaType(), equalTo(HTML));
}
Aggregations