Skip to content

Commit f512977

Browse files
committed
merge PR #134 for patch
2 parents c763520 + 6c510c2 commit f512977

File tree

3 files changed

+101
-4
lines changed

3 files changed

+101
-4
lines changed

pom.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@
4545
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
4646
</properties>
4747

48+
<repositories>
49+
<repository>
50+
<id>jitpack.io</id>
51+
<url>https://jitpack.io</url>
52+
</repository>
53+
</repositories>
54+
4855
<profiles>
4956
<profile>
5057
<id>release</id>
@@ -416,10 +423,10 @@
416423
<scope>test</scope>
417424
</dependency>
418425
<dependency>
419-
<groupId>net.code-story</groupId>
420-
<artifactId>fluent-rest-test</artifactId>
421-
<version>1.6</version>
422-
<scope>test</scope>
426+
<groupId>com.github.CodeStory</groupId>
427+
<artifactId>fluent-rest-test</artifactId>
428+
<version>d5b4cf0</version>
429+
<type>jar</type>
423430
</dependency>
424431
<dependency>
425432
<groupId>org.webjars</groupId>

src/test/java/net/codestory/http/CatchAllTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ public void catch_all_put() {
6565
post("/route").should().respond(405);
6666
}
6767

68+
@Test
69+
public void catch_all_patch() {
70+
configure(routes -> routes
71+
.anyPatch((context) -> "Hello")
72+
);
73+
74+
patch("/").should().contain("Hello");
75+
patch("/any").should().contain("Hello");
76+
post("/route").should().respond(405);
77+
}
78+
6879
@Test
6980
public void catch_all_options() {
7081
configure(routes -> routes
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* Copyright (C) 2013-2015 all@code-story.net
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License
15+
*/
16+
package net.codestory.http;
17+
18+
import net.codestory.http.annotations.Patch;
19+
import net.codestory.http.testhelpers.AbstractProdWebServerTest;
20+
import org.junit.Test;
21+
22+
public class PatchTest extends AbstractProdWebServerTest {
23+
@Test
24+
public void patch() {
25+
configure(routes -> routes
26+
.patch("/patch", () -> "Done")
27+
);
28+
29+
patch("/patch").should().contain("Done");
30+
}
31+
32+
@Test
33+
public void content_as_bytes() {
34+
configure(routes -> routes
35+
.patch("/patch", context -> context.request().contentAsBytes())
36+
);
37+
38+
patch("/patch", "Bob").should().contain("Bob");
39+
}
40+
41+
@Test
42+
public void content_as_string() {
43+
configure(routes -> routes
44+
.patch("/patch", context -> context.request().content())
45+
);
46+
47+
patch("/patch", "Joe").should().contain("Joe");
48+
}
49+
50+
@Test
51+
public void resource() {
52+
configure(routes -> routes
53+
.add(new patchResource())
54+
);
55+
56+
patch("/order/12", "{\"name\":\"foo\",\"quantity\":42}").should().contain("order 12 : 42xfoo");
57+
}
58+
59+
@Test
60+
public void resource_class() {
61+
configure(routes -> routes
62+
.add(patchResource.class)
63+
);
64+
65+
patch("/order/12", "{\"name\":\"foo\",\"quantity\":42}").should().contain("order 12 : 42xfoo");
66+
}
67+
68+
public static class patchResource {
69+
@Patch("/order/:id")
70+
public String update(String id, Order order) {
71+
return "order " + id + " : " + order.quantity + "x" + order.name;
72+
}
73+
}
74+
75+
static class Order {
76+
String name;
77+
int quantity;
78+
}
79+
}

0 commit comments

Comments
 (0)