use of org.mule.runtime.core.internal.metadata.DefaultCollectionDataType in project mule by mulesoft.
the class DefaultMuleMessageBuilderTestCase method createNewMessageCollectionViaMessageInterfaceCopy.
@Test
public void createNewMessageCollectionViaMessageInterfaceCopy() {
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();
Message copy = InternalMessage.builder(message).build();
assertThat(copy.getPayload().getValue(), is(htmlStringList));
assertThat(copy.getPayload().getDataType().getType(), equalTo(ArrayList.class));
assertThat(copy.getPayload().getDataType().getMediaType(), is(ANY));
assertThat(copy.getPayload().getDataType(), instanceOf(DefaultCollectionDataType.class));
assertThat(((DefaultCollectionDataType) copy.getPayload().getDataType()).getItemDataType().getMediaType(), equalTo(HTML));
}
use of org.mule.runtime.core.internal.metadata.DefaultCollectionDataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method templateCollection.
@Test
public void templateCollection() {
final DataType template = DataType.builder().type(Set.class).mediaType("text/plain;charset=ASCII").build();
final DataType dataType = DataType.builder(template).build();
assertThat(dataType, instanceOf(DefaultCollectionDataType.class));
assertThat(dataType.getType(), is(equalTo(Set.class)));
assertThat(((DefaultCollectionDataType) dataType).getItemDataType(), is(OBJECT));
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 DataTypeBuilderTestCase method buildTypedCollectionFromImplementationClass.
@Test
public void buildTypedCollectionFromImplementationClass() {
final DataType dataType = DataType.builder().collectionType(SpecificCollection.class).build();
assertThat(dataType, instanceOf(DefaultCollectionDataType.class));
assertThat(dataType.getType(), is(equalTo(SpecificCollection.class)));
assertThat(((DefaultCollectionDataType) dataType).getItemDataType(), is(STRING));
}
use of org.mule.runtime.core.internal.metadata.DefaultCollectionDataType in project mule by mulesoft.
the class DataTypeFactoryTestCase method createsDataTypeForNonCollection.
@Test
public void createsDataTypeForNonCollection() {
final DataType dataType = DataType.builder().collectionType(List.class).itemType(type).itemMediaType(mimeType).build();
assertThat(dataType.getType(), equalTo(List.class));
assertThat(dataType, instanceOf(DefaultCollectionDataType.class));
final DataType itemDataType = ((DefaultCollectionDataType) dataType).getItemDataType();
assertThat(itemDataType.getType(), equalTo(type));
assertThat(itemDataType.getMediaType().getPrimaryType(), is(mimeType.split("/")[0]));
assertThat(itemDataType.getMediaType().getSubType(), is(mimeType.split("/")[1]));
}
use of org.mule.runtime.core.internal.metadata.DefaultCollectionDataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method buildTypedCollection.
@Test
public void buildTypedCollection() {
final DataType dataType = DataType.builder().collectionType(List.class).itemType(String.class).itemMediaType(APPLICATION_JSON).build();
assertThat(dataType, instanceOf(DefaultCollectionDataType.class));
assertThat(dataType.getType(), is(equalTo(List.class)));
DataType itemDataType = ((DefaultCollectionDataType) dataType).getItemDataType();
assertThat(itemDataType.getType(), equalTo(String.class));
assertThat(itemDataType.getMediaType(), is(APPLICATION_JSON));
}
Aggregations