// Path: src/main/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreator.java
// public static BigQueryTableEntity fromBigQueryResource(String resource) {
//   return extractInformation(BQ_RESOURCE_FORMAT, resource);
// }
// 
// Path: src/main/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreator.java
// public static BigQueryTableEntity fromLegacyTableName(String legacyName) {
//   return extractInformation(LEGACY_TABLE_FORMAT, legacyName);
// }
// 
// Path: src/main/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreator.java
// public static BigQueryTableEntity fromLinkedResource(String linkedResource) {
//   return extractInformation(BQ_LINKED_RESOURCE_FORMAT, linkedResource);
// }
// 
// Path: src/main/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreator.java
// public static BigQueryTableEntity fromSqlResource(String sqlResource) {
//   return extractInformation(SQL_RESOURCE_FORMAT, sqlResource);
// }
// 
// Path: src/main/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreator.java
// public static BigQueryTableEntity usingBestEffort(String bigQueryTableName) {
//   if (bigQueryTableName != null && bigQueryTableName.startsWith("$")) {
//     return BigQueryTableEntity.create(null, null, bigQueryTableName);
//   }
// 
//   for (String pattern : ImmutableList
//       .of(BQ_LEGACY_STANDARD_TABLE_NAME_FORMAT, BQ_RESOURCE_FORMAT, BQ_LINKED_RESOURCE_FORMAT)) {
//     try {
//       return extractInformation(pattern, bigQueryTableName);
//     } catch (IllegalArgumentException aex) {
//       logger.atInfo().atMostEvery(1, TimeUnit.MINUTES).withCause(aex)
//           .log("error parsing %s", bigQueryTableName);
//     }
//   }
// 
//   throw new IllegalArgumentException(
//       "Couldn't convert into any known types: (" + bigQueryTableName + ")");
// }
// 
// Path: src/main/java/com/google/cloud/solutions/datalineage/model/BigQueryTableEntity.java
// @AutoValue
// public abstract class BigQueryTableEntity implements DataEntityConvertible, Serializable {
// 
//   public abstract String getProjectId();
// 
//   public abstract String getDataset();
// 
//   public abstract String getTable();
// 
//   /**
//    * Returns {@code true} if the table is a temporary table.
//    * <p> It uses rule dataset name starts with '_' or table name starts with '_' or 'anon'.
//    */
//   public final boolean isTempTable() {
//     return getDataset().startsWith("_")
//         || getTable().startsWith("_")
//         || getTable().startsWith("anon");
//   }
// 
//   public static Builder builder() {
//     return new AutoValue_BigQueryTableEntity.Builder();
//   }
// 
//   public static BigQueryTableEntity create(String projectId, String dataset, String table) {
//     return builder()
//         .setProjectId(projectId)
//         .setDataset(dataset)
//         .setTable(table)
//         .build();
//   }
// 
//   @Override
//   public DataEntity dataEntity() {
//     return DataEntity.newBuilder()
//         .setKind(DataEntityTypes.BIGQUERY_TABLE)
//         .setLinkedResource(
//             String.format("//bigquery.googleapis.com/projects/%s/datasets/%s/tables/%s",
//                 getProjectId(),
//                 getDataset(),
//                 getTable()))
//         .setSqlResource(
//             String.format("bigquery.table.%s.%s.%s", getProjectId(), getDataset(), getTable()))
//         .build();
//   }
// 
//   public String getLegacySqlName() {
//     return String.format("%s:%s.%s", getProjectId(), getDataset(), getTable());
//   }
// 
//   public String getStandSqlName() {
//     return String.format("%s.%s.%s", getProjectId(), getDataset(), getTable());
//   }
// 
//   @AutoValue.Builder
//   public abstract static class Builder {
// 
//     public abstract Builder setProjectId(String projectId);
// 
//     public abstract Builder setDataset(String dataset);
// 
//     public abstract Builder setTable(String table);
// 
//     public abstract BigQueryTableEntity build();
//   }
// }


import static com.google.cloud.solutions.datalineage.extractor.BigQueryTableCreator.fromBigQueryResource;
import static com.google.cloud.solutions.datalineage.extractor.BigQueryTableCreator.fromLegacyTableName;
import static com.google.cloud.solutions.datalineage.extractor.BigQueryTableCreator.fromLinkedResource;
import static com.google.cloud.solutions.datalineage.extractor.BigQueryTableCreator.fromSqlResource;
import static com.google.cloud.solutions.datalineage.extractor.BigQueryTableCreator.usingBestEffort;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import com.google.cloud.solutions.datalineage.model.BigQueryTableEntity;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
 * Copyright 2020 Google LLC
 *
 * 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.solutions.datalineage.extractor;



@RunWith(JUnit4.class)
public final class BigQueryTableCreatorTest {

  @Test
  public void fromLegacyTableName_projectIdWithHyphens_valid() {
    assertThat(fromLegacyTableName("bq-lineage-demo:audit_dataset.lineage"))
// Path: src/main/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreator.java
// public static BigQueryTableEntity fromBigQueryResource(String resource) {
//   return extractInformation(BQ_RESOURCE_FORMAT, resource);
// }
// 
// Path: src/main/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreator.java
// public static BigQueryTableEntity fromLegacyTableName(String legacyName) {
//   return extractInformation(LEGACY_TABLE_FORMAT, legacyName);
// }
// 
// Path: src/main/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreator.java
// public static BigQueryTableEntity fromLinkedResource(String linkedResource) {
//   return extractInformation(BQ_LINKED_RESOURCE_FORMAT, linkedResource);
// }
// 
// Path: src/main/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreator.java
// public static BigQueryTableEntity fromSqlResource(String sqlResource) {
//   return extractInformation(SQL_RESOURCE_FORMAT, sqlResource);
// }
// 
// Path: src/main/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreator.java
// public static BigQueryTableEntity usingBestEffort(String bigQueryTableName) {
//   if (bigQueryTableName != null && bigQueryTableName.startsWith("$")) {
//     return BigQueryTableEntity.create(null, null, bigQueryTableName);
//   }
// 
//   for (String pattern : ImmutableList
//       .of(BQ_LEGACY_STANDARD_TABLE_NAME_FORMAT, BQ_RESOURCE_FORMAT, BQ_LINKED_RESOURCE_FORMAT)) {
//     try {
//       return extractInformation(pattern, bigQueryTableName);
//     } catch (IllegalArgumentException aex) {
//       logger.atInfo().atMostEvery(1, TimeUnit.MINUTES).withCause(aex)
//           .log("error parsing %s", bigQueryTableName);
//     }
//   }
// 
//   throw new IllegalArgumentException(
//       "Couldn't convert into any known types: (" + bigQueryTableName + ")");
// }
// 
// Path: src/main/java/com/google/cloud/solutions/datalineage/model/BigQueryTableEntity.java
// @AutoValue
// public abstract class BigQueryTableEntity implements DataEntityConvertible, Serializable {
// 
//   public abstract String getProjectId();
// 
//   public abstract String getDataset();
// 
//   public abstract String getTable();
// 
//   /**
//    * Returns {@code true} if the table is a temporary table.
//    * <p> It uses rule dataset name starts with '_' or table name starts with '_' or 'anon'.
//    */
//   public final boolean isTempTable() {
//     return getDataset().startsWith("_")
//         || getTable().startsWith("_")
//         || getTable().startsWith("anon");
//   }
// 
//   public static Builder builder() {
//     return new AutoValue_BigQueryTableEntity.Builder();
//   }
// 
//   public static BigQueryTableEntity create(String projectId, String dataset, String table) {
//     return builder()
//         .setProjectId(projectId)
//         .setDataset(dataset)
//         .setTable(table)
//         .build();
//   }
// 
//   @Override
//   public DataEntity dataEntity() {
//     return DataEntity.newBuilder()
//         .setKind(DataEntityTypes.BIGQUERY_TABLE)
//         .setLinkedResource(
//             String.format("//bigquery.googleapis.com/projects/%s/datasets/%s/tables/%s",
//                 getProjectId(),
//                 getDataset(),
//                 getTable()))
//         .setSqlResource(
//             String.format("bigquery.table.%s.%s.%s", getProjectId(), getDataset(), getTable()))
//         .build();
//   }
// 
//   public String getLegacySqlName() {
//     return String.format("%s:%s.%s", getProjectId(), getDataset(), getTable());
//   }
// 
//   public String getStandSqlName() {
//     return String.format("%s.%s.%s", getProjectId(), getDataset(), getTable());
//   }
// 
//   @AutoValue.Builder
//   public abstract static class Builder {
// 
//     public abstract Builder setProjectId(String projectId);
// 
//     public abstract Builder setDataset(String dataset);
// 
//     public abstract Builder setTable(String table);
// 
//     public abstract BigQueryTableEntity build();
//   }
// }


// Path: src/test/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreatorTest.java
import static com.google.cloud.solutions.datalineage.extractor.BigQueryTableCreator.fromBigQueryResource;
import static com.google.cloud.solutions.datalineage.extractor.BigQueryTableCreator.fromLegacyTableName;
import static com.google.cloud.solutions.datalineage.extractor.BigQueryTableCreator.fromLinkedResource;
import static com.google.cloud.solutions.datalineage.extractor.BigQueryTableCreator.fromSqlResource;
import static com.google.cloud.solutions.datalineage.extractor.BigQueryTableCreator.usingBestEffort;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import com.google.cloud.solutions.datalineage.model.BigQueryTableEntity;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/*
 * Copyright 2020 Google LLC
 *
 * 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.solutions.datalineage.extractor;



@RunWith(JUnit4.class)
public final class BigQueryTableCreatorTest {

  @Test
  public void fromLegacyTableName_projectIdWithHyphens_valid() {
    assertThat(fromLegacyTableName("bq-lineage-demo:audit_dataset.lineage"))
        .isEqualTo(