use of org.mule.runtime.core.internal.metadata.DefaultMapDataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method templateTypedMap.
@Test
public void templateTypedMap() {
final DataType template = DataType.builder().mapType(HashMap.class).keyType(String.class).keyMediaType("text/plain;charset=UTF-8").valueType(Number.class).valueMediaType("application/json;charset=ISO-8859-1").mediaType("text/plain;charset=ASCII").build();
final DataType dataType = DataType.builder(template).build();
assertThat(dataType, instanceOf(DefaultMapDataType.class));
assertThat(dataType.getType(), is(equalTo(HashMap.class)));
assertThat(((DefaultMapDataType) dataType).getKeyDataType(), is(assignableTo(TEXT_STRING)));
assertThat(((DefaultMapDataType) dataType).getKeyDataType().getMediaType().getPrimaryType(), is("text"));
assertThat(((DefaultMapDataType) dataType).getKeyDataType().getMediaType().getSubType(), is("plain"));
assertThat(((DefaultMapDataType) dataType).getKeyDataType().getMediaType().getCharset().get(), is(UTF_8));
assertThat(((DefaultMapDataType) dataType).getValueDataType(), is(assignableTo((NUMBER))));
assertThat(((DefaultMapDataType) dataType).getValueDataType().getMediaType().getPrimaryType(), is("application"));
assertThat(((DefaultMapDataType) dataType).getValueDataType().getMediaType().getSubType(), is("json"));
assertThat(((DefaultMapDataType) dataType).getValueDataType().getMediaType().getCharset().get(), is(ISO_8859_1));
}
use of org.mule.runtime.core.internal.metadata.DefaultMapDataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method buildMap.
@Test
public void buildMap() {
final DataType dataType = DataType.fromType(HashMap.class);
assertThat(dataType, instanceOf(DefaultMapDataType.class));
assertThat(dataType.getType(), is(equalTo(HashMap.class)));
assertThat(((DefaultMapDataType) dataType).getKeyDataType(), is(OBJECT));
assertThat(((DefaultMapDataType) dataType).getValueDataType(), is(OBJECT));
}
use of org.mule.runtime.core.internal.metadata.DefaultMapDataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method buildTypedMapFromImplementationClass.
@Test
public void buildTypedMapFromImplementationClass() {
final DataType dataType = DataType.builder().mapType(SpecificMap.class).build();
assertThat(dataType, instanceOf(DefaultMapDataType.class));
assertThat(dataType.getType(), is(equalTo(SpecificMap.class)));
assertThat(((DefaultMapDataType) dataType).getKeyDataType(), is(STRING));
assertThat(((DefaultMapDataType) dataType).getValueDataType(), is(NUMBER));
}
use of org.mule.runtime.core.internal.metadata.DefaultMapDataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method buildTypedMap.
@Test
public void buildTypedMap() {
final DataType dataType = DataType.builder().mapType(HashMap.class).keyType(Number.class).keyMediaType(APPLICATION_JAVA).valueType(String.class).valueMediaType(APPLICATION_JSON).build();
assertThat(dataType, instanceOf(DefaultMapDataType.class));
assertThat(dataType.getType(), is(equalTo(HashMap.class)));
DataType keyDataType = ((DefaultMapDataType) dataType).getKeyDataType();
assertThat(keyDataType.getType(), equalTo(Number.class));
assertThat(keyDataType.getMediaType(), is(APPLICATION_JAVA));
DataType valueDataType = ((DefaultMapDataType) dataType).getValueDataType();
assertThat(valueDataType.getType(), equalTo(String.class));
assertThat(valueDataType.getMediaType(), is(APPLICATION_JSON));
}
use of org.mule.runtime.core.internal.metadata.DefaultMapDataType in project mule by mulesoft.
the class DataTypeBuilderTestCase method templateMap.
@Test
public void templateMap() {
final DataType template = DataType.builder().type(HashMap.class).mediaType("text/plain;charset=ASCII").build();
final DataType dataType = DataType.builder(template).build();
assertThat(dataType, instanceOf(DefaultMapDataType.class));
assertThat(dataType.getType(), is(equalTo(HashMap.class)));
assertThat(((DefaultMapDataType) dataType).getKeyDataType(), is(OBJECT));
assertThat(((DefaultMapDataType) dataType).getValueDataType(), is(OBJECT));
assertThat(dataType.getMediaType().getPrimaryType(), is("text"));
assertThat(dataType.getMediaType().getSubType(), is("plain"));
assertThat(dataType.getMediaType().getCharset().get(), is(US_ASCII));
}
Aggregations