Search in sources :

Example 16 with JavaSource

use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.

the class JPAExaminerTest method testFindAndSetAttributesIgnoreCommentBlocks.

@Test
public void testFindAndSetAttributesIgnoreCommentBlocks() {
    ExaminerJPA jpaExaminer = new ExaminerJPA();
    JavaSource javaSource;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("CocktailModel");
    sourceCode = "@Model\n" + "public class CocktailModel implements Serializable\n" + "{\n" + "  private List<Cocktail>     nonAlcoholicCocktails;\n" + "  private List<Cocktail>     alcoholicCocktails;\n" + "  /*\n" + "  @Inject\n" + "  private CocktailRepository cocktailRepository;\n" + "    */\n" + "  public List<Cocktail> getNonAlcoholicCocktails()\n" + "{\n" + "return this.nonAlcoholicCocktails;\n" + "}\n";
    javaSource.setSourceCode(sourceCode);
    jpaExaminer.examine(javaSource);
    assertEquals(0, DependencyContainer.getInstance().getDependencies(javaSource).size());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Test(org.junit.Test)

Example 17 with JavaSource

use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.

the class JPAExaminerTest method testFindAndSetAttributesManyToMany.

@Test
public void testFindAndSetAttributesManyToMany() {
    ExaminerJPA jpaExaminer = new ExaminerJPA();
    JavaSource javaSource;
    Dependency dependency;
    String sourceCode;
    // Many to many
    javaSource = JavaSourceFactory.getInstance().newJavaSource("User");
    sourceCode = TestDataProvider.getTestSourceCodeBeforeBody() + "@ManyToMany(cascade = {CascadeType.REFRESH, CascadeType.DETACH}, fetch = FetchType.LAZY)\n" + "@JoinTable(name = \"USERS_GROUPS\", joinColumns = {\n" + "   @JoinColumn(name = \"USERID\", nullable = false)}, inverseJoinColumns = {\n" + "   @JoinColumn(name = \"GROUPID\", nullable = false)})\n" + "private Set<Group> groups;\n";
    javaSource.setSourceCode(sourceCode);
    jpaExaminer.examine(javaSource);
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(1, DependencyContainer.getInstance().getDependencies(javaSource).size());
    assertEquals(DependencyType.MANY_TO_MANY, dependency.getDependencyType());
    assertEquals("User", dependency.getJavaSourceFrom().getName());
    assertEquals("Group", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 18 with JavaSource

use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.

the class JPAExaminerTest method testFindAndSetAttributesManyToOne.

@Test
public void testFindAndSetAttributesManyToOne() {
    ExaminerJPA jpaExaminer = new ExaminerJPA();
    JavaSource javaSource;
    Dependency dependency;
    String sourceCode;
    // Many to one
    javaSource = JavaSourceFactory.getInstance().newJavaSource("MyTestClass");
    sourceCode = TestDataProvider.getTestSourceCodeBeforeBody() + "@ManyToOne(cascade = { CascadeType.DETACH })\n" + "@JoinColumn(name = \"ALBUMID\", nullable = false)\n" + "@NotNull(groups = PersistenceConstraint.class)\n" + "private Album album;\n";
    javaSource.setSourceCode(sourceCode);
    jpaExaminer.examine(javaSource);
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(1, DependencyContainer.getInstance().getDependencies(javaSource).size());
    assertEquals(DependencyType.MANY_TO_ONE, dependency.getDependencyType());
    assertEquals("MyTestClass", dependency.getJavaSourceFrom().getName());
    assertEquals("Album", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 19 with JavaSource

use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.

the class GraphCreator method buildJSONNodes.

static JsonArrayBuilder buildJSONNodes(DependencyFilter filter) {
    Set<JavaSource> relevantClasses = DependencyContainer.getInstance().getFilteredJavaSources(filter);
    JsonArrayBuilder nodesArray = Json.createArrayBuilder();
    for (JavaSource javaSource : JavaSourceContainer.getInstance().getJavaSources()) {
        if (filter == null || relevantClasses.contains(javaSource)) {
            nodesArray.add(buildJSONNode(javaSource));
        }
    }
    return nodesArray;
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) JsonArrayBuilder(javax.json.JsonArrayBuilder)

Example 20 with JavaSource

use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.

the class DependencyContainerTest method testFindAllDependenciesWith.

@Test
public void testFindAllDependenciesWith() {
    TestDataProvider.createSampleDependencies();
    JavaSource producer = JavaSourceContainer.getInstance().getJavaSourceByName("Producer");
    JavaSource product1 = JavaSourceContainer.getInstance().getJavaSourceByName("Product1");
    Set<Dependency> foundedDependencies = DependencyContainer.getInstance().findAllDependenciesWith(producer, DependencyType.PRODUCES);
    assertEquals(4, foundedDependencies.size());
    foundedDependencies = DependencyContainer.getInstance().findAllDependenciesWith(producer, DependencyType.EVENT);
    assertEquals(0, foundedDependencies.size());
    foundedDependencies = DependencyContainer.getInstance().findAllDependenciesWith(product1, DependencyType.INSTANCE);
    assertEquals(1, foundedDependencies.size());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Aggregations

JavaSource (de.strullerbaumann.visualee.source.entity.JavaSource)50 Test (org.junit.Test)44 Dependency (de.strullerbaumann.visualee.dependency.entity.Dependency)31 Scanner (java.util.Scanner)5 DependencyType (de.strullerbaumann.visualee.dependency.entity.DependencyType)3 ArrayList (java.util.ArrayList)3 JsonArrayBuilder (javax.json.JsonArrayBuilder)2 JsonObjectBuilder (javax.json.JsonObjectBuilder)2 ExaminerInject (de.strullerbaumann.visualee.examiner.cdi.ExaminerInject)1 ExaminerProduces (de.strullerbaumann.visualee.examiner.cdi.ExaminerProduces)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 JsonArray (javax.json.JsonArray)1 JsonObject (javax.json.JsonObject)1 Ignore (org.junit.Ignore)1