Repository: james-project Updated Branches: refs/heads/master dec2685fa -> 866d09e24
JAMES-2294 Fix taskIdDTO Location header Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/fac7e596 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/fac7e596 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/fac7e596 Branch: refs/heads/master Commit: fac7e596baf4e54ec94a5d612bf2e6c9da91c1fa Parents: dec2685 Author: benwa <[email protected]> Authored: Thu Jan 25 10:22:00 2018 +0700 Committer: benwa <[email protected]> Committed: Fri Jan 26 08:12:00 2018 +0700 ---------------------------------------------------------------------- .../apache/james/webadmin/dto/TaskIdDto.java | 2 +- .../james/webadmin/dto/TaskIdDtoTest.java | 50 ++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/fac7e596/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/dto/TaskIdDto.java ---------------------------------------------------------------------- diff --git a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/dto/TaskIdDto.java b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/dto/TaskIdDto.java index 64c4321..35f88e9 100644 --- a/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/dto/TaskIdDto.java +++ b/server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/dto/TaskIdDto.java @@ -33,7 +33,7 @@ public class TaskIdDto { public static TaskIdDto respond(Response response, TaskId taskId) { response.status(HttpStatus.CREATED_201); - response.header(LOCATION.asString(), TasksRoutes.BASE + "/" + taskId.toString()); + response.header(LOCATION.asString(), TasksRoutes.BASE + "/" + taskId.getValue()); return TaskIdDto.from(taskId); } http://git-wip-us.apache.org/repos/asf/james-project/blob/fac7e596/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/dto/TaskIdDtoTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/dto/TaskIdDtoTest.java b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/dto/TaskIdDtoTest.java new file mode 100644 index 0000000..5f85a54 --- /dev/null +++ b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/dto/TaskIdDtoTest.java @@ -0,0 +1,50 @@ +/**************************************************************** + * 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.webadmin.dto; + +import static org.eclipse.jetty.http.HttpHeader.LOCATION; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; + +import java.util.UUID; + +import org.apache.james.task.TaskId; +import org.eclipse.jetty.http.HttpStatus; +import org.junit.Test; + +import spark.Response; + +public class TaskIdDtoTest { + private static final String UID_VALUE = "ce5316cb-c924-40eb-9ca0-c5828e276297"; + + @Test + public void respondShouldReturnCreatedWithTaskIdHeader() { + Response response = mock(Response.class); + TaskId taskId = new TaskId(UUID.fromString(UID_VALUE)); + + TaskIdDto.respond(response, taskId); + + verify(response).status(HttpStatus.CREATED_201); + verify(response).header(LOCATION.asString(), "/tasks/" + UID_VALUE); + verifyNoMoreInteractions(response); + } + +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
