1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.rest; |
35 |
|
|
36 |
|
import static org.junit.Assert.assertEquals; |
37 |
|
|
38 |
|
import javax.jcr.AccessDeniedException; |
39 |
|
import javax.jcr.RepositoryException; |
40 |
|
import javax.ws.rs.core.Response; |
41 |
|
|
42 |
|
import org.junit.Test; |
43 |
|
|
44 |
|
|
45 |
|
@link |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 3 |
Complexity Density: 0.33 |
|
47 |
|
public class RestExceptionMapperTest { |
48 |
|
|
49 |
|
private final RestExceptionMapper restExceptionMapper = new RestExceptionMapper(); |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
51 |
1 |
@Test... |
52 |
|
public void testThatRestExceptionMapperDoesNotProvideAStackTrace() { |
53 |
|
|
54 |
1 |
final String exceptionMessage = "This is a test-exception."; |
55 |
1 |
final Exception exception = new Exception(exceptionMessage); |
56 |
|
|
57 |
|
|
58 |
1 |
Response response = restExceptionMapper.toResponse(exception); |
59 |
|
|
60 |
|
|
61 |
1 |
assertEquals(exceptionMessage, response.getEntity().toString()); |
62 |
1 |
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus()); |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
65 |
1 |
@Test... |
66 |
|
public void testMapsRepositoryExceptionToInternalServerError() { |
67 |
|
|
68 |
|
|
69 |
1 |
Response response = restExceptionMapper.toResponse(new RepositoryException("")); |
70 |
|
|
71 |
|
|
72 |
1 |
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus()); |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
75 |
1 |
@Test... |
76 |
|
public void testMapsAccessDeniedExceptionToForbidden() { |
77 |
|
|
78 |
|
|
79 |
1 |
Response response = restExceptionMapper.toResponse(new AccessDeniedException("")); |
80 |
|
|
81 |
|
|
82 |
1 |
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), response.getStatus()); |
83 |
|
} |
84 |
|
} |