1 package com.atlassian.sal.testresources.net;
2
3 import com.atlassian.sal.api.net.Response;
4 import com.atlassian.sal.api.net.ResponseException;
5
6 import java.io.InputStream;
7 import java.util.Map;
8 import java.util.Collections;
9
10
11
12
13 public class MockResponse implements Response
14 {
15 private int statusCode;
16 private String responseBodyAsString;
17 private InputStream responseBodyAsStream;
18 private String statusText;
19 private boolean successful;
20 private Map<String, String> headers = Collections.emptyMap();
21
22 public String getHeader(String name)
23 {
24 return headers.get(name);
25 }
26
27 public int getStatusCode()
28 {
29 return statusCode;
30 }
31
32 public void setStatusCode(int statusCode)
33 {
34 this.statusCode = statusCode;
35 }
36
37 public String getResponseBodyAsString()
38 {
39 return responseBodyAsString;
40 }
41
42 public void setResponseBodyAsString(String responseBodyAsString)
43 {
44 this.responseBodyAsString = responseBodyAsString;
45 }
46
47 public InputStream getResponseBodyAsStream()
48 {
49 return responseBodyAsStream;
50 }
51
52 public void setResponseBodyAsStream(InputStream responseBodyAsStream)
53 {
54 this.responseBodyAsStream = responseBodyAsStream;
55 }
56
57 public <T> T getEntity(Class<T> entityClass) throws ResponseException
58 {
59 throw new UnsupportedOperationException();
60 }
61
62 public String getStatusText()
63 {
64 return statusText;
65 }
66
67 public void setStatusText(String statusText)
68 {
69 this.statusText = statusText;
70 }
71
72 public boolean isSuccessful()
73 {
74 return successful;
75 }
76
77 public void setSuccessful(boolean successful)
78 {
79 this.successful = successful;
80 }
81
82 public Map<String, String> getHeaders()
83 {
84 return headers;
85 }
86
87 public void setHeaders(Map<String, String> headers)
88 {
89 this.headers = headers;
90 }
91 }