This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit a93aca8184de1b1b762e6d01af25c77d003706a7
Author: RĂ©mi Kowalski <rkowal...@linagora.com>
AuthorDate: Fri Sep 20 17:34:31 2019 +0200

    JAMES-2813 extract UserReindexingTaskDTO
---
 .../mailbox/tools/indexer/UserReindexingTask.java  | 44 ++--------------
 .../tools/indexer/UserReindexingTaskDTO.java       | 61 ++++++++++++++++++++++
 .../UserReindexingTaskSerializationTest.java       |  2 +-
 3 files changed, 66 insertions(+), 41 deletions(-)

diff --git 
a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/UserReindexingTask.java
 
b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/UserReindexingTask.java
index 53d9275..7b69928 100644
--- 
a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/UserReindexingTask.java
+++ 
b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/UserReindexingTask.java
@@ -20,60 +20,20 @@
 package org.apache.mailbox.tools.indexer;
 
 import java.util.Optional;
-import java.util.function.Function;
 
 import javax.inject.Inject;
 
 import org.apache.james.core.User;
-import org.apache.james.json.DTOModule;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.indexer.ReIndexingExecutionFailures;
-import org.apache.james.server.task.json.dto.TaskDTO;
-import org.apache.james.server.task.json.dto.TaskDTOModule;
 import org.apache.james.task.Task;
 import org.apache.james.task.TaskExecutionDetails;
 import org.apache.james.task.TaskType;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-
 public class UserReindexingTask implements Task {
 
     public static final TaskType USER_RE_INDEXING = 
TaskType.of("userReIndexing");
 
-    public static final Function<UserReindexingTask.Factory, 
TaskDTOModule<UserReindexingTask, UserReindexingTask.UserReindexingTaskDTO>> 
MODULE = (factory) ->
-        DTOModule
-            .forDomainObject(UserReindexingTask.class)
-            .convertToDTO(UserReindexingTask.UserReindexingTaskDTO.class)
-            .toDomainObjectConverter(factory::create)
-            .toDTOConverter(UserReindexingTask.UserReindexingTaskDTO::of)
-            .typeName(USER_RE_INDEXING.asString())
-            .withFactory(TaskDTOModule::new);
-
-    public static class UserReindexingTaskDTO implements TaskDTO {
-
-        public static UserReindexingTaskDTO of(UserReindexingTask task, String 
type) {
-            return new UserReindexingTaskDTO(type, task.user.asString());
-        }
-
-        private final String type;
-        private final String username;
-
-        private UserReindexingTaskDTO(@JsonProperty("type") String type, 
@JsonProperty("username") String username) {
-            this.type = type;
-            this.username = username;
-        }
-
-        @Override
-        public String getType() {
-            return type;
-        }
-
-        public String getUsername() {
-            return username;
-        }
-
-    }
-
     public static class AdditionalInformation extends 
ReprocessingContextInformation {
         private final User user;
 
@@ -123,6 +83,10 @@ public class UserReindexingTask implements Task {
         }
     }
 
+    public User getUser() {
+        return user;
+    }
+
     @Override
     public TaskType type() {
         return USER_RE_INDEXING;
diff --git 
a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/UserReindexingTaskDTO.java
 
b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/UserReindexingTaskDTO.java
new file mode 100644
index 0000000..82e12f5
--- /dev/null
+++ 
b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/UserReindexingTaskDTO.java
@@ -0,0 +1,61 @@
+/****************************************************************
+ * 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.mailbox.tools.indexer;
+
+import java.util.function.Function;
+
+import org.apache.james.json.DTOModule;
+import org.apache.james.server.task.json.dto.TaskDTO;
+import org.apache.james.server.task.json.dto.TaskDTOModule;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class UserReindexingTaskDTO implements TaskDTO {
+
+    public static final Function<UserReindexingTask.Factory, 
TaskDTOModule<UserReindexingTask, UserReindexingTaskDTO>> MODULE = (factory) ->
+        DTOModule
+            .forDomainObject(UserReindexingTask.class)
+            .convertToDTO(UserReindexingTaskDTO.class)
+            .toDomainObjectConverter(factory::create)
+            .toDTOConverter(UserReindexingTaskDTO::of)
+            .typeName(UserReindexingTask.USER_RE_INDEXING.asString())
+            .withFactory(TaskDTOModule::new);
+
+    public static UserReindexingTaskDTO of(UserReindexingTask task, String 
type) {
+        return new UserReindexingTaskDTO(type, task.getUser().asString());
+    }
+
+    private final String type;
+    private final String username;
+
+    private UserReindexingTaskDTO(@JsonProperty("type") String type, 
@JsonProperty("username") String username) {
+        this.type = type;
+        this.username = username;
+    }
+
+    @Override
+    public String getType() {
+        return type;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+}
diff --git 
a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/UserReindexingTaskSerializationTest.java
 
b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/UserReindexingTaskSerializationTest.java
index c5007af..c586e65 100644
--- 
a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/UserReindexingTaskSerializationTest.java
+++ 
b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/UserReindexingTaskSerializationTest.java
@@ -41,7 +41,7 @@ class UserReindexingTaskSerializationTest {
     void setUp() {
         reIndexerPerformer = mock(ReIndexerPerformer.class);
         UserReindexingTask.Factory factory = new 
UserReindexingTask.Factory(reIndexerPerformer);
-        taskSerializer = new 
JsonTaskSerializer(UserReindexingTask.MODULE.apply(factory));
+        taskSerializer = new 
JsonTaskSerializer(UserReindexingTaskDTO.MODULE.apply(factory));
     }
 
     @Test


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

Reply via email to