Ejemplo n.º 1
0
 public Set<String> getIndexedClasses() {
   Set<String> classes = newHashSet();
   Set<JavaClass> vertexSet = graph.vertexSet();
   for (JavaClass each : vertexSet) {
     classes.add(each.getName());
   }
   return classes;
 }
Ejemplo n.º 2
0
 private JavaClass findClass(String classname) {
   for (JavaClass jClass : graph.vertexSet()) {
     if (jClass.getName().equals(classname)) {
       return jClass;
     }
   }
   return null;
 }
  @Test
  public void shouldReturnUnparsableClassIfClassCannotBeFound() {
    JavaClass javaClass = builder.createClass("foo.bar.com");

    assertThat(javaClass).isInstanceOf(UnparsableClass.class);
    assertThat(javaClass.getName()).isEqualTo("foo.bar.com");
    assertThat(javaClass.getImports()).isEmpty();
  }
Ejemplo n.º 4
0
 public JavaClass findJavaClass(String classname) {
   JavaClass clazz = findClass(classname);
   if (clazz == null) {
     clazz = builder.getClass(classname);
     if (clazz.locatedInClassFile()) {
       addToIndex(clazz);
     }
   }
   return clazz;
 }
Ejemplo n.º 5
0
 private void updateParentReferences(JavaClass parentClass) {
   for (String child : parentClass.getImports()) {
     JavaClass childClass = findJavaClass(child);
     if ((childClass != null) && !childClass.equals(parentClass)) {
       if (graph.containsVertex(childClass)) {
         graph.addEdge(parentClass, childClass);
       }
     }
   }
 }
  @Test
  public void shouldLookForClassesInTargetDirectories() throws Exception {
    newDir = new File("tempClassDir");
    List<File> buildPaths = asList(newDir);
    ClasspathProvider classpath =
        new StandaloneClasspath(
            buildPaths,
            FakeEnvironments.systemClasspath() + pathSeparator + newDir.getAbsolutePath());

    String classname = "org.fakeco.Foobar";
    createClass(classname);

    builder = new JavaClassBuilder(classpath);
    JavaClass javaClass = builder.createClass(classname);
    assertEquals(classname, javaClass.getName());
    assertFalse(javaClass.isATest());
  }
  @Test
  public void shouldFindDependenciesInSamePackage() {
    JavaClass javaClass = builder.createClass(FakeTree.class.getName());

    assertThat(javaClass.getImports()).contains(FakeDependency.class.getName());
  }