use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class ChatAsyncImplClientTest method canRepeatCreateThread.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canRepeatCreateThread(HttpClient httpClient) throws ExecutionException, InterruptedException {
setupTest(httpClient);
UUID uuid = UUID.randomUUID();
final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadMember.getId(), secondThreadMember.getId());
CompletableFuture<Response<CreateChatThreadResult>> completableFuture1 = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, uuid.toString());
assertNotNull(completableFuture1);
Response<CreateChatThreadResult> response1 = completableFuture1.get();
assertNotNull(response1);
CreateChatThreadResult result1 = response1.getValue();
assertNotNull(result1);
assertNotNull(result1.getChatThread());
assertNotNull(result1.getChatThread().getId());
String expectedThreadId = response1.getValue().getChatThread().getId();
CompletableFuture<Response<CreateChatThreadResult>> completableFuture2 = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, uuid.toString());
assertNotNull(completableFuture2);
Response<CreateChatThreadResult> response2 = completableFuture2.get();
assertNotNull(response2);
CreateChatThreadResult result2 = response2.getValue();
assertNotNull(result2);
assertNotNull(result2.getChatThread());
assertNotNull(result2.getChatThread().getId());
assertEquals(expectedThreadId, result2.getChatThread().getId());
CompletableFuture<Response<CreateChatThreadResult>> completableFuture3 = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, UUID.randomUUID().toString());
assertNotNull(completableFuture3);
Response<CreateChatThreadResult> response3 = completableFuture3.get();
assertNotNull(response3);
CreateChatThreadResult result3 = response3.getValue();
assertNotNull(result3);
assertNotNull(result3.getChatThread());
assertNotNull(result3.getChatThread().getId());
assertNotEquals(expectedThreadId, result3.getChatThread().getId());
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class ChatAsyncImplClientTest method canDeleteChatThreadWithResponse.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canDeleteChatThreadWithResponse(HttpClient httpClient) throws ExecutionException, InterruptedException {
setupTest(httpClient);
final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadMember.getId(), secondThreadMember.getId());
CompletableFuture<Response<CreateChatThreadResult>> completableFuture1 = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, null);
assertNotNull(completableFuture1);
Response<CreateChatThreadResult> response1 = completableFuture1.get();
assertNotNull(response1);
CreateChatThreadResult result1 = response1.getValue();
assertNotNull(result1);
assertNotNull(result1.getChatThread());
assertNotNull(result1.getChatThread().getId());
CompletableFuture<Response<Void>> completableFuture2 = this.client.getChatClient().deleteChatThreadWithResponseAsync(result1.getChatThread().getId());
assertNotNull(completableFuture2);
Response<Void> response2 = completableFuture2.get();
assertNotNull(response2);
Void result2 = response2.getValue();
assertNull(result2);
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class ChatAsyncImplClientTest method canCreateThreadWithResponse.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canCreateThreadWithResponse(HttpClient httpClient) throws ExecutionException, InterruptedException {
setupTest(httpClient);
final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadMember.getId(), secondThreadMember.getId());
CompletableFuture<Response<CreateChatThreadResult>> completableFuture = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, null);
assertNotNull(completableFuture);
Response<CreateChatThreadResult> response = completableFuture.get();
assertNotNull(response);
CreateChatThreadResult result = response.getValue();
assertNotNull(result);
assertNotNull(result.getChatThread());
assertNotNull(result.getChatThread().getId());
}
use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.
the class RestProxyTests method service19PutWithHeaderApplicationOctetStreamContentTypeAndByteArrayBodyWithEmptyBody.
@Test
public void service19PutWithHeaderApplicationOctetStreamContentTypeAndByteArrayBodyWithEmptyBody() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
createService(Service19.class).putWithHeaderApplicationOctetStreamContentTypeAndByteArrayBody(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, "service19PutWithHeaderApplicationOctetStreamContentTypeAndByteArrayBodyWithEmptyBody");
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 service19PutWithHeaderApplicationOctetStreamContentTypeAndStringBodyWithNullBody.
@Test
public void service19PutWithHeaderApplicationOctetStreamContentTypeAndStringBodyWithNullBody() {
CountDownLatch latch = new CountDownLatch(1);
CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
createService(Service19.class).putWithHeaderApplicationOctetStreamContentTypeAndStringBody(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, "service19PutWithHeaderApplicationOctetStreamContentTypeAndStringBodyWithNullBody");
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