james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [01/10] james-project git commit: JAMES-1818 Introduce mailboxId serializer/deserializer
Date Mon, 05 Sep 2016 12:43:57 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 4a2550182 -> 47cfda6cc


JAMES-1818 Introduce mailboxId serializer/deserializer


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/460b650c
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/460b650c
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/460b650c

Branch: refs/heads/master
Commit: 460b650cf702a78d816865a34c72d9088dd03f12
Parents: 4a25501
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Tue Aug 30 11:05:37 2016 +0200
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Mon Sep 5 14:41:59 2016 +0200

----------------------------------------------------------------------
 .../james/jmap/json/ObjectMapperFactory.java    |  74 +++++++++++-
 .../jmap/json/ObjectMapperFactoryTest.java      | 117 +++++++++++++++++++
 .../jmap/json/ParsingWritingObjectsTest.java    |   9 +-
 .../jmap/methods/JmapRequestParserImplTest.java |  11 +-
 .../methods/JmapResponseWriterImplTest.java     |  16 +--
 .../james/jmap/methods/RequestHandlerTest.java  |   6 +-
 .../org/apache/james/jmap/model/FilterTest.java |   3 +-
 7 files changed, 215 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/460b650c/server/protocols/jmap/src/main/java/org/apache/james/jmap/json/ObjectMapperFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/json/ObjectMapperFactory.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/json/ObjectMapperFactory.java
index 29b5471..79742f4 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/json/ObjectMapperFactory.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/json/ObjectMapperFactory.java
@@ -19,12 +19,26 @@
 
 package org.apache.james.jmap.json;
 
+import java.io.IOException;
 import java.util.Set;
 
+import javax.inject.Inject;
+
+import org.apache.james.mailbox.model.MailboxId;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
 import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.KeyDeserializer;
 import com.fasterxml.jackson.databind.Module;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.module.SimpleModule;
 import com.fasterxml.jackson.datatype.guava.GuavaModule;
 import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
 import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
@@ -32,17 +46,71 @@ import com.google.common.collect.ImmutableSet;
 
 public class ObjectMapperFactory {
 
-    private static final Set<Module> JACKSON_MODULES = ImmutableSet.of(new Jdk8Module(),
new JavaTimeModule(), new GuavaModule());
+    private static final ImmutableSet.Builder<Module> JACKSON_BASE_MODULES = ImmutableSet.<Module>builder().add(new
Jdk8Module(), new JavaTimeModule(), new GuavaModule());
+    private final Set<Module> jacksonModules;
+    
+    @Inject
+    public ObjectMapperFactory(MailboxId.Factory mailboxIdFactory) {
+        SimpleModule mailboxIdModule = new SimpleModule();
+        mailboxIdModule.addDeserializer(MailboxId.class, new MailboxIdDeserializer(mailboxIdFactory));
+        mailboxIdModule.addSerializer(MailboxId.class, new MailboxIdSerializer());
+        mailboxIdModule.addKeyDeserializer(MailboxId.class, new MailboxIdKeyDeserializer(mailboxIdFactory));
+        mailboxIdModule.addKeySerializer(MailboxId.class, new MailboxIdKeySerializer());
+        jacksonModules = JACKSON_BASE_MODULES.add(mailboxIdModule).build();
+    }
 
     public ObjectMapper forParsing() {
         return new ObjectMapper()
-                .registerModules(JACKSON_MODULES)
+                .registerModules(jacksonModules)
                 .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
     }
 
     public ObjectMapper forWriting() {
         return new ObjectMapper()
-                .registerModules(JACKSON_MODULES)
+                .registerModules(jacksonModules)
                 .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
     }
+
+    public static class MailboxIdDeserializer extends JsonDeserializer<MailboxId> {
+        private MailboxId.Factory factory;
+
+        public MailboxIdDeserializer(MailboxId.Factory factory) {
+            this.factory = factory;
+        }
+
+        @Override
+        public MailboxId deserialize(JsonParser p, DeserializationContext ctxt) throws IOException,
JsonProcessingException {
+            return factory.fromString(p.getValueAsString());
+        }
+    }
+
+    public static class MailboxIdSerializer extends JsonSerializer<MailboxId> {
+
+        @Override
+        public void serialize(MailboxId value, JsonGenerator gen, SerializerProvider serializers)
throws IOException, JsonProcessingException {
+            gen.writeString(value.serialize());
+        }
+    }
+
+    public static class MailboxIdKeyDeserializer extends KeyDeserializer {
+        private MailboxId.Factory factory;
+
+        public MailboxIdKeyDeserializer(MailboxId.Factory factory) {
+            this.factory = factory;
+        }
+
+        @Override
+        public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException,
JsonProcessingException {
+            return factory.fromString(key);
+        }
+    }
+
+    public static class MailboxIdKeySerializer extends JsonSerializer<MailboxId> {
+
+        @Override
+        public void serialize(MailboxId value, JsonGenerator gen, SerializerProvider serializers)
throws IOException, JsonProcessingException {
+            gen.writeFieldName(value.serialize());
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/460b650c/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ObjectMapperFactoryTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ObjectMapperFactoryTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ObjectMapperFactoryTest.java
new file mode 100644
index 0000000..8e3a635
--- /dev/null
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ObjectMapperFactoryTest.java
@@ -0,0 +1,117 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.jmap.json;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.Map;
+
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.model.MailboxId;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+public class ObjectMapperFactoryTest {
+    
+    private ObjectMapperFactory testee;
+
+    @Before
+    public void setup() {
+        testee = new ObjectMapperFactory(new InMemoryId.Factory());
+    }
+
+    @Test
+    public void mailboxIdShouldBeDeserializable() throws Exception {
+        String json = "{ \"mailboxId\": \"123\"}";
+        MailboxIdTestContainer expected = new MailboxIdTestContainer(InMemoryId.of(123));
+        MailboxIdTestContainer actual = testee.forParsing().readValue(json, MailboxIdTestContainer.class);
+        assertThat(actual).isEqualToComparingFieldByField(expected);
+    }
+
+    @Test
+    public void mailboxIdShouldBeSerializable() throws Exception {
+        MailboxIdTestContainer container = new MailboxIdTestContainer(InMemoryId.of(123));
+        String expectedJson = "{\"mailboxId\":\"123\"}";
+        String actual = testee.forWriting().writeValueAsString(container);
+        assertThat(actual).isEqualTo(expectedJson);
+    }
+
+    @Test
+    public void mailboxIdShouldBeDeserializableWhenKey() throws Exception {
+        String json = "{ \"map\": {\"123\": \"value\"}}";
+        MailboxIdKeyTestContainer expected = new MailboxIdKeyTestContainer(ImmutableMap.of(InMemoryId.of(123),
"value"));
+        MailboxIdKeyTestContainer actual = testee.forParsing().readValue(json, MailboxIdKeyTestContainer.class);
+        assertThat(actual).isEqualToComparingFieldByField(expected);
+    }
+
+    @Test
+    public void mailboxIdShouldBeSerializableWhenKeyWithoutToString() throws Exception {
+        ObjectMapperFactory testeeWithoutToString = new ObjectMapperFactory(new KeyWithoutToString.Factory());
+        MailboxIdKeyTestContainer container = new MailboxIdKeyTestContainer(ImmutableMap.of(new
KeyWithoutToString("key"), "value"));
+        String expectedJson = "{\"map\":{\"key\":\"value\"}}";
+        String actual = testeeWithoutToString.forWriting().writeValueAsString(container);
+        assertThat(actual).isEqualTo(expectedJson);
+    }
+
+    public static class MailboxIdTestContainer {
+        public MailboxId mailboxId;
+
+        public MailboxIdTestContainer() {
+        }
+
+        public MailboxIdTestContainer(MailboxId mailboxId) {
+            this.mailboxId = mailboxId;
+        }
+    }
+
+    public static class MailboxIdKeyTestContainer {
+        public Map<MailboxId, String> map;
+
+        public MailboxIdKeyTestContainer() {
+        }
+
+        public MailboxIdKeyTestContainer(Map<MailboxId, String> map) {
+            this.map = map;
+        }
+    }
+
+    public static class KeyWithoutToString implements MailboxId {
+        private String value;
+
+        public KeyWithoutToString(String value) {
+            this.value = value;
+        }
+
+        @Override
+        public String serialize() {
+            return value;
+        }
+
+        public static class Factory implements MailboxId.Factory {
+
+            @Override
+            public MailboxId fromString(String serialized) {
+                return new KeyWithoutToString(serialized);
+            }
+            
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/460b650c/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjectsTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjectsTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjectsTest.java
index 0106d71..b001060 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjectsTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjectsTest.java
@@ -30,6 +30,7 @@ import org.apache.james.jmap.methods.GetMessagesMethod;
 import org.apache.james.jmap.methods.JmapResponseWriterImpl;
 import org.apache.james.jmap.model.Message;
 import org.apache.james.jmap.model.SubMessage;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.junit.Test;
 
 import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
@@ -41,7 +42,7 @@ public class ParsingWritingObjectsTest {
     public void parsingJsonShouldWorkOnSubMessage() throws Exception {
         SubMessage expected = SUB_MESSAGE;
 
-        SubMessage subMessage = new ObjectMapperFactory().forParsing()
+        SubMessage subMessage = new ObjectMapperFactory(new InMemoryId.Factory()).forParsing()
             .readValue(IOUtils.toString(ClassLoader.getSystemResource("json/subMessage.json")),
SubMessage.class);
 
         assertThat(subMessage).isEqualToComparingFieldByField(expected);
@@ -51,7 +52,7 @@ public class ParsingWritingObjectsTest {
     public void writingJsonShouldWorkOnSubMessage() throws Exception {
         String expected = IOUtils.toString(ClassLoader.getSystemResource("json/subMessage.json"));
 
-        String json = new ObjectMapperFactory().forWriting()
+        String json = new ObjectMapperFactory(new InMemoryId.Factory()).forWriting()
                 .writeValueAsString(SUB_MESSAGE);
 
         assertThatJson(json)
@@ -64,7 +65,7 @@ public class ParsingWritingObjectsTest {
     public void parsingJsonShouldWorkOnMessage() throws Exception {
         Message expected = MESSAGE;
 
-        Message message = new ObjectMapperFactory().forParsing()
+        Message message = new ObjectMapperFactory(new InMemoryId.Factory()).forParsing()
             .readValue(IOUtils.toString(ClassLoader.getSystemResource("json/message.json")),
Message.class);
 
         assertThat(message).isEqualToComparingFieldByField(expected);
@@ -78,7 +79,7 @@ public class ParsingWritingObjectsTest {
                 .addFilter(JmapResponseWriterImpl.PROPERTIES_FILTER, SimpleBeanPropertyFilter.serializeAll())
                 .addFilter(GetMessagesMethod.HEADERS_FILTER, SimpleBeanPropertyFilter.serializeAll());
 
-        String json = new ObjectMapperFactory().forWriting()
+        String json = new ObjectMapperFactory(new InMemoryId.Factory()).forWriting()
                 .setFilterProvider(filterProvider)
                 .writeValueAsString(MESSAGE);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/460b650c/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/JmapRequestParserImplTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/JmapRequestParserImplTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/JmapRequestParserImplTest.java
index 1d62863..879de19 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/JmapRequestParserImplTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/JmapRequestParserImplTest.java
@@ -21,6 +21,8 @@ package org.apache.james.jmap.methods;
 
 import org.apache.james.jmap.json.ObjectMapperFactory;
 import org.apache.james.jmap.model.ProtocolRequest;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.junit.Before;
 import org.junit.Test;
 
 import com.fasterxml.jackson.databind.JsonNode;
@@ -28,6 +30,12 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 
 public class JmapRequestParserImplTest {
+    private JmapRequestParserImpl jmapRequestParserImpl;
+
+    @Before
+    public void setup() {
+        jmapRequestParserImpl = new JmapRequestParserImpl(new ObjectMapperFactory(new InMemoryId.Factory()));
+    }
 
     @Test(expected=IllegalArgumentException.class)
     public void extractJmapRequestShouldThrowWhenNullRequestClass() throws Exception {
@@ -35,7 +43,6 @@ public class JmapRequestParserImplTest {
                 new ObjectNode(new JsonNodeFactory(false)).putObject("{\"id\": \"id\"}"),
                 new ObjectNode(new JsonNodeFactory(false)).textNode("#1")} ;
 
-        JmapRequestParserImpl jmapRequestParserImpl = new JmapRequestParserImpl(new ObjectMapperFactory());
         jmapRequestParserImpl.extractJmapRequest(ProtocolRequest.deserialize(nodes), null);
     }
 
@@ -47,7 +54,6 @@ public class JmapRequestParserImplTest {
                 parameters,
                 new ObjectNode(new JsonNodeFactory(false)).textNode("#1")} ;
 
-        JmapRequestParserImpl jmapRequestParserImpl = new JmapRequestParserImpl(new ObjectMapperFactory());
         jmapRequestParserImpl.extractJmapRequest(ProtocolRequest.deserialize(nodes), RequestClass.class);
     }
 
@@ -58,7 +64,6 @@ public class JmapRequestParserImplTest {
                 parameters,
                 new ObjectNode(new JsonNodeFactory(false)).textNode("#1")} ;
 
-        JmapRequestParserImpl jmapRequestParserImpl = new JmapRequestParserImpl(new ObjectMapperFactory());
         jmapRequestParserImpl.extractJmapRequest(ProtocolRequest.deserialize(nodes), RequestClass.class);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/460b650c/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/JmapResponseWriterImplTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/JmapResponseWriterImplTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/JmapResponseWriterImplTest.java
index 8f35e43..b943a9a 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/JmapResponseWriterImplTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/JmapResponseWriterImplTest.java
@@ -32,6 +32,8 @@ import org.apache.james.jmap.model.ClientId;
 import org.apache.james.jmap.model.Property;
 import org.apache.james.jmap.model.ProtocolRequest;
 import org.apache.james.jmap.model.ProtocolResponse;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -44,6 +46,12 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 
 public class JmapResponseWriterImplTest {
+    private JmapResponseWriterImpl jmapResponseWriterImpl;
+
+    @Before
+    public void setup() {
+        jmapResponseWriterImpl = new JmapResponseWriterImpl(new ObjectMapperFactory(new InMemoryId.Factory()));
+    }
 
     @Ignore
     @Test(expected=IllegalStateException.class)
@@ -52,7 +60,6 @@ public class JmapResponseWriterImplTest {
         String expectedClientId = "#1";
         String expectedId = "myId";
 
-        JmapResponseWriterImpl jmapResponseWriterImpl = new JmapResponseWriterImpl(new ObjectMapperFactory());
         Stream<ProtocolResponse> response = jmapResponseWriterImpl.formatMethodResponse(Stream.of(JmapResponse
                 .builder()
                 .clientId(ClientId.of(expectedClientId))
@@ -73,7 +80,6 @@ public class JmapResponseWriterImplTest {
         ResponseClass responseClass = new ResponseClass();
         responseClass.id = expectedId;
 
-        JmapResponseWriterImpl jmapResponseWriterImpl = new JmapResponseWriterImpl(new ObjectMapperFactory());
         List<ProtocolResponse> response = jmapResponseWriterImpl.formatMethodResponse(
                 Stream.of(JmapResponse
                 .builder()
@@ -101,7 +107,6 @@ public class JmapResponseWriterImplTest {
         responseClass.list = ImmutableList.of(new ObjectResponseClass.Foo("id", "name"));
         Property property = () -> "id";
 
-        JmapResponseWriterImpl jmapResponseWriterImpl = new JmapResponseWriterImpl(new ObjectMapperFactory());
         List<ProtocolResponse> response = jmapResponseWriterImpl.formatMethodResponse(
                 Stream.of(JmapResponse
                 .builder()
@@ -126,7 +131,6 @@ public class JmapResponseWriterImplTest {
         responseClass.list = ImmutableList.of(new ObjectResponseClass.Foo("id", "name"));
         Property property = () -> "id";
 
-        JmapResponseWriterImpl jmapResponseWriterImpl = new JmapResponseWriterImpl(new ObjectMapperFactory());
         @SuppressWarnings("unused")
         Stream<ProtocolResponse> ignoredResponse = jmapResponseWriterImpl.formatMethodResponse(
                 Stream.of(JmapResponse
@@ -159,8 +163,6 @@ public class JmapResponseWriterImplTest {
         Property idProperty = () -> "id";
         Property nameProperty = () -> "name";
 
-        JmapResponseWriterImpl jmapResponseWriterImpl = new JmapResponseWriterImpl(new ObjectMapperFactory());
-
         List<ProtocolResponse> response = jmapResponseWriterImpl.formatMethodResponse(
                 Stream.of(JmapResponse
                             .builder()
@@ -210,7 +212,6 @@ public class JmapResponseWriterImplTest {
                 parameters,
                 new ObjectNode(new JsonNodeFactory(false)).textNode(expectedClientId)} ;
 
-        JmapResponseWriterImpl jmapResponseWriterImpl = new JmapResponseWriterImpl(new ObjectMapperFactory());
         List<ProtocolResponse> response = jmapResponseWriterImpl.formatMethodResponse(
                 Stream.of(JmapResponse
                     .builder()
@@ -234,7 +235,6 @@ public class JmapResponseWriterImplTest {
                 parameters,
                 new ObjectNode(new JsonNodeFactory(false)).textNode(expectedClientId)} ;
 
-        JmapResponseWriterImpl jmapResponseWriterImpl = new JmapResponseWriterImpl(new ObjectMapperFactory());
         List<ProtocolResponse> response = jmapResponseWriterImpl.formatMethodResponse(
                 Stream.of(JmapResponse
                     .builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/460b650c/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/RequestHandlerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/RequestHandlerTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/RequestHandlerTest.java
index 2ad4f09..8725dd6 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/RequestHandlerTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/RequestHandlerTest.java
@@ -36,6 +36,7 @@ import org.apache.james.jmap.model.ClientId;
 import org.apache.james.jmap.model.ProtocolRequest;
 import org.apache.james.jmap.model.ProtocolResponse;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -123,8 +124,9 @@ public class RequestHandlerTest {
 
     @Before
     public void setup() {
-        jmapRequestParser = new JmapRequestParserImpl(new ObjectMapperFactory());
-        jmapResponseWriter = new JmapResponseWriterImpl(new ObjectMapperFactory());
+        ObjectMapperFactory objectMapperFactory = new ObjectMapperFactory(new InMemoryId.Factory());
+        jmapRequestParser = new JmapRequestParserImpl(objectMapperFactory);
+        jmapResponseWriter = new JmapResponseWriterImpl(objectMapperFactory);
         mockHttpServletRequest = mock(HttpServletRequest.class);
         testee = new RequestHandler(ImmutableSet.of(new TestMethod()), jmapRequestParser,
jmapResponseWriter);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/460b650c/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/FilterTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/FilterTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/FilterTest.java
index 7588bad..00fb904 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/FilterTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/FilterTest.java
@@ -19,6 +19,7 @@
 package org.apache.james.jmap.model;
 
 import org.apache.james.jmap.json.ObjectMapperFactory;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -32,7 +33,7 @@ public class FilterTest {
 
     @Before
     public void setup() {
-        parser = new ObjectMapperFactory().forParsing();
+        parser = new ObjectMapperFactory(new InMemoryId.Factory()).forParsing();
     }
 
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message