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());
}
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());
}
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());
}
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;
}
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());
}
Aggregations