This is an automated email from the git hooks/post-receive script. New commit to branch feature/spgeed in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 53f5dea9e5f0b34ca340391fa77e8f5fb2444e44 Author: Yannick Martel <martel@codelutin.com> Date: Fri Jul 26 10:03:54 2019 +0200 add some test to check json mapper behavior --- .../org/chorem/pollen/rest/api/SpgeedTest.java | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/SpgeedTest.java b/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/SpgeedTest.java new file mode 100644 index 00000000..4aca30ec --- /dev/null +++ b/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/SpgeedTest.java @@ -0,0 +1,47 @@ +package org.chorem.pollen.rest.api; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.chorem.pollen.persistence.entity.PollenUser; +import org.chorem.pollen.persistence.entity.PollenUserEmailAddress; +import org.chorem.pollen.services.PollenTechnicalException; +import org.chorem.pollen.services.service.PollenUserService; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; + +/** + * @author ymartel (martel@codelutin.com) + */ +public class SpgeedTest { + + @Test + public void testEmailDeserialization() throws Exception { + String json = "{\"topiaid\":\"PollenUserEmailAddress_M-wGbZ74QQCUr_hwl6JXmw\",\"topiaversion\":1,\"topiacreatedate\":\"2019-07-19T10:00:30.962\",\"emailaddress\":\"admin@chorem.org\",\"pgppublickey\":null,\"validated\":true,\"pollenuser\":\"PollenUser_6qdaqbgBTyCBa8Dvz5SeHQ\"}"; + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); + PollenUserEmailAddress email = mapper.readValue(json, PollenUserEmailAddress.class); + + Assert.assertNotNull(email); + Assert.assertEquals("admin@chorem.org", email.getEmailAddress()); + } + + @Test + public void testUserDeserialization() throws Exception { + String json = "{\"topiaid\":\"PollenUser_6qdaqbgBTyCBa8Dvz5SeHQ\",\"topiaversion\":1,\"topiacreatedate\":\"2019-07-19T10:00:30.913\",\"name\":\"admin\",\"administrator\":true,\"language\":null,\"password\":\"m7LAmO/AeLrjPI6kkzS0wTmU6fpbG/nxptfi/P7fg0BToZoIAV6xVre3tcttYxnLTDrXjtq7YOpggTFRz7mTjA==\",\"salt\":\"yRnTw64IPoWXR5f/j/rIsal7Pvd3Zz9LM9FPH3yXgIo=\",\"banned\":false,\"gtuvalidationdate\":null,\"premiumto\":null,\"cancreatepoll\":false,\"avatar\":null,\"defaultemailaddress\": [...] + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); + PollenUser pollenUser = mapper.readValue(json, PollenUser.class); + + Assert.assertNotNull(pollenUser); + Assert.assertEquals("admin", pollenUser.getName()); + Assert.assertTrue(pollenUser.isAdministrator()); + } + +} -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.