@Ignore("Can cause flakiness - only run manually") public void put202Retry200Async() throws Exception { final CountDownLatch lock = new CountDownLatch(1); long startTime = System.currentTimeMillis(); final long[] callbackTime = new long[1]; Product product = new Product(); product.setLocation("West US"); client.getAzureClient().setLongRunningOperationRetryTimeout(1); client .getLROsOperations() .put202Retry200Async( product, new ServiceCallback<Product>() { @Override public void failure(Throwable t) { fail(); } @Override public void success(ServiceResponse<Product> result) { Assert.assertEquals(200, result.getResponse().code()); Assert.assertEquals("100", result.getBody().getId()); callbackTime[0] = System.currentTimeMillis(); lock.countDown(); } }); long endTime = System.currentTimeMillis(); Assert.assertTrue(500 > endTime - startTime); Assert.assertTrue(lock.await(3000, TimeUnit.MILLISECONDS)); client.getAzureClient().setLongRunningOperationRetryTimeout(0); Assert.assertTrue(1000 < callbackTime[0] - startTime); }
@Test public void postAsyncRetrySucceeded() throws Exception { Product product = new Product(); product.setLocation("West US"); ServiceResponse<Product> response = client.getLROsOperations().postAsyncRetrySucceeded(product); Assert.assertEquals(200, response.getResponse().code()); }
@Test public void deleteProvisioning202Deletingcanceled200() throws Exception { ServiceResponse<Product> response = client.getLROsOperations().deleteProvisioning202Deletingcanceled200(); Assert.assertEquals(200, response.getResponse().code()); Assert.assertEquals("Canceled", response.getBody().getProvisioningState()); }
@Test public void putSubResource() throws Exception { SubProduct subProduct = new SubProduct(); ServiceResponse<SubProduct> response = client.getLROsOperations().putSubResource(subProduct); Assert.assertEquals(200, response.getResponse().code()); Assert.assertEquals("Succeeded", response.getBody().getProvisioningState()); }
@Test public void putAsyncNonResource() throws Exception { Sku sku = new Sku(); ServiceResponse<Sku> response = client.getLROsOperations().putAsyncNonResource(sku); Assert.assertEquals(200, response.getResponse().code()); Assert.assertEquals("100", response.getBody().getId()); }
@Test public void put202Retry200() throws Exception { Product product = new Product(); product.setLocation("West US"); ServiceResponse<Product> response = client.getLROsOperations().put202Retry200(product); Assert.assertEquals(200, response.getResponse().code()); Assert.assertEquals("100", response.getBody().getId()); }
@Test public void put200Succeeded() throws Exception { Product product = new Product(); product.setLocation("West US"); ServiceResponse<Product> response = client.getLROsOperations().put200Succeeded(product); Assert.assertEquals(200, response.getResponse().code()); Assert.assertEquals("Succeeded", response.getBody().getProvisioningState()); }
@Test public void deleteAsyncRetrycanceled() throws Exception { try { ServiceResponse<Void> response = client.getLROsOperations().deleteAsyncRetrycanceled(); fail(); } catch (CloudException e) { Assert.assertEquals("Async operation failed", e.getMessage()); } }
@Test public void postAsyncRetrycanceled() throws Exception { try { Product product = new Product(); product.setLocation("West US"); ServiceResponse<Void> response = client.getLROsOperations().postAsyncRetrycanceled(product); fail(); } catch (CloudException e) { Assert.assertEquals("Async operation failed", e.getMessage()); } }
@Test public void put200Acceptedcanceled200() throws Exception { Product product = new Product(); product.setLocation("West US"); try { ServiceResponse<Product> response = client.getLROsOperations().put200Acceptedcanceled200(product); fail(); } catch (CloudException e) { Assert.assertEquals("Async operation failed", e.getMessage()); } }
@Test public void post200WithPayload() throws Exception { ServiceResponse<Sku> response = client.getLROsOperations().post200WithPayload(); Assert.assertEquals(200, response.getResponse().code()); Assert.assertEquals("1", response.getBody().getId()); }
@Test public void deleteAsyncNoRetrySucceeded() throws Exception { ServiceResponse<Void> response = client.getLROsOperations().deleteAsyncNoRetrySucceeded(); Assert.assertEquals(200, response.getResponse().code()); }
@Test public void deleteNoHeaderInRetry() throws Exception { ServiceResponse<Void> response = client.getLROsOperations().deleteNoHeaderInRetry(); Assert.assertEquals(204, response.getResponse().code()); }
@Test public void delete202NoRetry204() throws Exception { ServiceResponse<Product> response = client.getLROsOperations().delete202NoRetry204(); Assert.assertEquals(204, response.getResponse().code()); }
@BeforeClass public static void setup() { client = new AutoRestLongRunningOperationTestServiceImpl("http://localhost.:3000", null); client.getAzureClient().setLongRunningOperationRetryTimeout(0); }