// 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;
// Copyright 2017 The Bazel Authors. All rights reserved.
//
// 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.devtools.build.bfg;



/** Tests for {@link ProjectClassToRuleResolver}. */
@RunWith(JUnit4.class)
public class ProjectClassToRuleResolverTest {

  private Path workspace;

  private static final Pattern WHITELIST_DEFAULT = Pattern.compile(".*");

  @Before
  public void setUp() throws IOException {
    FileSystem fileSystem = createDefaultFileSystem();
    workspace = fileSystem.getPath("/src");
  }

  /**
   * Tests behavior of resolver on a graph where each class is uniquely mapped to a target.
   * Resulting map should have each class uniquely mapped to a build rule.
   */
  @Test
  public void simpleDAGWithUniqueTargets() throws IOException {
    MutableGraph<String> classgraph = newGraph(String.class);
    classgraph.putEdge("com.A", "com.B");
    classgraph.putEdge("com.B", "com.C");

    ProjectClassToRuleResolver resolver =
        newResolver(
// 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;

// Copyright 2017 The Bazel Authors. All rights reserved.
//
// 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.devtools.build.bfg;



/** Tests for {@link ProjectClassToRuleResolver}. */
@RunWith(JUnit4.class)
public class ProjectClassToRuleResolverTest {

  private Path workspace;

  private static final Pattern WHITELIST_DEFAULT = Pattern.compile(".*");

  @Before
  public void setUp() throws IOException {
    FileSystem fileSystem = createDefaultFileSystem();
    workspace = fileSystem.getPath("/src");
  }

  /**
   * Tests behavior of resolver on a graph where each class is uniquely mapped to a target.
   * Resulting map should have each class uniquely mapped to a build rule.
   */
  @Test
  public void simpleDAGWithUniqueTargets() throws IOException {
    MutableGraph<String> classgraph = newGraph(String.class);
    classgraph.putEdge("com.A", "com.B");
    classgraph.putEdge("com.B", "com.C");

    ProjectClassToRuleResolver resolver =
        newResolver(
            classgraph,