-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix checkstyle errors in BigQuery sample tests.
- Loading branch information
Showing
9 changed files
with
233 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 35 additions & 24 deletions
59
bigquery/src/test/java/com/google/cloud/bigquery/samples/test/AsyncQuerySampleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,60 @@ | ||
/* | ||
* Copyright (c) 2015 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. You may obtain a | ||
* copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.google.cloud.bigquery.samples.test; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
import com.google.api.services.bigquery.model.GetQueryResultsResponse; | ||
import com.google.cloud.bigquery.samples.AsyncQuerySample; | ||
import com.google.gson.JsonIOException; | ||
import com.google.gson.JsonSyntaxException; | ||
|
||
import org.junit.*; | ||
|
||
import static org.junit.Assert.*; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.util.Iterator; | ||
|
||
/** | ||
* Tests for asynchronous query sample. | ||
*/ | ||
public class AsyncQuerySampleTest extends BigquerySampleTest{ | ||
|
||
/** | ||
* @throws JsonSyntaxException | ||
* @throws JsonIOException | ||
* @throws FileNotFoundException | ||
*/ | ||
public AsyncQuerySampleTest() throws JsonSyntaxException, JsonIOException, | ||
FileNotFoundException { | ||
public AsyncQuerySampleTest() throws JsonSyntaxException, JsonIOException, FileNotFoundException { | ||
super(); | ||
// TODO(elibixby): Auto-generated constructor stub | ||
} | ||
|
||
|
||
@Test | ||
public void testInteractive() throws IOException, InterruptedException{ | ||
Iterator<GetQueryResultsResponse> pages = AsyncQuerySample.run(CONSTANTS.getProjectId(), CONSTANTS.getQuery(), false, 5000); | ||
while(pages.hasNext()){ | ||
assertTrue(!pages.next().getRows().isEmpty()); | ||
public void testInteractive() throws IOException, InterruptedException { | ||
Iterator<GetQueryResultsResponse> pages = | ||
AsyncQuerySample.run(CONSTANTS.getProjectId(), CONSTANTS.getQuery(), false, 5000); | ||
while (pages.hasNext()) { | ||
assertThat(pages.next().getRows()).isNotEmpty(); | ||
} | ||
} | ||
|
||
|
||
|
||
@Test | ||
@Ignore // Batches can take up to 3 hours to run, probably shouldn't use this | ||
public void testBatch() throws IOException, InterruptedException{ | ||
Iterator<GetQueryResultsResponse> pages = AsyncQuerySample.run(CONSTANTS.getProjectId(), CONSTANTS.getQuery(), true, 5000); | ||
while(pages.hasNext()){ | ||
assertTrue(!pages.next().getRows().isEmpty()); | ||
public void testBatch() throws IOException, InterruptedException { | ||
Iterator<GetQueryResultsResponse> pages = | ||
AsyncQuerySample.run(CONSTANTS.getProjectId(), CONSTANTS.getQuery(), true, 5000); | ||
while (pages.hasNext()) { | ||
assertThat(pages.next().getRows()).isNotEmpty(); | ||
} | ||
} | ||
|
||
|
||
} |
83 changes: 41 additions & 42 deletions
83
bigquery/src/test/java/com/google/cloud/bigquery/samples/test/BigquerySampleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,83 @@ | ||
/* | ||
* Copyright (c) 2015 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. You may obtain a | ||
* copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.google.cloud.bigquery.samples.test; | ||
|
||
import com.google.cloud.bigquery.samples.BigqueryUtils; | ||
import com.google.gson.Gson; | ||
import com.google.gson.JsonIOException; | ||
import com.google.gson.JsonSyntaxException; | ||
|
||
import java.io.*; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
|
||
/** | ||
* TODO: Insert description here. (generated by elibixby) | ||
* Superclass for tests for samples. | ||
*/ | ||
public class BigquerySampleTest extends BigqueryUtils { | ||
|
||
protected static class Constants{ | ||
protected static class Constants { | ||
private String projectId; | ||
private String datasetId; | ||
private String currentTableId; | ||
private String newTableId; | ||
private String cloudStorageInputURI; | ||
private String cloudStorageOutputURI; | ||
private String cloudStorageInputUri; | ||
private String cloudStorageOutputUri; | ||
private String query; | ||
/** | ||
* @return the projectId | ||
*/ | ||
|
||
public String getProjectId() { | ||
return projectId; | ||
} | ||
/** | ||
* @return the datasetId | ||
*/ | ||
|
||
public String getDatasetId() { | ||
return datasetId; | ||
} | ||
/** | ||
* @return the currentTableId | ||
*/ | ||
|
||
public String getCurrentTableId() { | ||
return currentTableId; | ||
} | ||
/** | ||
* @return the newTableId | ||
*/ | ||
|
||
public String getNewTableId() { | ||
return newTableId; | ||
} | ||
/** | ||
* @return the query | ||
*/ | ||
|
||
public String getQuery() { | ||
return query; | ||
} | ||
/** | ||
* @return the cloudStorageOutputURI | ||
*/ | ||
|
||
@SuppressWarnings("checkstyle:abbreviationaswordinname") | ||
public String getCloudStorageOutputURI() { | ||
return cloudStorageOutputURI; | ||
return cloudStorageOutputUri; | ||
} | ||
/** | ||
* @return the cloudStorageInputURI | ||
*/ | ||
|
||
@SuppressWarnings("checkstyle:abbreviationaswordinname") | ||
public String getCloudStorageInputURI() { | ||
return cloudStorageInputURI; | ||
return cloudStorageInputUri; | ||
} | ||
} | ||
|
||
protected static Constants CONSTANTS = null ; | ||
@SuppressWarnings("checkstyle:abbreviationaswordinname") | ||
protected static Constants CONSTANTS = null; | ||
|
||
protected BigquerySampleTest() throws JsonSyntaxException, JsonIOException, FileNotFoundException{ | ||
if(CONSTANTS == null){ | ||
InputStream is = this.getClass().getResourceAsStream | ||
("/constants.json"); | ||
CONSTANTS = (new Gson()).<Constants>fromJson( | ||
new InputStreamReader(is), | ||
Constants.class); | ||
protected BigquerySampleTest() | ||
throws JsonSyntaxException, JsonIOException, FileNotFoundException { | ||
if (CONSTANTS == null) { | ||
InputStream is = this.getClass().getResourceAsStream("/constants.json"); | ||
CONSTANTS = (new Gson()).<Constants>fromJson(new InputStreamReader(is), Constants.class); | ||
} | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.