Skip to content

Commit

Permalink
Avoid trivial deprecations in test codes (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego authored Jan 31, 2023
1 parent 77d364f commit d1c2140
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import java.util.Optional;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down
47 changes: 21 additions & 26 deletions src/test/java/com/treasuredata/client/TestTDClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@
import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.msgpack.core.MessagePack;
import org.msgpack.core.MessagePacker;
import org.msgpack.core.MessageUnpacker;
Expand Down Expand Up @@ -114,9 +112,10 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand All @@ -125,9 +124,6 @@
*/
public class TestTDClient
{
@Rule
public ExpectedException exception = ExpectedException.none();

private static final Logger logger = LoggerFactory.getLogger(TestTDClient.class);

private static final String SAMPLE_DB = "_tdclient_test";
Expand Down Expand Up @@ -563,14 +559,13 @@ public void submitPrestoJobWithPoolName()
public void submitPrestoJobWithInvalidPoolName()
throws Exception
{
exception.expect(TDClientHttpException.class);
exception.expectMessage("Presto resource pool with name 'no_such_pool' does not exist");

client.deleteTableIfExists(SAMPLE_DB, "sample_output");
String poolName = "no_such_pool";
String jobId = client.submit(TDJobRequest.newPrestoQuery("sample_datasets", "-- td-client-java test\nselect count(*) from nasdaq", null, poolName));
TDJobSummary tdJob = waitJobCompletion(jobId);
client.existsTable(SAMPLE_DB, "sample_output");
assertThrows("Presto resource pool with name 'no_such_pool' does not exist", TDClientHttpException.class, () -> {
client.deleteTableIfExists(SAMPLE_DB, "sample_output");
String poolName = "no_such_pool";
String jobId = client.submit(TDJobRequest.newPrestoQuery("sample_datasets", "-- td-client-java test\nselect count(*) from nasdaq", null, poolName));
TDJobSummary tdJob = waitJobCompletion(jobId);
client.existsTable(SAMPLE_DB, "sample_output");
});
}

@Test
Expand Down Expand Up @@ -696,7 +691,7 @@ public void submitBulkLoadJob()
ObjectNode config = JsonNodeFactory.instance.objectNode();
ObjectNode in = JsonNodeFactory.instance.objectNode();
in.put("type", "s3");
config.put("in", in);
config.set("in", in);
client.createDatabaseIfNotExists(SAMPLE_DB);
client.createTableIfNotExists(SAMPLE_DB, "sample_output");
String jobId = client.submit(TDJobRequest.newBulkLoad(SAMPLE_DB, "sample_output", config));
Expand Down Expand Up @@ -799,17 +794,17 @@ public void startSavedQueryWithDomainKey()
public void submitExportJob()
throws Exception
{
TDExportJobRequest jobRequest = new TDExportJobRequest(
SAMPLE_DB,
"sample_output",
new Date(0L),
new Date(1456522300L * 1000),
TDExportFileFormatType.JSONL_GZ,
"access key id",
"secret access key",
"bucket",
"prefix/",
Optional.empty());
TDExportJobRequest jobRequest = TDExportJobRequest.builder()
.database(SAMPLE_DB)
.table("sample_output")
.from(new Date(0L))
.to(new Date(1456522300L * 1000))
.fileFormat(TDExportFileFormatType.JSONL_GZ)
.accessKeyId("access key id")
.secretAccessKey("secret access key")
.bucketName("bucket")
.filePrefix("prefix/")
.poolName(Optional.empty()).build();
client.createDatabaseIfNotExists(SAMPLE_DB);
client.createTableIfNotExists(SAMPLE_DB, "sample_output");
String jobId = client.submitExportJob(jobRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
import static com.treasuredata.client.TDClientConfig.Type.USER;
import static com.treasuredata.client.TDClientConfig.Type.USESSL;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.exparity.hamcrest.date.DateMatchers.within;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import static com.treasuredata.client.model.ObjectMappers.compactMapper;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class TDBulkLoadSessionStartRequestTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.junit.Test;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class TDUserTest
{
Expand Down

0 comments on commit d1c2140

Please # to comment.