Search in sources :

Example 6 with JavaSource

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

the class JavaSourceContainerTest method testAddJavaSourceDoublette.

@Test
public void testAddJavaSourceDoublette() {
    JavaSourceContainer.getInstance().clear();
    String name = "DataPoint";
    JavaSource javaSource1 = JavaSourceFactory.getInstance().newJavaSource(name);
    String sourceCode1 = "Test source code for JavaSource1 (listen to Brian Blade - Season of change";
    javaSource1.setSourceCode(sourceCode1);
    JavaSourceContainer.getInstance().add(javaSource1);
    JavaSource javaSource2 = JavaSourceFactory.getInstance().newJavaSource(name);
    javaSource2.setSourceCode("");
    JavaSourceContainer.getInstance().add(javaSource2);
    assertNotNull(JavaSourceContainer.getInstance().getJavaSourceByName(name));
    assertEquals(1, JavaSourceContainer.getInstance().getJavaSources().size());
    assertEquals(name, JavaSourceContainer.getInstance().getJavaSourceByName(name).getName());
    assertEquals(sourceCode1, JavaSourceContainer.getInstance().getJavaSourceByName(name).getSourceCode());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Test(org.junit.Test)

Example 7 with JavaSource

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

the class GraphCreatorTest method testBuildJSONNodes.

@Test
public void testBuildJSONNodes() {
    JavaSourceContainer.getInstance().clear();
    int count = 10;
    String namePrefix = "Testclass ";
    for (int i = 0; i < count; i++) {
        String name = namePrefix + i;
        JavaSource javaSource = JavaSourceFactory.getInstance().newJavaSource(name);
        JavaSourceContainer.getInstance().add(javaSource);
    }
    JsonArray nodes = GraphCreator.buildJSONNodes(null).build();
    assertEquals(count, nodes.size());
}
Also used : JsonArray(javax.json.JsonArray) JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Test(org.junit.Test)

Example 8 with JavaSource

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

the class GraphCreatorTest method testBuildJSONNode.

@Test
public void testBuildJSONNode() {
    JavaSourceContainer.getInstance().clear();
    DependencyContainer.getInstance().clear();
    String name = "MyTestClass";
    String sourcecode = "test source code - Matt Pavolka Group - Something People Can Use";
    JavaSource javaSource = JavaSourceFactory.getInstance().newJavaSource("MyTestClass");
    javaSource.setGroup(2);
    javaSource.setPackagePath("de.test.test2");
    javaSource.setSourceCode(sourcecode);
    JsonObjectBuilder job = GraphCreator.buildJSONNode(javaSource);
    JsonObject node = job.build();
    assertEquals(name, node.getString("name"));
    assertEquals(2, node.getInt("group"));
    assertNotNull(node.getString("description"));
    assertEquals(sourcecode, node.getString("sourcecode"));
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) JsonObject(javax.json.JsonObject) JsonObjectBuilder(javax.json.JsonObjectBuilder) Test(org.junit.Test)

Example 9 with JavaSource

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

the class DescriptionTest method testGenerateDescription.

/**
 * Test of generateDescription method, of class Description.
 */
@Test
public void testGenerateDescription() {
    JavaSource javaSource1 = JavaSourceFactory.getInstance().newJavaSource("TestJavaSource1");
    JavaSource javaSource2 = JavaSourceFactory.getInstance().newJavaSource("TestJavaSource2");
    JavaSource javaSource3 = JavaSourceFactory.getInstance().newJavaSource("TestJavaSource3");
    String testPackage = "//my/test/package/path";
    javaSource1.setPackagePath(testPackage);
    Dependency dependency12 = new Dependency(DependencyType.INJECT, javaSource1, javaSource2);
    Dependency dependency13 = new Dependency(DependencyType.OBSERVES, javaSource1, javaSource3);
    List<Dependency> dependencies = new ArrayList<>();
    dependencies.add(dependency12);
    dependencies.add(dependency13);
    DependencyContainer.getInstance().addAll(dependencies);
    String actual = Description.generateDescription(javaSource1);
    assertTrue(actual.indexOf(testPackage) > 0);
    assertTrue(actual.indexOf(javaSource2.getName()) > 0);
    assertTrue(actual.indexOf(javaSource3.getName()) > 0);
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) ArrayList(java.util.ArrayList) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 10 with JavaSource

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

the class JavaSourceInspectorTest method testFindAndSetAttributesIgnoreCommentBlocks.

@Test
public void testFindAndSetAttributesIgnoreCommentBlocks() {
    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);
    JavaSourceContainer.getInstance().add(javaSource);
    JavaSourceInspector.getInstance().examine();
    assertEquals(0, DependencyContainer.getInstance().getDependencies(javaSource).size());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) 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