use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method postUrlForm.
@Test
public void postUrlForm() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinFormDataJSON> cbResult = new CallbackResult<>();
Service26 service = createService(Service26.class);
service.postForm("Foo", "123", "foo@bar.com", HttpBinFormDataJSON.PizzaSize.LARGE, Arrays.asList("Bacon", "Onion"), new Callback<Response<HttpBinFormDataJSON>>() {
@Override
public void onSuccess(Response<HttpBinFormDataJSON> response) {
cbResult.response = response;
latch.countDown();
}
@Override
public void onFailure(Throwable error) {
cbResult.error = error;
latch.countDown();
}
});
awaitOnLatch(latch, "postUrlForm");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<HttpBinFormDataJSON> response = cbResult.response;
assertNotNull(response);
assertEquals(200, response.getStatusCode());
HttpBinFormDataJSON result = response.getValue();
assertNotNull(result);
assertNotNull(result.form());
assertEquals("Foo", result.form().customerName());
assertEquals("123", result.form().customerTelephone());
assertEquals("foo%40bar.com", result.form().customerEmail());
assertEquals(HttpBinFormDataJSON.PizzaSize.LARGE, result.form().pizzaSize());
assertEquals(2, result.form().toppings().size());
assertEquals("Bacon", result.form().toppings().get(0));
assertEquals("Onion", result.form().toppings().get(1));
}
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method service18GetStatus300WithExpectedResponse300.
@Test
public void service18GetStatus300WithExpectedResponse300() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<Void> cbResult = new CallbackResult<>();
createService(Service18.class).getStatus300WithExpectedResponse300(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, "service18GetStatus300WithExpectedResponse300");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<Void> response = cbResult.response;
Assertions.assertEquals(300, response.getStatusCode());
}
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method service19PutWithBodyParamApplicationJsonContentTypeAndCharsetAndStringBodyWithNonEmptyBody.
@Test
public void service19PutWithBodyParamApplicationJsonContentTypeAndCharsetAndStringBodyWithNonEmptyBody() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
createService(Service19.class).putWithBodyParamApplicationJsonContentTypeAndCharsetAndStringBody("soups and stuff", 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, "service19PutWithBodyParamApplicationJsonContentTypeAndCharsetAndStringBodyWithNonEmptyBody");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<HttpBinJSON> response = cbResult.response;
HttpBinJSON json = response.getValue();
Assertions.assertNotNull(json);
assertEquals("\"soups and stuff\"", json.data());
}
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method service18GetStatus300.
@Test
public void service18GetStatus300() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<Void> cbResult = new CallbackResult<>();
createService(Service18.class).getStatus300(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, "service18GetStatus300");
if (cbResult.error != null) {
Assertions.fail(cbResult.error);
} else {
final Response<Void> response = cbResult.response;
Assertions.assertEquals(300, response.getStatusCode());
}
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method service19PutWithHeaderApplicationOctetStreamContentTypeAndByteArrayBodyWithNullBody.
@Test
public void service19PutWithHeaderApplicationOctetStreamContentTypeAndByteArrayBodyWithNullBody() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
createService(Service19.class).putWithHeaderApplicationOctetStreamContentTypeAndByteArrayBody(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, "service19PutWithHeaderApplicationOctetStreamContentTypeAndByteArrayBodyWithNullBody");
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());
}
}
Aggregations