-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enrich BQSQLExceptions with a little more information for ALL exceptions
Should give more information related to #100
- Loading branch information
Jonathan Swenson
committed
Aug 4, 2021
1 parent
9a99300
commit fc7b888
Showing
2 changed files
with
48 additions
and
0 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
46 changes: 46 additions & 0 deletions
46
src/test/java/net/starschema/clouddb/jdbc/BQSQLExceptionTest.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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package net.starschema.clouddb.jdbc; | ||
|
||
import com.google.api.client.googleapis.json.GoogleJsonError; | ||
import com.google.api.client.googleapis.json.GoogleJsonResponseException; | ||
import com.google.api.client.http.HttpHeaders; | ||
import com.google.api.client.http.HttpResponseException; | ||
import java.io.IOException; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class BQSQLExceptionTest { | ||
|
||
@Test | ||
public void exceptionCauseEnrichmentIOExceptionTest() { | ||
IOException ioException = new IOException("Read timed out!"); | ||
BQSQLException exception = new BQSQLException("Oops! Something went wrong:", ioException); | ||
|
||
String actualMessage = exception.getMessage(); | ||
Assert.assertEquals("Oops! Something went wrong: - java.io.IOException: Read timed out!", actualMessage); | ||
} | ||
|
||
@Test | ||
public void exceptionCauseEnrichmentGoogleJsonResponseExceptionTest() { | ||
HttpHeaders headers = new HttpHeaders(); | ||
HttpResponseException.Builder builder = new HttpResponseException.Builder( | ||
403,"you can't see this", headers | ||
); | ||
GoogleJsonError error = new GoogleJsonError(); | ||
error.setMessage("You don't have access"); | ||
GoogleJsonResponseException cause = new GoogleJsonResponseException(builder, error); | ||
BQSQLException exception = new BQSQLException("Oops! Something went wrong:", cause); | ||
|
||
String actualMessage = exception.getMessage(); | ||
Assert.assertEquals("Oops! Something went wrong: - You don't have access", actualMessage); | ||
} | ||
|
||
@Test | ||
public void exceptionCauseEnrichmentOtherRuntimeExceptionTest() { | ||
Exception exception = new RuntimeException("something went horribly wrong"); | ||
BQSQLException sqlException = new BQSQLException("Oops! Something went wrong:", exception); | ||
|
||
String actualMessage = sqlException.getMessage(); | ||
Assert.assertEquals("Oops! Something went wrong: - RuntimeException: something went horribly wrong", actualMessage); | ||
} | ||
|
||
} |