File tree Expand file tree Collapse file tree
main/java/com/retailsvc/http
test/java/com/retailsvc/http Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .retailsvc .http ;
2+
3+ import com .retailsvc .http .spec .HttpMethod ;
4+ import java .util .Set ;
5+
6+ public final class MethodNotAllowedException extends RuntimeException {
7+ private final Set <HttpMethod > allowed ;
8+
9+ public MethodNotAllowedException (Set <HttpMethod > allowed ) {
10+ super ("method not allowed; allowed=" + allowed );
11+ this .allowed = Set .copyOf (allowed );
12+ }
13+
14+ public Set <HttpMethod > allowed () {
15+ return allowed ;
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ package com .retailsvc .http ;
2+
3+ public final class NotFoundException extends RuntimeException {
4+ public NotFoundException (String message ) {
5+ super (message );
6+ }
7+ }
Original file line number Diff line number Diff line change 1+ package com .retailsvc .http ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import com .retailsvc .http .spec .HttpMethod ;
6+ import java .util .Set ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ class HttpExceptionsTest {
10+ @ Test
11+ void notFoundCarriesPath () {
12+ NotFoundException e = new NotFoundException ("GET /missing" );
13+ assertThat (e .getMessage ()).isEqualTo ("GET /missing" );
14+ }
15+
16+ @ Test
17+ void methodNotAllowedCarriesAllowedSet () {
18+ MethodNotAllowedException e =
19+ new MethodNotAllowedException (Set .of (HttpMethod .GET , HttpMethod .POST ));
20+ assertThat (e .allowed ()).containsExactlyInAnyOrder (HttpMethod .GET , HttpMethod .POST );
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments