use of org.mule.runtime.api.metadata.MapDataType 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.runtime.api.metadata.MapDataType in project mule by mulesoft.
the class OperationMessageProcessorTestCase method operationReturnsResultMapWithCorrectDataType.
@Test
public void operationReturnsResultMapWithCorrectDataType() throws Exception {
Object payload = new HashMap<>();
setUpOperationReturning(Result.builder().output(payload).build(), new TypeToken<Map<String, String>>() {
}.getType());
Message message = messageProcessor.process(event).getMessage();
assertThat(message, is(notNullValue()));
assertThat(message.getPayload().getValue(), is(sameInstance(payload)));
DataType dataType = message.getPayload().getDataType();
assertThat(dataType, instanceOf(MapDataType.class));
assertThat(((MapDataType) dataType).getKeyDataType(), like(String.class, ANY.withCharset(null)));
assertThat(((MapDataType) dataType).getValueDataType(), like(String.class, ANY));
}
use of org.mule.runtime.api.metadata.MapDataType in project mule by mulesoft.
the class OperationMessageProcessorTestCase method operationReturnsMapWithCorrectDataType.
@Test
public void operationReturnsMapWithCorrectDataType() throws Exception {
Object payload = new HashMap<>();
setUpOperationReturning(payload, new TypeToken<Map<String, String>>() {
}.getType());
Message message = messageProcessor.process(event).getMessage();
assertThat(message, is(notNullValue()));
assertThat(message.getPayload().getValue(), is(sameInstance(payload)));
DataType dataType = message.getPayload().getDataType();
assertThat(dataType, instanceOf(MapDataType.class));
assertThat(((MapDataType) dataType).getKeyDataType(), like(String.class, ANY.withCharset(null)));
assertThat(((MapDataType) dataType).getValueDataType(), like(String.class, ANY));
}
Aggregations