public synchronized String createDataset(String region) throws BigQueryResourceManagerException {

    // Check to see if dataset already exists, and throw error if it does
    if (dataset != null) {
      throw new IllegalStateException(
          "Dataset " + datasetId + " already exists for project " + projectId + ".");
    }

    LOG.info("Creating dataset {} in project {}.", datasetId, projectId);

    // Send the dataset request to Google Cloud
    try {
      DatasetInfo datasetInfo = DatasetInfo.newBuilder(datasetId).setLocation(region).build();
      LOG.info("Dataset {} created successfully", datasetId);
      dataset = bigQuery.create(datasetInfo);
      return datasetId;
    } catch (Exception e) {
      throw new BigQueryResourceManagerException("Failed to create dataset.", e);
    }
  }
@Test
  public void testCreateDatasetShouldNotCreateDatasetWhenDatasetAlreadyExists() {
    testManager.createDataset(DATASET_ID);

    assertThrows(IllegalStateException.class, () -> testManager.createDataset(DATASET_ID));
  }