use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method service20GetResponseBody.
@Test
public void service20GetResponseBody() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
createService(Service20.class).putBody("body string", new Callback<Response<HttpBinJSON>>() {
@Override
public void onSuccess(Response<HttpBinJSON> response) {
cbResult.response = response;
latch.countDown();
}
@Override
public void onFailure(Throwable error) {
cbResult.error = error;
latch.countDown();
}
});
awaitOnLatch(latch, "service20GetResponseBody");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<HttpBinJSON> response = cbResult.response;
assertNotNull(response);
assertEquals(200, response.getStatusCode());
final HttpBinJSON body = response.getValue();
assertNotNull(body);
assertMatchWithHttpOrHttps("localhost/put", body.url());
assertEquals("body string", body.data());
final HttpHeaders headers = response.getHeaders();
assertNotNull(headers);
}
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method service19PutWithBodyParamApplicationJsonContentTypeAndStringBodyWithNullBody.
@Test
public void service19PutWithBodyParamApplicationJsonContentTypeAndStringBodyWithNullBody() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
createService(Service19.class).putWithBodyParamApplicationJsonContentTypeAndStringBody(null, new Callback<Response<HttpBinJSON>>() {
@Override
public void onSuccess(Response<HttpBinJSON> response) {
cbResult.response = response;
latch.countDown();
}
@Override
public void onFailure(Throwable error) {
cbResult.error = error;
latch.countDown();
}
});
awaitOnLatch(latch, "service19PutWithBodyParamApplicationJsonContentTypeAndStringBodyWithNullBody");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<HttpBinJSON> response = cbResult.response;
HttpBinJSON json = response.getValue();
Assertions.assertNotNull(json);
assertEquals("", json.data());
}
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method getRequestWithQueryParametersAndAnythingWithEncodedWithPercent20.
@Test
public void getRequestWithQueryParametersAndAnythingWithEncodedWithPercent20() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
createService(Service6.class).getAnythingWithEncoded("x%20y", 15, new Callback<Response<HttpBinJSON>>() {
@Override
public void onSuccess(Response<HttpBinJSON> response) {
cbResult.response = response;
latch.countDown();
}
@Override
public void onFailure(Throwable error) {
cbResult.error = error;
latch.countDown();
}
});
awaitOnLatch(latch, "getRequestWithQueryParametersAndAnythingWithEncodedWithPercent20");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<HttpBinJSON> response = cbResult.response;
Assertions.assertNotNull(response);
HttpBinJSON json = response.getValue();
assertNotNull(json);
assertMatchWithHttpOrHttps("localhost/anything?a=x y&b=15", json.url());
}
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method service18GetStatus200.
@Test
public void service18GetStatus200() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<Void> cbResult = new CallbackResult<>();
createService(Service18.class).getStatus200(new Callback<Response<Void>>() {
@Override
public void onSuccess(Response<Void> response) {
cbResult.response = response;
latch.countDown();
}
@Override
public void onFailure(Throwable error) {
cbResult.error = error;
latch.countDown();
}
});
awaitOnLatch(latch, "service18GetStatus200");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<Void> response = cbResult.response;
Assertions.assertEquals(200, response.getStatusCode());
}
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method service22GetBytes.
@Test
public void service22GetBytes() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<byte[]> cbResult = new CallbackResult<>();
createService(Service22.class).getBytes("http://localhost/bytes/27", new Callback<Response<byte[]>>() {
@Override
public void onSuccess(Response<byte[]> response) {
cbResult.response = response;
latch.countDown();
}
@Override
public void onFailure(Throwable error) {
cbResult.error = error;
latch.countDown();
}
});
awaitOnLatch(latch, "simpleDownloadResponseTest");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<byte[]> response = cbResult.response;
assertNotNull(response);
assertEquals(200, response.getStatusCode());
byte[] bytes = response.getValue();
assertNotNull(bytes);
assertEquals(27, bytes.length);
}
}
Aggregations