diff --git a/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java b/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java index 439e401d374b..25b90dc942ee 100644 --- a/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java +++ b/java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java @@ -4698,13 +4698,10 @@ void testProjectIDFastSQLQueryWithJobId() { JobId jobIdWithProjectId = JobId.newBuilder().setProject(invalidProjectId).build(); QueryJobConfiguration configSelect = QueryJobConfiguration.newBuilder(query).setDefaultDataset(DatasetId.of(DATASET)).build(); - try { - bigquery.query(configSelect, jobIdWithProjectId); - } catch (Exception exception) { - // error message for non-existent project - assertEquals("Cannot parse as CloudRegion.", exception.getMessage()); - assertEquals(BigQueryException.class, exception.getClass()); - } + BigQueryException bqException = + assertThrows( + BigQueryException.class, () -> bigquery.query(configSelect, jobIdWithProjectId)); + assertEquals(400, bqException.getCode()); } @Test