Search in sources :

Example 1 with DependencyType

use of de.strullerbaumann.visualee.dependency.entity.DependencyType in project visualee by Thomas-S-B.

the class DependencyContainer method getFilteredJavaSources.

//TODO simplify
public Set<JavaSource> getFilteredJavaSources(DependencyFilter filter) {
    Set<JavaSource> filteredJavaSources = new HashSet<>();
    if (filter != null && filter.isDirectlyConnected()) {
        DependencyType primaryType = filter.getFilterTypes().get(0);
        for (Dependency d : getDependenciesOfType(primaryType)) {
            JavaSource to = d.getJavaSourceTo();
            List<Dependency> injects = new ArrayList<>();
            for (DependencyType dFilter : filter.getFilterTypes()) {
                if (!dFilter.equals(primaryType)) {
                    injects.addAll(findAllDependenciesWith(to, dFilter));
                }
            }
            if (injects.size() > 0) {
                filteredJavaSources.add(d.getJavaSourceFrom());
                filteredJavaSources.add(to);
                for (Dependency inject : injects) {
                    filteredJavaSources.add(inject.getJavaSourceFrom());
                }
            }
        }
    } else {
        for (Dependency dependency : DEPENDENCIES) {
            if (filter == null || filter.contains(dependency.getDependencyType())) {
                filteredJavaSources.add(dependency.getJavaSourceFrom());
                filteredJavaSources.add(dependency.getJavaSourceTo());
            }
        }
    }
    return filteredJavaSources;
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) DependencyType(de.strullerbaumann.visualee.dependency.entity.DependencyType) ArrayList(java.util.ArrayList) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) HashSet(java.util.HashSet)

Example 2 with DependencyType

use of de.strullerbaumann.visualee.dependency.entity.DependencyType in project visualee by Thomas-S-B.

the class Description method generateDescription.

public static String generateDescription(JavaSource javaSource) {
    StringBuilder description = new StringBuilder();
    description.append("<nobr>Package: ").append(javaSource.getPackagePath()).append("</nobr>");
    HashMap<DependencyType, StringBuilder> descriptionParts = new HashMap<>();
    for (DependencyType type : DependencyType.values()) {
        descriptionParts.put(type, new StringBuilder());
    }
    for (Dependency dependency : DependencyContainer.getInstance().getDependencies(javaSource)) {
        StringBuilder descriptionPart = descriptionParts.get(dependency.getDependencyType());
        assert descriptionPart != null : "Unknown DependencyType";
        descriptionPart.append("<br/><nobr>");
        String desc = DESCRIPTIONS.get(dependency.getDependencyType());
        desc = desc.replaceAll(JAVASOURCE_TO, dependency.getJavaSourceTo().toString());
        descriptionPart.append(desc);
        descriptionPart.append("</nobr>");
    }
    for (DependencyType type : descriptionParts.keySet()) {
        description.append(getDescriptionPart(type, descriptionParts.get(type).toString()));
    }
    return description.toString();
}
Also used : HashMap(java.util.HashMap) DependencyType(de.strullerbaumann.visualee.dependency.entity.DependencyType) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency)

Example 3 with DependencyType

use of de.strullerbaumann.visualee.dependency.entity.DependencyType in project visualee by Thomas-S-B.

the class ExaminerInstanceTest method testgetTypeFromToken.

@Test
public void testgetTypeFromToken() {
    String sourceLine;
    DependencyType actual;
    sourceLine = "My test sourcecode";
    actual = examiner.getTypeFromToken(sourceLine);
    assertEquals(null, actual);
    sourceLine = "@Inject TestCalss myTestClass;";
    actual = examiner.getTypeFromToken(sourceLine);
    assertEquals(DependencyType.INJECT, actual);
}
Also used : DependencyType(de.strullerbaumann.visualee.dependency.entity.DependencyType) Test(org.junit.Test)

Example 4 with DependencyType

use of de.strullerbaumann.visualee.dependency.entity.DependencyType in project visualee by Thomas-S-B.

the class ExaminerEventTest method testgetTypeFromToken.

@Test
public void testgetTypeFromToken() {
    String sourceLine;
    DependencyType actual;
    sourceLine = "My test sourcecode";
    actual = examiner.getTypeFromToken(sourceLine);
    assertEquals(null, actual);
    sourceLine = "@Inject TestCalss myTestClass;";
    actual = examiner.getTypeFromToken(sourceLine);
    assertEquals(DependencyType.INJECT, actual);
}
Also used : DependencyType(de.strullerbaumann.visualee.dependency.entity.DependencyType) Test(org.junit.Test)

Example 5 with DependencyType

use of de.strullerbaumann.visualee.dependency.entity.DependencyType in project visualee by Thomas-S-B.

the class ExaminerInjectTest method testgetTypeFromToken.

@Test
public void testgetTypeFromToken() {
    String sourceLine;
    DependencyType actual;
    sourceLine = "My test sourcecode";
    actual = examiner.getTypeFromToken(sourceLine);
    assertEquals(null, actual);
    sourceLine = "@Inject TestCalss myTestClass;";
    actual = examiner.getTypeFromToken(sourceLine);
    assertEquals(DependencyType.INJECT, actual);
}
Also used : DependencyType(de.strullerbaumann.visualee.dependency.entity.DependencyType) Test(org.junit.Test)

Aggregations

DependencyType (de.strullerbaumann.visualee.dependency.entity.DependencyType)12 Test (org.junit.Test)9 Dependency (de.strullerbaumann.visualee.dependency.entity.Dependency)4 JavaSource (de.strullerbaumann.visualee.source.entity.JavaSource)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 JsonArrayBuilder (javax.json.JsonArrayBuilder)1 JsonObjectBuilder (javax.json.JsonObjectBuilder)1