// Path: kawala-testing/src/main/java/com/kaching/platform/testing/CyclicDependencyTestRunner.java
// static class Result {
//   final int numClasses;
//   final Map<JavaPackage, Set<JavaPackage>> sccs = Maps.newHashMap();
//   Result(int numClasses) {
//     this.numClasses = numClasses;
//   }
// 
//   boolean hasCycle() {
//     return !sccs.isEmpty();
//   }
// 
//   void addCycles(List<JavaPackage> cycles) {
//     Set<JavaPackage> scc = Sets.newHashSet(cycles);
//     for (JavaPackage pkg : cycles) {
//       sccs.put(pkg, scc);
//     }
//   }
// 
//   Set<Set<JavaPackage>> getUniqueCycles() {
//     return Sets.newHashSet(sccs.values());
//   }
// 
//   @Override
//   public String toString() {
//     StringBuilder sb = new StringBuilder("Strongly connected components: {\n");
//     for (Set<JavaPackage> scc : getUniqueCycles()) {
//       boolean first = true;
//       sb.append("[");
//       for (JavaPackage jp : scc) {
//         if (first) {
//           first = false;
//         } else {
//           sb.append(",\n ");
//         }
//         sb.append(jp.getName());
//       }
//       sb.append("]\n");
//     }
//     return sb.append("}").toString();
//   }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import com.kaching.platform.testing.CyclicDependencyTestRunner.Packages;
import com.kaching.platform.testing.CyclicDependencyTestRunner.PackagesBuilder.Result;
/**
 * Copyright 2015 Wealthfront Inc. 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.kaching.platform.testing;





public class CyclicDependencyTestRunnerTest {

  @Packages(
      binDirectories = "target/test-classes",
      forPackages = "com.kaching.platform.testing.testexamples.a")
  private static class SinglePackage {}

  @Test
  public void testSinglePackage_NoCycles() throws IOException {
    CyclicDependencyTestRunner runner = new CyclicDependencyTestRunner(SinglePackage.class);
// Path: kawala-testing/src/main/java/com/kaching/platform/testing/CyclicDependencyTestRunner.java
// static class Result {
//   final int numClasses;
//   final Map<JavaPackage, Set<JavaPackage>> sccs = Maps.newHashMap();
//   Result(int numClasses) {
//     this.numClasses = numClasses;
//   }
// 
//   boolean hasCycle() {
//     return !sccs.isEmpty();
//   }
// 
//   void addCycles(List<JavaPackage> cycles) {
//     Set<JavaPackage> scc = Sets.newHashSet(cycles);
//     for (JavaPackage pkg : cycles) {
//       sccs.put(pkg, scc);
//     }
//   }
// 
//   Set<Set<JavaPackage>> getUniqueCycles() {
//     return Sets.newHashSet(sccs.values());
//   }
// 
//   @Override
//   public String toString() {
//     StringBuilder sb = new StringBuilder("Strongly connected components: {\n");
//     for (Set<JavaPackage> scc : getUniqueCycles()) {
//       boolean first = true;
//       sb.append("[");
//       for (JavaPackage jp : scc) {
//         if (first) {
//           first = false;
//         } else {
//           sb.append(",\n ");
//         }
//         sb.append(jp.getName());
//       }
//       sb.append("]\n");
//     }
//     return sb.append("}").toString();
//   }
// }


// Path: kawala-testing/src/test/java/com/kaching/platform/testing/CyclicDependencyTestRunnerTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Test;
import com.kaching.platform.testing.CyclicDependencyTestRunner.Packages;
import com.kaching.platform.testing.CyclicDependencyTestRunner.PackagesBuilder.Result;

/**
 * Copyright 2015 Wealthfront Inc. 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.kaching.platform.testing;





public class CyclicDependencyTestRunnerTest {

  @Packages(
      binDirectories = "target/test-classes",
      forPackages = "com.kaching.platform.testing.testexamples.a")
  private static class SinglePackage {}

  @Test
  public void testSinglePackage_NoCycles() throws IOException {
    CyclicDependencyTestRunner runner = new CyclicDependencyTestRunner(SinglePackage.class);
    Result result = runner.getTestResults(SinglePackage.class.getAnnotation(Packages.class));