use of com.dtflys.forest.converter.json.ForestFastjsonConverter in project forest by dromara.
the class TestFastjsonConverter method testConfig.
@Test
public void testConfig() {
ForestJsonConverter jsonConverter = forestConfiguration.getJsonConverter();
assertThat(jsonConverter).isNotNull().isInstanceOf(ForestFastjsonConverter.class);
ForestFastjsonConverter forestFastjsonConverter = (ForestFastjsonConverter) jsonConverter;
assertThat(forestFastjsonConverter.getDateFormat()).isEqualTo("yyyy/MM/dd hh:mm:ss");
}
use of com.dtflys.forest.converter.json.ForestFastjsonConverter in project forest by dromara.
the class TestForestConfiguration method testConverterMap.
@Test
public void testConverterMap() {
ForestConfiguration configuration = ForestConfiguration.createConfiguration();
assertNotNull(configuration.getConverterMap());
Map<ForestDataType, ForestConverter> converterMap = new HashMap<>();
converterMap.put(ForestDataType.JSON, new ForestFastjsonConverter());
configuration.setConverterMap(converterMap);
assertEquals(converterMap, configuration.getConverterMap());
}
use of com.dtflys.forest.converter.json.ForestFastjsonConverter in project forest by dromara.
the class TestForestFastjsonConverter method testConvertToMap.
@Test
public void testConvertToMap() {
TestObj testObj = new TestObj();
testObj.setId(1);
testObj.setBody("xxx");
testObj.setCrc(new Byte("1"));
testObj.setDirection(4);
testObj.setType("yyy");
ForestFastjsonConverter forestFastjsonConverter = new ForestFastjsonConverter();
Map<String, Object> map = forestFastjsonConverter.convertObjectToMap(testObj);
assertEquals("{\"id\":1,\"direction\":4,\"type\":\"yyy\",\"body\":\"xxx\",\"crc\":1}", JSON.toJSONString(map));
}
use of com.dtflys.forest.converter.json.ForestFastjsonConverter in project forest by dromara.
the class TestForestFastjsonConverter method testConvertToJsonError.
@Test
public void testConvertToJsonError() {
ForestFastjsonConverter forestFastjsonConverter = new ForestFastjsonConverter();
Map map = new HashMap();
map.put("ref", map);
boolean error = false;
try {
forestFastjsonConverter.encodeToString(map);
} catch (ForestRuntimeException e) {
error = true;
assertNotNull(e.getCause());
}
assertTrue(error);
}
use of com.dtflys.forest.converter.json.ForestFastjsonConverter in project forest by dromara.
the class TestForestFastjsonConverter method testJavaObjectToMap.
@Test
public void testJavaObjectToMap() {
Coordinate coordinate = new Coordinate("11.11111", "22.22222");
ForestFastjsonConverter forestFastjsonConverter = new ForestFastjsonConverter();
Map map = forestFastjsonConverter.convertObjectToMap(coordinate);
assertNotNull(map);
assertEquals("11.11111", map.get("longitude"));
assertEquals("22.22222", map.get("latitude"));
}
Aggregations