You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2020/07/17 02:24:18 UTC
[james-project] 04/31: JAMES-3305 Add FailsDeserializationTask type
for testing
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 7ed19807ad79e3899097469152457865889d302e
Author: LanKhuat <dl...@linagora.com>
AuthorDate: Wed Jul 15 17:21:21 2020 +0700
JAMES-3305 Add FailsDeserializationTask type for testing
---
.../james/task/FailsDeserializationTask.java | 40 ++++++++++++++++++++++
.../task/json/dto/FailsDeserializationTaskDTO.java | 35 +++++++++++++++++++
.../server/task/json/dto/TestTaskDTOModules.java | 9 +++++
3 files changed, 84 insertions(+)
diff --git a/server/task/task-api/src/test/java/org/apache/james/task/FailsDeserializationTask.java b/server/task/task-api/src/test/java/org/apache/james/task/FailsDeserializationTask.java
new file mode 100644
index 0000000..9a047a4
--- /dev/null
+++ b/server/task/task-api/src/test/java/org/apache/james/task/FailsDeserializationTask.java
@@ -0,0 +1,40 @@
+/****************************************************************
+ * 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.task;
+
+import java.util.Optional;
+
+public class FailsDeserializationTask implements Task {
+ public static final TaskType TYPE = TaskType.of("fails-deserialization");
+
+ @Override
+ public Result run() {
+ return Result.COMPLETED;
+ }
+
+ @Override
+ public TaskType type() {
+ return TYPE;
+ }
+
+ @Override
+ public Optional<TaskExecutionDetails.AdditionalInformation> details() {
+ return Optional.empty();
+ }
+}
diff --git a/server/task/task-json/src/test/java/org/apache/james/server/task/json/dto/FailsDeserializationTaskDTO.java b/server/task/task-json/src/test/java/org/apache/james/server/task/json/dto/FailsDeserializationTaskDTO.java
new file mode 100644
index 0000000..e043e5e
--- /dev/null
+++ b/server/task/task-json/src/test/java/org/apache/james/server/task/json/dto/FailsDeserializationTaskDTO.java
@@ -0,0 +1,35 @@
+/****************************************************************
+ * 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.server.task.json.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class FailsDeserializationTaskDTO implements TaskDTO {
+
+ private final String type;
+
+ public FailsDeserializationTaskDTO(@JsonProperty("type") String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+}
diff --git a/server/task/task-json/src/test/java/org/apache/james/server/task/json/dto/TestTaskDTOModules.java b/server/task/task-json/src/test/java/org/apache/james/server/task/json/dto/TestTaskDTOModules.java
index 61b3acc..a4450d0 100644
--- a/server/task/task-json/src/test/java/org/apache/james/server/task/json/dto/TestTaskDTOModules.java
+++ b/server/task/task-json/src/test/java/org/apache/james/server/task/json/dto/TestTaskDTOModules.java
@@ -25,6 +25,7 @@ import org.apache.james.json.DTOModule;
import org.apache.james.server.task.json.TestTask;
import org.apache.james.task.CompletedTask;
import org.apache.james.task.FailedTask;
+import org.apache.james.task.FailsDeserializationTask;
import org.apache.james.task.MemoryReferenceTask;
import org.apache.james.task.MemoryReferenceWithCounterTask;
import org.apache.james.task.ThrowingTask;
@@ -57,6 +58,14 @@ public interface TestTaskDTOModules {
.typeName("completed-task")
.withFactory(TaskDTOModule::new);
+ TaskDTOModule<FailsDeserializationTask, FailsDeserializationTaskDTO> FAILS_DESERIALIZATION_TASK_MODULE = DTOModule
+ .forDomainObject(FailsDeserializationTask.class)
+ .convertToDTO(FailsDeserializationTaskDTO.class)
+ .toDomainObjectConverter(dto -> {throw new RuntimeException("fail to deserialize"); })
+ .toDTOConverter((task, typeName) -> new FailsDeserializationTaskDTO(typeName))
+ .typeName(FailsDeserializationTask.TASK_TYPE)
+ .withFactory(TaskDTOModule::new);
+
TaskDTOModule<ThrowingTask, ThrowingTaskDTO> THROWING_TASK_MODULE = DTOModule
.forDomainObject(ThrowingTask.class)
.convertToDTO(ThrowingTaskDTO.class)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org