Search in sources :

Example 16 with ForestFastjsonConverter

use of com.dtflys.forest.converter.json.ForestFastjsonConverter in project forest by dromara.

the class TestForestFastjsonConverter method testSerializerFeature.

@Test
public void testSerializerFeature() {
    ForestFastjsonConverter forestFastjsonConverter = new ForestFastjsonConverter();
    String defaultSerializerFeatureName = forestFastjsonConverter.getSerializerFeatureName();
    SerializerFeature defaultSerializerFeature = forestFastjsonConverter.getSerializerFeature();
    assertEquals(SerializerFeature.DisableCircularReferenceDetect.name(), defaultSerializerFeatureName);
    assertEquals(defaultSerializerFeature.name(), defaultSerializerFeatureName);
    forestFastjsonConverter.setSerializerFeatureName(SerializerFeature.WriteClassName.name());
    assertEquals(SerializerFeature.WriteClassName.name(), forestFastjsonConverter.getSerializerFeatureName());
    assertEquals(SerializerFeature.WriteClassName, forestFastjsonConverter.getSerializerFeature());
    forestFastjsonConverter.setSerializerFeature(SerializerFeature.BeanToArray);
    assertEquals(SerializerFeature.BeanToArray.name(), forestFastjsonConverter.getSerializerFeatureName());
    assertEquals(SerializerFeature.BeanToArray, forestFastjsonConverter.getSerializerFeature());
}
Also used : ForestFastjsonConverter(com.dtflys.forest.converter.json.ForestFastjsonConverter) SerializerFeature(com.alibaba.fastjson.serializer.SerializerFeature) Test(org.junit.Test)

Aggregations

ForestFastjsonConverter (com.dtflys.forest.converter.json.ForestFastjsonConverter)16 Test (org.junit.Test)16 HashMap (java.util.HashMap)9 LinkedHashMap (java.util.LinkedHashMap)9 Map (java.util.Map)8 ForestRuntimeException (com.dtflys.forest.exceptions.ForestRuntimeException)3 TypeReference (com.alibaba.fastjson.TypeReference)2 ForestConverter (com.dtflys.forest.converter.ForestConverter)2 SubCoordinate (com.dtflys.test.model.SubCoordinate)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 SerializerFeature (com.alibaba.fastjson.serializer.SerializerFeature)1 ForestConfiguration (com.dtflys.forest.config.ForestConfiguration)1 DefaultAutoConverter (com.dtflys.forest.converter.auto.DefaultAutoConverter)1 ForestJacksonConverter (com.dtflys.forest.converter.json.ForestJacksonConverter)1 ForestJsonConverter (com.dtflys.forest.converter.json.ForestJsonConverter)1 ForestConvertException (com.dtflys.forest.exceptions.ForestConvertException)1 ForestFileNotFoundException (com.dtflys.forest.exceptions.ForestFileNotFoundException)1 ForestHandlerException (com.dtflys.forest.exceptions.ForestHandlerException)1 ForestInterceptorDefineException (com.dtflys.forest.exceptions.ForestInterceptorDefineException)1 ForestNetworkException (com.dtflys.forest.exceptions.ForestNetworkException)1