, ValueDeserializer>> commonDeserializers) {
this.configuration = configuration;
+ this.commonDeserializers = commonDeserializers;
BeanAnnotationProcessor.setPropertyAccessResolver(propertyAccessResolver);
}
@@ -35,7 +42,8 @@ public JsonLdDeserializerModifier(Configuration configuration, PropertyAccessRes
public JsonDeserializer> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc,
JsonDeserializer> deserializer) {
if (BeanAnnotationProcessor.isOwlClassEntity(beanDesc.getBeanClass())) {
- return new JacksonJsonLdDeserializer(deserializer, beanDesc.getBeanClass(), configuration);
+ return new JacksonJsonLdDeserializer(deserializer, beanDesc.getBeanClass(), configuration,
+ commonDeserializers);
}
return deserializer;
}
diff --git a/src/test/java/cz/cvut/kbss/jsonld/jackson/deserialization/JsonLdDeserializationTest.java b/src/test/java/cz/cvut/kbss/jsonld/jackson/deserialization/JsonLdDeserializationTest.java
index 40d60ed..2eb1d95 100644
--- a/src/test/java/cz/cvut/kbss/jsonld/jackson/deserialization/JsonLdDeserializationTest.java
+++ b/src/test/java/cz/cvut/kbss/jsonld/jackson/deserialization/JsonLdDeserializationTest.java
@@ -1,16 +1,14 @@
/**
* Copyright (C) 2022 Czech Technical University in Prague
- *
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details. You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details. You should have received a copy of the GNU General Public License along with this program. If not, see
+ * .
*/
package cz.cvut.kbss.jsonld.jackson.deserialization;
@@ -18,6 +16,8 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import cz.cvut.kbss.jsonld.ConfigParam;
+import cz.cvut.kbss.jsonld.deserialization.DeserializationContext;
+import cz.cvut.kbss.jsonld.deserialization.ValueDeserializer;
import cz.cvut.kbss.jsonld.jackson.JsonLdModule;
import cz.cvut.kbss.jsonld.jackson.environment.Environment;
import cz.cvut.kbss.jsonld.jackson.environment.model.Employee;
@@ -34,6 +34,10 @@
import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
class JsonLdDeserializationTest {
@@ -150,4 +154,22 @@ void deserializationSkipsPropertiesMappedToFieldsWithReadOnlyAccess() throws Exc
assertNotNull(result);
assertNull(result.getEmployeeCount());
}
+
+ @Test
+ void deserializationSupportsCustomDeserializers() throws Exception {
+ final ValueDeserializer deserializer = spy(new CustomDeserializer());
+ jsonLdModule.registerDeserializer(Boolean.class, deserializer);
+ final String input = Environment.readData("objectWithDataProperties.json");
+ final User result = objectMapper.readValue(input, User.class);
+ assertNotNull(result);
+ assertNull(result.getAdmin());
+ verify(deserializer).deserialize(anyMap(), any(DeserializationContext.class));
+ }
+
+ static class CustomDeserializer implements ValueDeserializer {
+ @Override
+ public Boolean deserialize(Map, ?> map, DeserializationContext deserializationContext) {
+ return null;
+ }
+ }
}