// Path: src/main/java/com/google/devtools/build/bfg/ProjectClassToRuleResolver.java
// static final double UNRESOLVED_THRESHOLD = 0.7;


import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.bfg.ProjectClassToRuleResolver.UNRESOLVED_THRESHOLD;
import static junit.framework.TestCase.fail;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.graph.Graph;
import com.google.common.graph.GraphBuilder;
import com.google.common.graph.ImmutableGraph;
import com.google.common.graph.MutableGraph;
import com.google.common.jimfs.Configuration;
import com.google.common.jimfs.Jimfs;
import com.google.re2j.Pattern;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
    assertThat(actual).doesNotContainKey("com.DoesNotExist");
  }

  /**
   * If a class's source file cannot be found, then that class name should not be in the ensuing
   * class. If more than the default threshold are unresolved, then it BFG should error out.
   */
  @Test
  public void ignoresUnresolvedClass_exceedsThreshold() throws IOException {
    MutableGraph<String> classgraph = newGraph(String.class);
    classgraph.putEdge("com.A", "com.DoesNotExist");
    classgraph.putEdge("com.A", "com.DoesNotExistTwo");
    classgraph.putEdge("com.A", "com.DoesNotExistThree");

    ProjectClassToRuleResolver resolver =
        newResolver(
            classgraph,
            WHITELIST_DEFAULT,
            ImmutableMap.of("com.A", workspace.resolve("java/com/A.java")));

    try {
      resolver.resolve(classgraph.nodes());
      fail("Expected an exception, but nothing was thrown.");
    } catch (IllegalStateException e) {
      assertThat(e)
          .hasMessageThat()
          .isEqualTo(
              String.format(
                  "BUILD File Generator failed to map over %.0f percent of class names. "
                      + "Check your white list and content roots",
// Path: src/main/java/com/google/devtools/build/bfg/ProjectClassToRuleResolver.java
// static final double UNRESOLVED_THRESHOLD = 0.7;


// Path: src/test/java/com/google/devtools/build/bfg/ProjectClassToRuleResolverTest.java
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.bfg.ProjectClassToRuleResolver.UNRESOLVED_THRESHOLD;
import static junit.framework.TestCase.fail;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.graph.Graph;
import com.google.common.graph.GraphBuilder;
import com.google.common.graph.ImmutableGraph;
import com.google.common.graph.MutableGraph;
import com.google.common.jimfs.Configuration;
import com.google.common.jimfs.Jimfs;
import com.google.re2j.Pattern;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

    assertThat(actual).doesNotContainKey("com.DoesNotExist");
  }

  /**
   * If a class's source file cannot be found, then that class name should not be in the ensuing
   * class. If more than the default threshold are unresolved, then it BFG should error out.
   */
  @Test
  public void ignoresUnresolvedClass_exceedsThreshold() throws IOException {
    MutableGraph<String> classgraph = newGraph(String.class);
    classgraph.putEdge("com.A", "com.DoesNotExist");
    classgraph.putEdge("com.A", "com.DoesNotExistTwo");
    classgraph.putEdge("com.A", "com.DoesNotExistThree");

    ProjectClassToRuleResolver resolver =
        newResolver(
            classgraph,
            WHITELIST_DEFAULT,
            ImmutableMap.of("com.A", workspace.resolve("java/com/A.java")));

    try {
      resolver.resolve(classgraph.nodes());
      fail("Expected an exception, but nothing was thrown.");
    } catch (IllegalStateException e) {
      assertThat(e)
          .hasMessageThat()
          .isEqualTo(
              String.format(
                  "BUILD File Generator failed to map over %.0f percent of class names. "
                      + "Check your white list and content roots",
                  UNRESOLVED_THRESHOLD * 100));