// Path: src/main/java/com/google/devtools/build/bfg/BuildozerCommandCreator.java
// static ImmutableList<String> computeBuildozerCommands(Graph<BuildRule> buildRuleDAG) {
//   ImmutableList.Builder<String> commands = ImmutableList.builder();
//   for (BuildRule buildRule : buildRuleDAG.nodes()) {
//     List<String> initialCommands = buildRule.getCreatingBuildozerCommands();
//     commands.addAll(initialCommands);
//     List<String> depsList = getDepsForBuildRule(buildRuleDAG, buildRule);
//     if (buildRule.shouldAddDeps() && !depsList.isEmpty()) {
//       commands.add(BuildozerCommand.addAttribute("deps", depsList, buildRule.label()));
//     }
//   }
//   return commands.build();
// }
// 
// Path: src/main/java/com/google/devtools/build/bfg/BuildozerCommandCreator.java
// static Iterable<Path> getBuildFilesForBuildozer(
//     Graph<BuildRule> buildRuleGraph, Path workspacePath) {
//   Function<BuildRule, Path> relativePathForRule =
//       rule -> workspacePath.resolve(rule.label().split("//")[1].split(":")[0]);
// 
//   return buildRuleGraph
//       .nodes()
//       .stream()
//       .filter(buildRule -> buildRule.shouldAddDeps())
//       .map(relativePathForRule)
//       .collect(toImmutableSet());
// }


import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.bfg.BuildozerCommandCreator.computeBuildozerCommands;
import static com.google.devtools.build.bfg.BuildozerCommandCreator.getBuildFilesForBuildozer;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.graph.GraphBuilder;
import com.google.common.graph.MutableGraph;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
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 BuildozerCommandCreator}. */
@RunWith(JUnit4.class)
public class BuildozerCommandCreatorTest {

  private static final Path DEFAULT_WORKSPACE = Paths.get("/workspace");

  /**
   * Tests dependency behavior when a single file depends on another file. This should result in two
   * build rules, one with an empty deps field and another with a dependency.
   */
  @Test
  public void depsForSingleFileComponents() {
    MutableGraph<BuildRule> buildRuleGraph = newGraph();
    String packagePath = "/workspace/java/package/";
    ProjectBuildRule src = newProjectBuildRule(packagePath, "/workspace/java/package/Example.java");
    ProjectBuildRule dst = newProjectBuildRule(packagePath, "/workspace/java/package/Other.java");

    buildRuleGraph.putEdge(src, dst);

// Path: src/main/java/com/google/devtools/build/bfg/BuildozerCommandCreator.java
// static ImmutableList<String> computeBuildozerCommands(Graph<BuildRule> buildRuleDAG) {
//   ImmutableList.Builder<String> commands = ImmutableList.builder();
//   for (BuildRule buildRule : buildRuleDAG.nodes()) {
//     List<String> initialCommands = buildRule.getCreatingBuildozerCommands();
//     commands.addAll(initialCommands);
//     List<String> depsList = getDepsForBuildRule(buildRuleDAG, buildRule);
//     if (buildRule.shouldAddDeps() && !depsList.isEmpty()) {
//       commands.add(BuildozerCommand.addAttribute("deps", depsList, buildRule.label()));
//     }
//   }
//   return commands.build();
// }
// 
// Path: src/main/java/com/google/devtools/build/bfg/BuildozerCommandCreator.java
// static Iterable<Path> getBuildFilesForBuildozer(
//     Graph<BuildRule> buildRuleGraph, Path workspacePath) {
//   Function<BuildRule, Path> relativePathForRule =
//       rule -> workspacePath.resolve(rule.label().split("//")[1].split(":")[0]);
// 
//   return buildRuleGraph
//       .nodes()
//       .stream()
//       .filter(buildRule -> buildRule.shouldAddDeps())
//       .map(relativePathForRule)
//       .collect(toImmutableSet());
// }


// Path: src/test/java/com/google/devtools/build/bfg/BuildozerCommandCreatorTest.java
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.bfg.BuildozerCommandCreator.computeBuildozerCommands;
import static com.google.devtools.build.bfg.BuildozerCommandCreator.getBuildFilesForBuildozer;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.graph.GraphBuilder;
import com.google.common.graph.MutableGraph;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
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 BuildozerCommandCreator}. */
@RunWith(JUnit4.class)
public class BuildozerCommandCreatorTest {

  private static final Path DEFAULT_WORKSPACE = Paths.get("/workspace");

  /**
   * Tests dependency behavior when a single file depends on another file. This should result in two
   * build rules, one with an empty deps field and another with a dependency.
   */
  @Test
  public void depsForSingleFileComponents() {
    MutableGraph<BuildRule> buildRuleGraph = newGraph();
    String packagePath = "/workspace/java/package/";
    ProjectBuildRule src = newProjectBuildRule(packagePath, "/workspace/java/package/Example.java");
    ProjectBuildRule dst = newProjectBuildRule(packagePath, "/workspace/java/package/Other.java");

    buildRuleGraph.putEdge(src, dst);

    ImmutableList<String> actual = computeBuildozerCommands(buildRuleGraph);