|
1 |
| package com.agical.rmock.core.action; |
|
2 |
| |
|
3 |
| import com.agical.rmock.core.Action; |
|
4 |
| import com.agical.rmock.core.MethodHandle; |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| public class ThrowsAction implements Action { |
|
12 |
| |
|
13 |
| private final Throwable throwable; |
|
14 |
| |
|
15 |
18
| public ThrowsAction(Throwable throwable) {
|
|
16 |
18
| this.throwable = throwable;
|
|
17 |
| } |
|
18 |
| |
|
19 |
14
| public Object invocation(Object[] arguments, MethodHandle methodHandle)
|
|
20 |
| throws Throwable { |
|
21 |
14
| throw throwable.fillInStackTrace();
|
|
22 |
| } |
|
23 |
| |
|
24 |
1
| public int hashCode() {
|
|
25 |
1
| return throwable.hashCode();
|
|
26 |
| } |
|
27 |
| |
|
28 |
2
| public boolean equals(Object obj) {
|
|
29 |
2
| if(obj instanceof ThrowsAction) {
|
|
30 |
1
| Throwable otherThrowable = ((ThrowsAction)obj).throwable;
|
|
31 |
1
| return otherThrowable.getClass().equals(throwable.getClass()) &&
|
|
32 |
| (otherThrowable.getMessage() == throwable.getMessage() || |
|
33 |
| otherThrowable.getMessage().equals(throwable.getMessage())); |
|
34 |
| } |
|
35 |
| |
|
36 |
1
| return false;
|
|
37 |
| } |
|
38 |
| } |