File tree Expand file tree Collapse file tree
main/java/com/retailsvc/http/spec
test/java/com/retailsvc/http/spec Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .retailsvc .http .spec ;
2+
3+ import java .util .Locale ;
4+
5+ public enum HttpMethod {
6+ GET ,
7+ POST ,
8+ PUT ,
9+ DELETE ,
10+ PATCH ,
11+ HEAD ,
12+ OPTIONS ,
13+ TRACE ,
14+ CONNECT ;
15+
16+ public static HttpMethod parse (String s ) {
17+ return HttpMethod .valueOf (s .toUpperCase (Locale .ROOT ));
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ package com .retailsvc .http .spec ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import org .junit .jupiter .api .Test ;
6+
7+ class HttpMethodTest {
8+ @ Test
9+ void parsesUppercase () {
10+ assertThat (HttpMethod .parse ("GET" )).isEqualTo (HttpMethod .GET );
11+ }
12+
13+ @ Test
14+ void parsesLowercase () {
15+ assertThat (HttpMethod .parse ("get" )).isEqualTo (HttpMethod .GET );
16+ }
17+
18+ @ Test
19+ void parsesMixed () {
20+ assertThat (HttpMethod .parse ("PaTcH" )).isEqualTo (HttpMethod .PATCH );
21+ }
22+
23+ @ Test
24+ void unknownThrows () {
25+ org .junit .jupiter .api .Assertions .assertThrows (
26+ IllegalArgumentException .class , () -> HttpMethod .parse ("foo" ));
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments