com.fasterxml.jackson.databind.type.SimpleType Java Examples

The following examples show how to use com.fasterxml.jackson.databind.type.SimpleType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapDeserializerManager.java    From caravan with Apache License 2.0 6 votes vote down vote up
public MapDeserializerManager(MapCustomizationFactory factory) {
  /**
   * The first parameter is just a placeholder, won't be used.
   * So any element type is ok.
   */
  super(
      CollectionType.construct(ArrayList.class, null, null, null, //
          SimpleType.constructUnsafe(Object.class)), //
      null, null, new ValueInstantiator() {
        @SuppressWarnings("rawtypes")
        @Override
        public Object createUsingDefault(DeserializationContext ctxt) throws IOException {
          return new ArrayList();
        }
      });

  this.factory = factory;
}
 
Example #2
Source File: MessagingTest.java    From joynr with Apache License 2.0 6 votes vote down vote up
private ObjectMapper getObjectMapper() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
    // objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS,
    // true);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    TypeResolverBuilder<?> joynrTypeResolverBuilder = objectMapper.getSerializationConfig()
                                                                  .getDefaultTyper(SimpleType.construct(Object.class));

    return objectMapper;
}
 
Example #3
Source File: Jackson2ObjectMapperBuilderTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test  // gh-22740
public void registerMultipleModulesWithNullTypeId() {
	Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
	SimpleModule fooModule = new SimpleModule();
	fooModule.addSerializer(new FooSerializer());
	SimpleModule barModule = new SimpleModule();
	barModule.addSerializer(new BarSerializer());
	builder.modulesToInstall(fooModule, barModule);
	ObjectMapper objectMapper = builder.build();
	assertEquals(1, StreamSupport
			.stream(getSerializerFactoryConfig(objectMapper).serializers().spliterator(), false)
			.filter(s -> s.findSerializer(null, SimpleType.construct(Foo.class), null) != null)
			.count());
	assertEquals(1, StreamSupport
			.stream(getSerializerFactoryConfig(objectMapper).serializers().spliterator(), false)
			.filter(s -> s.findSerializer(null, SimpleType.construct(Bar.class), null) != null)
			.count());
}
 
Example #4
Source File: AbstractBounceProxyServerTest.java    From joynr with Apache License 2.0 6 votes vote down vote up
private ObjectMapper getObjectMapper() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
    // objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS,
    // true);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    TypeResolverBuilder<?> joynrTypeResolverBuilder = objectMapper.getSerializationConfig()
                                                                  .getDefaultTyper(SimpleType.construct(Object.class));

    SimpleModule module = new SimpleModule("NonTypedModule", new Version(1, 0, 0, "", "", ""));
    module.addSerializer(new JoynrEnumSerializer());
    module.addSerializer(new JoynrListSerializer());

    TypeDeserializer typeDeserializer = joynrTypeResolverBuilder.buildTypeDeserializer(objectMapper.getDeserializationConfig(),
                                                                                       SimpleType.construct(Object.class),
                                                                                       null);

    module.addDeserializer(Object.class, new JoynrUntypedObjectDeserializer(typeDeserializer));
    objectMapper.registerModule(module);
    return objectMapper;
}
 
Example #5
Source File: CustomMessageElementVisitor.java    From caravan with Apache License 2.0 6 votes vote down vote up
protected FieldElement buildFieldElement(BeanProperty writer, Label label) throws JsonMappingException {
  FieldElement.Builder fBuilder = FieldElement.builder();

  fBuilder.name(writer.getName());
  fBuilder.tag(nextTag(writer));

  JavaType type = writer.getType();

  if (type.isArrayType() && type.getContentType().getRawClass() == byte.class) {
    fBuilder.label(label);
    fBuilder.type(ScalarType.BYTES);
  } else if (type.isArrayType() || type.isCollectionLikeType()) {
    fBuilder.label(Label.REPEATED);
    fBuilder.type(getDataType(type.getContentType()));
  } else if (type instanceof MapType) {
    Class<?> wrapperClass = DynamicClassFactory.INSTANCE.fetchOrCreatePairClass((MapType) type);

    fBuilder.label(Label.REPEATED);
    fBuilder.type(getDataType(SimpleType.constructUnsafe(wrapperClass)));
  } else {
    fBuilder.label(label);
    fBuilder.type(getDataType(type));
  }
  return fBuilder.build();
}
 
Example #6
Source File: VaadinConnectControllerTest.java    From flow with Apache License 2.0 6 votes vote down vote up
@Test
public void should_ThrowException_When_MapperFailsToSerializeEverything()
        throws Exception {
    ObjectMapper mapperMock = mock(ObjectMapper.class);
    TypeFactory typeFactory = mock(TypeFactory.class);
    when(mapperMock.getTypeFactory()).thenReturn(typeFactory);
    when(typeFactory.constructType(int.class))
            .thenReturn(SimpleType.constructUnsafe(int.class));
    when(mapperMock.readerFor(SimpleType.constructUnsafe(int.class)))
            .thenReturn(new ObjectMapper()
                    .readerFor(SimpleType.constructUnsafe(int.class)));
    when(mapperMock.writeValueAsString(Mockito.isNotNull()))
            .thenThrow(new JsonMappingException(null, "sss"));

    exception.expect(IllegalStateException.class);
    exception.expectMessage("Unexpected");
    createVaadinController(TEST_ENDPOINT, mapperMock).serveEndpoint(
            TEST_ENDPOINT_NAME, TEST_METHOD.getName(),
            createRequestParameters("{\"value\": 222}"), requestMock);
}
 
Example #7
Source File: SwaggerModelConverter.java    From Web-API with MIT License 5 votes vote down vote up
@Override
public Model resolve(Type type, ModelConverterContext context, Iterator<ModelConverter> chain) {
    if (chain.hasNext()) {
        Class c = null;
        if (type instanceof SimpleType) {
            c = ((SimpleType) type).getRawClass();
        } else if (type instanceof Class) {
            c = (Class) type;
        }

        if (c != null) {
            // Process @JsonValue annotation on field first if we have any
            Optional<Field> optField = Arrays.stream(c.getFields())
                    .filter(f -> f.getAnnotation(JsonValue.class) != null)
                    .findAny();
            if (optField.isPresent()) {
                return resolve(optField.get().getGenericType(), context, chain);
            }

            // Process @JsonValue annotation on method first if we have any
            Optional<Method> optMethod = Arrays.stream(c.getMethods())
                    .filter(m -> m.getAnnotation(JsonValue.class) != null)
                    .findAny();
            if (optMethod.isPresent()) {
                return resolve(optMethod.get().getGenericReturnType(), context, chain);
            }

            // If we can find a cache/view object for this type, then use that for documentation,
            // because we can't annotate Sponge classes with @Swagger stuff
            Optional<Type> optClass = WebAPI.getSerializeService().getViewFor(c);
            if (optClass.isPresent()) {
                return resolve(optClass.get(), context, chain);
            }
        }
        return chain.next().resolve(type, context, chain);
    } else {
        return null;
    }
}
 
Example #8
Source File: Jackson2ObjectMapperBuilderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void modules() {
	NumberSerializer serializer1 = new NumberSerializer(Integer.class);
	SimpleModule module = new SimpleModule();
	module.addSerializer(Integer.class, serializer1);
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().modules(module).build();
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer1, serializers.findSerializer(null, SimpleType.construct(Integer.class), null));
}
 
Example #9
Source File: Jackson2ObjectMapperBuilderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void modulesToInstallByClass() {
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().modulesToInstall(CustomIntegerModule.class).build();
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(CustomIntegerSerializer.class, serializers.findSerializer(null, SimpleType.construct(Integer.class), null).getClass());
}
 
Example #10
Source File: Jackson2ObjectMapperBuilderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void serializerByType() {
	JsonSerializer<Number> serializer = new NumberSerializer(Integer.class);
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
			.modules(new ArrayList<>())  // Disable well-known modules detection
			.serializerByType(Boolean.class, serializer).build();
	assertTrue(getSerializerFactoryConfig(objectMapper).hasSerializers());
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer, serializers.findSerializer(null, SimpleType.construct(Boolean.class), null));
}
 
Example #11
Source File: Jackson2ObjectMapperBuilderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void deserializerByType() throws JsonMappingException {
	JsonDeserializer<Date> deserializer = new DateDeserializers.DateDeserializer();
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
			.modules(new ArrayList<>())  // Disable well-known modules detection
			.deserializerByType(Date.class, deserializer).build();
	assertTrue(getDeserializerFactoryConfig(objectMapper).hasDeserializers());
	Deserializers deserializers = getDeserializerFactoryConfig(objectMapper).deserializers().iterator().next();
	assertSame(deserializer, deserializers.findBeanDeserializer(SimpleType.construct(Date.class), null, null));
}
 
Example #12
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void setModules() {
	NumberSerializer serializer = new NumberSerializer(Integer.class);
	SimpleModule module = new SimpleModule();
	module.addSerializer(Integer.class, serializer);

	this.factory.setModules(Arrays.asList(new Module[]{module}));
	this.factory.afterPropertiesSet();
	ObjectMapper objectMapper = this.factory.getObject();

	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer, serializers.findSerializer(null, SimpleType.construct(Integer.class), null));
}
 
Example #13
Source File: LazyJsonModule.java    From emodb with Apache License 2.0 5 votes vote down vote up
@Override
public void setupModule(SetupContext context) {
    // Modify the Map serializer to the delegate if it matches Map<String, ?>
    context.addBeanSerializerModifier(new BeanSerializerModifier() {
        @Override
        public JsonSerializer<?> modifyMapSerializer(SerializationConfig config, MapType valueType, BeanDescription beanDesc,
                                                     JsonSerializer<?> serializer) {
            if (valueType.getKeyType().equals(SimpleType.construct(String.class))) {
                return new DelegatingMapSerializer(serializer);
            }
            return serializer;
        }
    });
}
 
Example #14
Source File: SwaggerAnnotationsReader.java    From mdw with Apache License 2.0 5 votes vote down vote up
private SwaggerAnnotationsReader(Swagger swagger) {
    this.swagger = swagger;
    ModelConverters.getInstance().addConverter(new SwaggerModelConverter() {
        protected boolean shouldIgnoreClass(Type type) {
            if (type instanceof SimpleType && JSONObject.class.equals(((SimpleType)type).getRawClass())) {
                return true;
            }
            return super.shouldIgnoreClass(type);
        }
    });
}
 
Example #15
Source File: Jackson2ObjectMapperBuilderTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void modulesToInstallByClass() {
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
			.modulesToInstall(CustomIntegerModule.class)
			.build();
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(CustomIntegerSerializer.class,
			serializers.findSerializer(null, SimpleType.construct(Integer.class), null).getClass());
}
 
Example #16
Source File: MonetaryAmountSerializerTest.java    From jackson-datatype-money with MIT License 5 votes vote down vote up
@Test
void shouldHandleNullValueFromExpectObjectFormatInSchemaVisitor() throws Exception {
    final MonetaryAmountSerializer unit = new MonetaryAmountSerializer(FieldNames.defaults(),
            new DecimalAmountWriter(), MonetaryAmountFormatFactory.NONE);

    final JsonFormatVisitorWrapper wrapper = mock(JsonFormatVisitorWrapper.class);
    unit.acceptJsonFormatVisitor(wrapper, SimpleType.constructUnsafe(MonetaryAmount.class));
}
 
Example #17
Source File: NsTypeIdResolver.java    From components with Apache License 2.0 5 votes vote down vote up
@Override
public JavaType typeFromId(DatabindContext context, String id) {
    Class<?> clazz = basicMetaData.getTypeClass(id);
    if (clazz == null) {
        return null;
    }
    JavaType javaType = SimpleType.construct(clazz);
    return javaType;
}
 
Example #18
Source File: NodeTypeResolver.java    From depgraph-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public JavaType typeFromId(DatabindContext context, String id) {
  try {
    return SimpleType.constructUnsafe(Class.forName(getClass().getPackage().getName() + "." + id.substring(0, 1).toUpperCase() + id.substring(1)));
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
}
 
Example #19
Source File: JSONBindingFactoryTest.java    From cougar with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testByteConversion() {
    ObjectMapper mapper = new JSONBindingFactory().createBaseObjectMapper();
    JsonNode paramValue = new IntNode(128);
    JavaType javaType = SimpleType.construct(byte.class);
    mapper.convertValue(paramValue, javaType);
}
 
Example #20
Source File: JsonMessageSerializerModule.java    From joynr with Apache License 2.0 5 votes vote down vote up
public JsonMessageSerializerModule() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
    objectMapper.configure(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY, true);
    // objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    TypeResolverBuilder<?> joynrTypeResolverBuilder = objectMapper.getSerializationConfig()
                                                                  .getDefaultTyper(SimpleType.construct(Object.class));

    SimpleModule module = new SimpleModule("NonTypedModule", new Version(1, 0, 0, "", "", ""));
    module.addSerializer(new JoynrEnumSerializer());
    module.addSerializer(new JoynrListSerializer());
    module.addSerializer(new JoynrArraySerializer());

    TypeDeserializer typeDeserializer = joynrTypeResolverBuilder.buildTypeDeserializer(objectMapper.getDeserializationConfig(),
                                                                                       SimpleType.construct(Object.class),
                                                                                       null);

    module.addDeserializer(Request.class, new RequestDeserializer(objectMapper));
    module.addDeserializer(OneWayRequest.class, new OneWayRequestDeserializer(objectMapper));
    module.addDeserializer(Object.class, new JoynrUntypedObjectDeserializer(typeDeserializer));

    module.setMixInAnnotation(Throwable.class, ThrowableMixIn.class);
    objectMapper.registerModule(module);
}
 
Example #21
Source File: TestDefaultHttpClientFilter.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void testAfterReceiveResponseNullProduceProcessor(@Mocked Invocation invocation,
    @Mocked HttpServletResponseEx responseEx,
    @Mocked OperationMeta operationMeta,
    @Mocked RestOperationMeta swaggerRestOperation) throws Exception {
  CommonExceptionData data = new CommonExceptionData("abcd");
  new Expectations() {
    {
      invocation.getOperationMeta();
      result = operationMeta;
      operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION);
      result = swaggerRestOperation;
      invocation.findResponseType(403);
      result = SimpleType.constructUnsafe(CommonExceptionData.class);
      responseEx.getStatus();
      result = 403;
      responseEx.getStatusType();
      result = Status.FORBIDDEN;
      responseEx.getBodyBuffer();
      result = Buffer.buffer(JsonUtils.writeValueAsString(data).getBytes());
    }
  };

  Response response = filter.afterReceiveResponse(invocation, responseEx);
  Assert.assertEquals(403, response.getStatusCode());
  Assert.assertEquals("Forbidden", response.getReasonPhrase());
  Assert.assertEquals(InvocationException.class, response.<InvocationException>getResult().getClass());
  InvocationException invocationException = response.getResult();
  Assert.assertEquals(
      403,
      invocationException.getStatusCode());
  Assert.assertEquals(
      "CommonExceptionData [message=abcd]",
      invocationException.getErrorData().toString());
}
 
Example #22
Source File: Jackson2ObjectMapperBuilderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void modules() {
	NumberSerializer serializer1 = new NumberSerializer(Integer.class);
	SimpleModule module = new SimpleModule();
	module.addSerializer(Integer.class, serializer1);
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().modules(module).build();
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer1, serializers.findSerializer(null, SimpleType.construct(Integer.class), null));
}
 
Example #23
Source File: Jackson2ObjectMapperBuilderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void modulesToInstallByClass() {
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
			.modulesToInstall(CustomIntegerModule.class)
			.build();
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(CustomIntegerSerializer.class,
			serializers.findSerializer(null, SimpleType.construct(Integer.class), null).getClass());
}
 
Example #24
Source File: Jackson2ObjectMapperBuilderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void modulesToInstallByInstance() {
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
			.modulesToInstall(new CustomIntegerModule())
			.build();
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(CustomIntegerSerializer.class,
			serializers.findSerializer(null, SimpleType.construct(Integer.class), null).getClass());
}
 
Example #25
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void setModules() {
	NumberSerializer serializer = new NumberSerializer(Integer.class);
	SimpleModule module = new SimpleModule();
	module.addSerializer(Integer.class, serializer);

	this.factory.setModules(Arrays.asList(new Module[]{module}));
	this.factory.afterPropertiesSet();
	ObjectMapper objectMapper = this.factory.getObject();

	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer, serializers.findSerializer(null, SimpleType.construct(Integer.class), null));
}
 
Example #26
Source File: Jackson2ObjectMapperBuilderTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void deserializerByType() throws JsonMappingException {
	JsonDeserializer<Date> deserializer = new DateDeserializers.DateDeserializer();
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
			.modules(new ArrayList<>())  // Disable well-known modules detection
			.deserializerByType(Date.class, deserializer)
			.build();
	assertTrue(getDeserializerFactoryConfig(objectMapper).hasDeserializers());
	Deserializers deserializers = getDeserializerFactoryConfig(objectMapper).deserializers().iterator().next();
	assertSame(deserializer, deserializers.findBeanDeserializer(SimpleType.construct(Date.class), null, null));
}
 
Example #27
Source File: Jackson2ObjectMapperBuilderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void serializerByType() {
	JsonSerializer<Number> serializer = new NumberSerializer(Integer.class);
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
			.modules(new ArrayList<>())  // Disable well-known modules detection
			.serializerByType(Boolean.class, serializer)
			.build();
	assertTrue(getSerializerFactoryConfig(objectMapper).hasSerializers());
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer, serializers.findSerializer(null, SimpleType.construct(Boolean.class), null));
}
 
Example #28
Source File: Jackson2ObjectMapperBuilderTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void serializerByType() {
	JsonSerializer<Number> serializer = new NumberSerializer(Integer.class);
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
			.modules(new ArrayList<>())  // Disable well-known modules detection
			.serializerByType(Boolean.class, serializer)
			.build();
	assertTrue(getSerializerFactoryConfig(objectMapper).hasSerializers());
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(serializer, serializers.findSerializer(null, SimpleType.construct(Boolean.class), null));
}
 
Example #29
Source File: Jackson2ObjectMapperBuilderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void deserializerByType() throws JsonMappingException {
	JsonDeserializer<Date> deserializer = new DateDeserializers.DateDeserializer();
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
			.modules(new ArrayList<>())  // Disable well-known modules detection
			.deserializerByType(Date.class, deserializer)
			.build();
	assertTrue(getDeserializerFactoryConfig(objectMapper).hasDeserializers());
	Deserializers deserializers = getDeserializerFactoryConfig(objectMapper).deserializers().iterator().next();
	assertSame(deserializer, deserializers.findBeanDeserializer(SimpleType.construct(Date.class), null, null));
}
 
Example #30
Source File: Jackson2ObjectMapperBuilderTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void modulesToInstallByInstance() {
	ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
			.modulesToInstall(new CustomIntegerModule())
			.build();
	Serializers serializers = getSerializerFactoryConfig(objectMapper).serializers().iterator().next();
	assertSame(CustomIntegerSerializer.class,
			serializers.findSerializer(null, SimpleType.construct(Integer.class), null).getClass());
}