Skip to content

Commit

Permalink
Remove CosmosThrottled
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Siegel committed Sep 9, 2020
1 parent 5f59638 commit d64917d
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 261 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
public class TableServiceAsyncClientTest extends TestBase {
private static final Duration TIMEOUT = Duration.ofSeconds(100);
private CosmosThrottled<TableServiceAsyncClient> runner;
private TableServiceAsyncClient serviceClient;

@BeforeAll
static void beforeAll() {
Expand Down Expand Up @@ -57,7 +57,7 @@ protected void beforeTest() {
Duration.ofSeconds(100))));
}

runner = CosmosThrottled.get(builder.buildAsyncClient(), interceptorManager.isPlaybackMode());
serviceClient = builder.buildAsyncClient();
}

@Test
Expand All @@ -66,7 +66,7 @@ void serviceCreateTableAsync() {
String tableName = testResourceNamer.randomName("test", 20);

//Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.createTable(tableName)))
StepVerifier.create(serviceClient.createTable(tableName))
.expectComplete()
.verify();
}
Expand All @@ -75,10 +75,10 @@ void serviceCreateTableAsync() {
void serviceCreateTableFailsIfExistsAsync() {
// Arrange
String tableName = testResourceNamer.randomName("test", 20);
runner.run(serviceClient -> serviceClient.createTable(tableName).block(TIMEOUT));
serviceClient.createTable(tableName).block(TIMEOUT);

//Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.createTable(tableName)))
StepVerifier.create(serviceClient.createTable(tableName))
.expectErrorMatches(e -> e instanceof TableServiceErrorException
&& ((TableServiceErrorException) e).getResponse().getStatusCode() == 409)
.verify();
Expand All @@ -91,7 +91,7 @@ void serviceCreateTableWithResponseAsync() {
int expectedStatusCode = 204;

//Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.createTableWithResponse(tableName)))
StepVerifier.create(serviceClient.createTableWithResponse(tableName))
.assertNext(response -> {
Assertions.assertEquals(expectedStatusCode, response.getStatusCode());
})
Expand All @@ -105,7 +105,7 @@ void serviceCreateTableIfNotExistsAsync() {
String tableName = testResourceNamer.randomName("test", 20);

//Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.createTableIfNotExists(tableName)))
StepVerifier.create(serviceClient.createTableIfNotExists(tableName))
.expectComplete()
.verify();
}
Expand All @@ -114,10 +114,10 @@ void serviceCreateTableIfNotExistsAsync() {
void serviceCreateTableIfNotExistsSucceedsIfExistsAsync() {
// Arrange
String tableName = testResourceNamer.randomName("test", 20);
runner.run(serviceClient -> serviceClient.createTable(tableName).block(TIMEOUT));
serviceClient.createTable(tableName).block(TIMEOUT);

//Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.createTableIfNotExists(tableName)))
StepVerifier.create(serviceClient.createTableIfNotExists(tableName))
.expectComplete()
.verify();
}
Expand All @@ -129,7 +129,7 @@ void serviceCreateTableIfNotExistsWithResponseAsync() {
int expectedStatusCode = 204;

//Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.createTableIfNotExistsWithResponse(tableName)))
StepVerifier.create(serviceClient.createTableIfNotExistsWithResponse(tableName))
.assertNext(response -> {
Assertions.assertEquals(expectedStatusCode, response.getStatusCode());
})
Expand All @@ -142,10 +142,10 @@ void serviceCreateTableIfNotExistsWithResponseSucceedsIfExistsAsync() {
// Arrange
String tableName = testResourceNamer.randomName("test", 20);
int expectedStatusCode = 409;
runner.run(serviceClient -> serviceClient.createTable(tableName).block(TIMEOUT));
serviceClient.createTable(tableName).block(TIMEOUT);

//Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.createTableIfNotExistsWithResponse(tableName)))
StepVerifier.create(serviceClient.createTableIfNotExistsWithResponse(tableName))
.assertNext(response -> {
Assertions.assertEquals(expectedStatusCode, response.getStatusCode());
})
Expand All @@ -157,10 +157,10 @@ void serviceCreateTableIfNotExistsWithResponseSucceedsIfExistsAsync() {
void serviceDeleteTableAsync() {
// Arrange
final String tableName = testResourceNamer.randomName("test", 20);
runner.run(serviceClient -> serviceClient.createTable(tableName).block(TIMEOUT));
serviceClient.createTable(tableName).block(TIMEOUT);

//Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.deleteTable(tableName)))
StepVerifier.create(serviceClient.deleteTable(tableName))
.expectComplete()
.verify();
}
Expand All @@ -170,10 +170,10 @@ void serviceDeleteTableWithResponseAsync() {
// Arrange
String tableName = testResourceNamer.randomName("test", 20);
int expectedStatusCode = 204;
runner.run(serviceClient -> serviceClient.createTable(tableName).block());
serviceClient.createTable(tableName).block();

//Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.deleteTableWithResponse(tableName)))
StepVerifier.create(serviceClient.deleteTableWithResponse(tableName))
.assertNext(response -> {
Assertions.assertEquals(expectedStatusCode, response.getStatusCode());
})
Expand All @@ -187,11 +187,11 @@ void serviceListTablesAsync() {
// Arrange
final String tableName = testResourceNamer.randomName("test", 20);
final String tableName2 = testResourceNamer.randomName("test", 20);
runner.run(serviceClient -> serviceClient.createTable(tableName)).block(TIMEOUT);
runner.run(serviceClient -> serviceClient.createTable(tableName2)).block(TIMEOUT);
serviceClient.createTable(tableName).block(TIMEOUT);
serviceClient.createTable(tableName2).block(TIMEOUT);

// Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.listTables()))
StepVerifier.create(serviceClient.listTables())
.expectNextCount(2)
.thenConsumeWhile(x -> true)
.expectComplete()
Expand All @@ -205,11 +205,11 @@ void serviceListTablesWithFilterAsync() {
final String tableName = testResourceNamer.randomName("test", 20);
final String tableName2 = testResourceNamer.randomName("test", 20);
ListTablesOptions options = new ListTablesOptions().setFilter("TableName eq '" + tableName + "'");
runner.run(serviceClient -> serviceClient.createTable(tableName)).block(TIMEOUT);
runner.run(serviceClient -> serviceClient.createTable(tableName2)).block(TIMEOUT);
serviceClient.createTable(tableName).block(TIMEOUT);
serviceClient.createTable(tableName2).block(TIMEOUT);

// Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.listTables(options)))
StepVerifier.create(serviceClient.listTables(options))
.assertNext(table -> {
assertEquals(tableName, table.getName());
})
Expand All @@ -227,12 +227,12 @@ void serviceListTablesWithTopAsync() {
final String tableName2 = testResourceNamer.randomName("test", 20);
final String tableName3 = testResourceNamer.randomName("test", 20);
ListTablesOptions options = new ListTablesOptions().setTop(2);
runner.run(serviceClient -> serviceClient.createTable(tableName)).block(TIMEOUT);
runner.run(serviceClient -> serviceClient.createTable(tableName2)).block(TIMEOUT);
runner.run(serviceClient -> serviceClient.createTable(tableName3)).block(TIMEOUT);
serviceClient.createTable(tableName).block(TIMEOUT);
serviceClient.createTable(tableName2).block(TIMEOUT);
serviceClient.createTable(tableName3).block(TIMEOUT);

// Act & Assert
StepVerifier.create(runner.run(serviceClient -> serviceClient.listTables(options)))
StepVerifier.create(serviceClient.listTables(options))
.expectNextCount(2)
.thenConsumeWhile(x -> true)
.expectComplete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.time.Duration;

public class TableServiceClientTest extends TestBase {
private CosmosThrottled<TableServiceClient> runner;
private TableServiceClient serviceClient;

@Override
protected void beforeTest() {
Expand All @@ -35,7 +35,7 @@ protected void beforeTest() {
builder.addPolicy(new RetryPolicy(new ExponentialBackoff(6, Duration.ofMillis(1500),
Duration.ofSeconds(100))));
}
runner = CosmosThrottled.get(builder.buildClient(), interceptorManager.isPlaybackMode());
serviceClient = builder.buildClient();
}

@Test
Expand All @@ -44,18 +44,18 @@ void serviceCreateTable() {
String tableName = testResourceNamer.randomName("test", 20);

// Act & Assert
runner.runVoid(serviceClient -> serviceClient.createTable(tableName));
serviceClient.createTable(tableName);
}

@Test
void serviceCreateTableFailsIfExists() {
// Arrange
String tableName = testResourceNamer.randomName("test", 20);
runner.runVoid(serviceClient -> serviceClient.createTable(tableName));
serviceClient.createTable(tableName);

// Act & Assert
Assertions.assertThrows(TableServiceErrorException.class,
() -> runner.runVoid(serviceClient -> serviceClient.createTable(tableName)));
() -> serviceClient.createTable(tableName));
}

@Test
Expand All @@ -64,17 +64,17 @@ void serviceCreateTableIfNotExists() {
String tableName = testResourceNamer.randomName("test", 20);

// Act & Assert
runner.runVoid(serviceClient -> serviceClient.createTableIfNotExists(tableName));
serviceClient.createTableIfNotExists(tableName);
}

@Test
void serviceCreateTableIfNotExistsSucceedsIfExists() {
// Arrange
String tableName = testResourceNamer.randomName("test", 20);
runner.runVoid(serviceClient -> serviceClient.createTable(tableName));
serviceClient.createTable(tableName);

//Act & Assert
runner.runVoid(serviceClient -> serviceClient.createTableIfNotExists(tableName));
serviceClient.createTableIfNotExists(tableName);
}

@Test
Expand Down
Loading

0 comments on commit d64917d

Please sign in to comment.