Repository: zeppelin
Updated Branches:
  refs/heads/master 91b5d69be -> fffdf2587


ZEPPELIN-3150. Fixed Checkstyle errors and warnings in the bigquery module

### What is this PR for?
Fixed the Checkstyle errors and warnings in the bigquery module.

### What type of PR is it?
Improvement

### Todos
* [ ] - Task

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-3150

### How should this be tested?
* CI pass

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Jan Hentschel <jan.hentsc...@ultratendency.com>

Closes #2783 from HorizonNet/ZEPPELIN-3150 and squashes the following commits:

5ab3caa [Jan Hentschel] ZEPPELIN-3150. Removed SuppressWarnings annotation in 
BigQueryInterpreterTest
c6be5be [Jan Hentschel] ZEPPELIN-3150. Fixed Checkstyle errors and warnings in 
the bigquery module


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/fffdf258
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/fffdf258
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/fffdf258

Branch: refs/heads/master
Commit: fffdf258704c1937a570e3974ff64ade58df7b73
Parents: 91b5d69
Author: Jan Hentschel <jan.hentsc...@ultratendency.com>
Authored: Sun Feb 11 14:14:14 2018 +0100
Committer: Jeff Zhang <zjf...@apache.org>
Committed: Wed Feb 14 12:42:42 2018 +0800

----------------------------------------------------------------------
 bigquery/pom.xml                                |  7 ++
 .../zeppelin/bigquery/BigQueryInterpreter.java  | 68 +++++++-------------
 .../bigquery/BigQueryInterpreterTest.java       | 47 ++++----------
 3 files changed, 43 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/fffdf258/bigquery/pom.xml
----------------------------------------------------------------------
diff --git a/bigquery/pom.xml b/bigquery/pom.xml
index c116c2f..66fe3f2 100644
--- a/bigquery/pom.xml
+++ b/bigquery/pom.xml
@@ -133,6 +133,13 @@
           </descriptorRefs>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <skip>false</skip>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/fffdf258/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java
----------------------------------------------------------------------
diff --git 
a/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java 
b/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java
index ca06964..2cd6d47 100644
--- 
a/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java
+++ 
b/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java
@@ -16,62 +16,44 @@
 
 package org.apache.zeppelin.bigquery;
 
-
-import static org.apache.commons.lang.StringUtils.containsIgnoreCase;
-
+import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
 import com.google.api.client.http.HttpTransport;
 import com.google.api.client.http.javanet.NetHttpTransport;
+import com.google.api.client.json.GenericJson;
 import com.google.api.client.json.JsonFactory;
-import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
 import com.google.api.client.json.jackson2.JacksonFactory;
-
 import com.google.api.services.bigquery.Bigquery;
-import com.google.api.services.bigquery.BigqueryScopes;
-import com.google.api.client.json.GenericJson;
-import com.google.api.services.bigquery.Bigquery.Datasets;
+import com.google.api.services.bigquery.Bigquery.Jobs.GetQueryResults;
 import com.google.api.services.bigquery.BigqueryRequest;
-import com.google.api.services.bigquery.model.DatasetList;
+import com.google.api.services.bigquery.BigqueryScopes;
+import com.google.api.services.bigquery.model.GetQueryResultsResponse;
 import com.google.api.services.bigquery.model.Job;
+import com.google.api.services.bigquery.model.JobCancelResponse;
+import com.google.api.services.bigquery.model.QueryRequest;
+import com.google.api.services.bigquery.model.QueryResponse;
 import com.google.api.services.bigquery.model.TableCell;
 import com.google.api.services.bigquery.model.TableFieldSchema;
 import com.google.api.services.bigquery.model.TableRow;
-import com.google.api.services.bigquery.model.TableSchema;
-import com.google.api.services.bigquery.Bigquery.Jobs.GetQueryResults;
-import com.google.api.services.bigquery.model.GetQueryResultsResponse;
-import com.google.api.services.bigquery.model.QueryRequest;
-import com.google.api.services.bigquery.model.QueryResponse;
-import com.google.api.services.bigquery.model.JobCancelResponse;
-import com.google.gson.Gson;
+import com.google.common.base.Function;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
 import java.util.Properties;
-import java.util.Set;
 
 import org.apache.zeppelin.interpreter.Interpreter;
 import org.apache.zeppelin.interpreter.InterpreterContext;
-import org.apache.zeppelin.interpreter.InterpreterPropertyBuilder;
 import org.apache.zeppelin.interpreter.InterpreterResult;
 import org.apache.zeppelin.interpreter.InterpreterResult.Code;
 import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
 import org.apache.zeppelin.scheduler.Scheduler;
 import org.apache.zeppelin.scheduler.SchedulerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.collect.Sets.SetView;
-import java.io.PrintStream;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
 
 /**
  * BigQuery interpreter for Zeppelin.
@@ -95,10 +77,7 @@ import java.util.NoSuchElementException;
  * </p>
  * 
  */
-
-
 public class BigQueryInterpreter extends Interpreter {
-
   private static Logger logger = 
LoggerFactory.getLogger(BigQueryInterpreter.class);
   private static final char NEWLINE = '\n';
   private static final char TAB = '\t';
@@ -128,7 +107,6 @@ public class BigQueryInterpreter extends Interpreter {
     super(property);
   }
 
-
   //Function to return valid BigQuery Service
   @Override
   public void open() {
@@ -182,7 +160,7 @@ public class BigQueryInterpreter extends Interpreter {
         msg.append(NEWLINE);
       }
       return msg.toString();
-    } catch ( NullPointerException ex ) {
+    } catch (NullPointerException ex) {
       throw new NullPointerException("SQL Execution returned an error!");
     }
   }
@@ -207,7 +185,7 @@ public class BigQueryInterpreter extends Interpreter {
     class PageIterator implements Iterator<T> {
       private BigqueryRequest<T> request;
       private boolean hasNext = true;
-      public PageIterator(final BigqueryRequest<T> requestTemplate) {
+      PageIterator(final BigqueryRequest<T> requestTemplate) {
         this.request = requestTemplate;
       }
       public boolean hasNext() {
@@ -251,7 +229,7 @@ public class BigQueryInterpreter extends Interpreter {
     Iterator<GetQueryResultsResponse> pages;
     try {
       pages = run(sql, projId, wTime, maxRows, useLegacySql);
-    } catch ( IOException ex ) {
+    } catch (IOException ex) {
       logger.error(ex.getMessage());
       return new InterpreterResult(Code.ERROR, ex.getMessage());
     }
@@ -260,15 +238,15 @@ public class BigQueryInterpreter extends Interpreter {
         finalmessage.append(printRows(pages.next()));
       }
       return new InterpreterResult(Code.SUCCESS, finalmessage.toString());
-    } catch ( NullPointerException ex ) {
+    } catch (NullPointerException ex) {
       return new InterpreterResult(Code.ERROR, ex.getMessage());
     }
   }
 
   //Function to run the SQL on bigQuery service
   public static Iterator<GetQueryResultsResponse> run(final String queryString,
-    final String projId, final long wTime, final long maxRows, boolean 
useLegacySql)
-      throws IOException {
+      final String projId, final long wTime, final long maxRows, boolean 
useLegacySql)
+          throws IOException {
     try {
       logger.info("Use legacy sql: {}", useLegacySql);
       QueryResponse query;
@@ -292,7 +270,6 @@ public class BigQueryInterpreter extends Interpreter {
 
   @Override
   public void close() {
-
     logger.info("Close bqsql connection!");
 
     service = null;
@@ -322,7 +299,6 @@ public class BigQueryInterpreter extends Interpreter {
 
   @Override
   public void cancel(InterpreterContext context) {
-
     logger.info("Trying to Cancel current query statement.");
 
     if (service != null && jobId != null && projectId != null) {

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/fffdf258/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java
----------------------------------------------------------------------
diff --git 
a/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java
 
b/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java
index 53c4dc3..2ffc67b 100644
--- 
a/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java
+++ 
b/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java
@@ -14,41 +14,27 @@
 * limitations under the License.
 */
 
-
 package org.apache.zeppelin.bigquery;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Properties;
-
-import org.apache.zeppelin.display.AngularObjectRegistry;
-import org.apache.zeppelin.display.GUI;
-import org.apache.zeppelin.interpreter.InterpreterContext;
-import org.apache.zeppelin.interpreter.InterpreterContextRunner;
-import org.apache.zeppelin.interpreter.InterpreterGroup;
-import org.apache.zeppelin.interpreter.InterpreterOutput;
-import org.apache.zeppelin.interpreter.InterpreterOutputListener;
-import org.apache.zeppelin.interpreter.InterpreterResult;
-import org.apache.zeppelin.interpreter.InterpreterResult.Type;
-import org.apache.zeppelin.user.AuthenticationInfo;
-import org.junit.Before;
-import org.junit.Test;
 
 import com.google.gson.Gson;
 import com.google.gson.JsonIOException;
 import com.google.gson.JsonSyntaxException;
 
+import org.junit.Before;
+import org.junit.Test;
+
 import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.util.Properties;
 
-public class BigQueryInterpreterTest {
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterGroup;
+import org.apache.zeppelin.interpreter.InterpreterResult;
 
+public class BigQueryInterpreterTest {
   protected static class Constants {
     private String projectId;
     private String oneQuery;
@@ -65,17 +51,15 @@ public class BigQueryInterpreterTest {
     public String getWrong()  {
       return wrongQuery;
     }
-
   }
 
-  @SuppressWarnings("checkstyle:abbreviationaswordinname")
-  protected static Constants CONSTANTS = null;
+  protected static Constants constants = null;
 
   public BigQueryInterpreterTest()
       throws JsonSyntaxException, JsonIOException, FileNotFoundException {
-    if (CONSTANTS == null) {
+    if (constants == null) {
       InputStream is = this.getClass().getResourceAsStream("/constants.json");
-      CONSTANTS = (new Gson()).<Constants>fromJson(new InputStreamReader(is), 
Constants.class);
+      constants = (new Gson()).<Constants>fromJson(new InputStreamReader(is), 
Constants.class);
     }
   }
 
@@ -87,7 +71,7 @@ public class BigQueryInterpreterTest {
   @Before
   public void setUp() throws Exception {
     Properties p = new Properties();
-    p.setProperty("zeppelin.bigquery.project_id", CONSTANTS.getProjectId());
+    p.setProperty("zeppelin.bigquery.project_id", constants.getProjectId());
     p.setProperty("zeppelin.bigquery.wait_time", "5000");
     p.setProperty("zeppelin.bigquery.max_no_of_rows", "100");
 
@@ -96,23 +80,20 @@ public class BigQueryInterpreterTest {
     bqInterpreter = new BigQueryInterpreter(p);
     bqInterpreter.setInterpreterGroup(intpGroup);
     bqInterpreter.open();
-
   }
 
   @Test
   public void sqlSuccess() {
-    InterpreterResult ret = bqInterpreter.interpret(CONSTANTS.getOne(), 
context);
+    InterpreterResult ret = bqInterpreter.interpret(constants.getOne(), 
context);
 
     assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
     assertEquals(ret.message().get(0).getType(), InterpreterResult.Type.TABLE);
-
   }
 
   @Test
   public void badSqlSyntaxFails() {
-    InterpreterResult ret = bqInterpreter.interpret(CONSTANTS.getWrong(), 
context);
+    InterpreterResult ret = bqInterpreter.interpret(constants.getWrong(), 
context);
 
     assertEquals(InterpreterResult.Code.ERROR, ret.code());
   }
-
 }

Reply via email to