use of com.amplifyframework.api.rest.RestResponse in project amplify-android by aws-amplify.
the class AWSRestOperationTest method responseEmittedWhenOperationSucceeds.
/**
* Tests the happy path, wherein the server returns a response, the
* operation hasn't been canceled, and we get a {@link RestResponse}
* at the end of it.
* @throws ApiException
* A possible outcome of the operation. This is not
* expected, and would constitute a test failure.
*/
@Test
public void responseEmittedWhenOperationSucceeds() throws ApiException {
RestOperationRequest request = new RestOperationRequest(HttpMethod.GET, baseUrl.uri().getPath(), emptyMap(), emptyMap());
RestResponse response = Await.<RestResponse, ApiException>result((onResult, onError) -> {
AWSRestOperation operation = new AWSRestOperation(request, baseUrl.url().toString(), client, onResult, onError);
operation.start();
});
assertTrue(response.getCode().isSuccessful());
Map<String, String> expected = new HashMap<>();
expected.put("foo", "bar,baz");
expected.put("qux", "quux");
expected.put("content-length", "21");
assertEquals(expected, response.getHeaders());
}
Aggregations