SchemaSerializationModule extends Module { @Override public void setupModule(SetupContext context) { context.addSerializers(new SimpleSerializers(Collections.singletonList(new SchemaSerializer()))); context.addDeserializers(new SimpleDeserializers(Collections.singletonMap(Schema.class, new SchemaDeserializer()))); }  @Override String getModuleName(); @Override Version version(); @Override void setupModule(SetupContext context);  }
@Test public void setupModule() throws JsonMappingException { SetupContext context = mock(SetupContext.class); underTest.setupModule(context); ArgumentCaptor<SimpleSerializers> serializersCaptor = ArgumentCaptor.forClass(SimpleSerializers.class); ArgumentCaptor<SimpleDeserializers> deserializersCaptor = ArgumentCaptor.forClass(SimpleDeserializers.class); verify(context).addSerializers(serializersCaptor.capture()); verify(context).addDeserializers(deserializersCaptor.capture()); JavaType javaType = new ObjectMapper().constructType(Schema.class); JsonSerializer<?> serializer = serializersCaptor.getValue().findSerializer(null, javaType, null); assertThat(serializer, is(instanceOf(SchemaSerializer.class))); JsonDeserializer<?> deserializer = deserializersCaptor.getValue().findBeanDeserializer(javaType, null, null); assertThat(deserializer, is(instanceOf(SchemaDeserializer.class))); }