use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method patchRequest.
@Test
public void patchRequest() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
createService(Service12.class).patch("body-contents", 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, "patchRequest");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<HttpBinJSON> response = cbResult.response;
Assertions.assertNotNull(response);
Assertions.assertNotNull(response.getValue());
HttpBinJSON json = response.getValue();
assertEquals(String.class, json.data().getClass());
assertEquals("body-contents", json.data());
}
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method service19PutWithBodyParamApplicationJsonContentTypeAndByteArrayBodyWithEmptyBody.
@Test
public void service19PutWithBodyParamApplicationJsonContentTypeAndByteArrayBodyWithEmptyBody() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
createService(Service19.class).putWithBodyParamApplicationJsonContentTypeAndByteArrayBody(new byte[0], 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, "service19PutWithBodyParamApplicationJsonContentTypeAndByteArrayBodyWithEmptyBody");
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 service19PutWithHeaderApplicationJsonContentTypeAndCharsetAndStringBodyWithEmptyBody.
@Test
public void service19PutWithHeaderApplicationJsonContentTypeAndCharsetAndStringBodyWithEmptyBody() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
createService(Service19.class).putWithHeaderApplicationJsonContentTypeAndCharsetAndStringBody("", 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, "service19PutWithHeaderApplicationJsonContentTypeAndCharsetAndStringBodyWithEmptyBody");
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 service18GetStatus400WithExpectedResponse400.
@Test
public void service18GetStatus400WithExpectedResponse400() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<Void> cbResult = new CallbackResult<>();
createService(Service18.class).getStatus400WithExpectedResponse400(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, "service18GetStatus400WithExpectedResponse400");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<Void> response = cbResult.response;
Assertions.assertEquals(400, response.getStatusCode());
}
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method postRequestWithNullBody.
@Test
public void postRequestWithNullBody() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
createService(Service8.class).post(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, "postRequestWithNullBody");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<HttpBinJSON> response = cbResult.response;
Assertions.assertNotNull(response);
HttpBinJSON json = response.getValue();
assertEquals("", json.data());
}
}
Aggregations