View Javadoc

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.Collections;
8   import java.util.Map;
9   
10  /**
11   * Mock response that provides setters for all properties
12   */
13  public class MockResponse implements Response {
14      private int statusCode;
15      private String responseBodyAsString;
16      private InputStream responseBodyAsStream;
17      private String statusText;
18      private boolean successful;
19      private Map<String, String> headers = Collections.emptyMap();
20  
21      public String getHeader(String name) {
22          return headers.get(name);
23      }
24  
25      public int getStatusCode() {
26          return statusCode;
27      }
28  
29      public void setStatusCode(int statusCode) {
30          this.statusCode = statusCode;
31      }
32  
33      public String getResponseBodyAsString() {
34          return responseBodyAsString;
35      }
36  
37      public void setResponseBodyAsString(String responseBodyAsString) {
38          this.responseBodyAsString = responseBodyAsString;
39      }
40  
41      public InputStream getResponseBodyAsStream() {
42          return responseBodyAsStream;
43      }
44  
45      public void setResponseBodyAsStream(InputStream responseBodyAsStream) {
46          this.responseBodyAsStream = responseBodyAsStream;
47      }
48  
49      public <T> T getEntity(Class<T> entityClass) throws ResponseException {
50          throw new UnsupportedOperationException();
51      }
52  
53      public String getStatusText() {
54          return statusText;
55      }
56  
57      public void setStatusText(String statusText) {
58          this.statusText = statusText;
59      }
60  
61      public boolean isSuccessful() {
62          return successful;
63      }
64  
65      public void setSuccessful(boolean successful) {
66          this.successful = successful;
67      }
68  
69      public Map<String, String> getHeaders() {
70          return headers;
71      }
72  
73      public void setHeaders(Map<String, String> headers) {
74          this.headers = headers;
75      }
76  }