Search in sources :

Example 41 with JavaSource

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

the class ExaminerObservesTest method testObservesAnnotated.

@Test
public void testObservesAnnotated() {
    JavaSource javaSource;
    Dependency dependency1;
    Dependency dependency2;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("SnapshotEscalator");
    sourceCode = TestDataProvider.getTestCompleteSourceCodeExample();
    javaSource.setSourceCode(sourceCode);
    examiner.examine(javaSource);
    assertEquals(2, DependencyContainer.getInstance().getDependencies(javaSource).size());
    dependency1 = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(DependencyType.OBSERVES, dependency1.getDependencyType());
    assertEquals("SnapshotEscalator", dependency1.getJavaSourceFrom().getName());
    assertEquals("BrowserWindow", dependency1.getJavaSourceTo().getName());
    dependency2 = DependencyContainer.getInstance().getDependencies(javaSource).get(1);
    assertEquals(DependencyType.OBSERVES, dependency2.getDependencyType());
    assertEquals("SnapshotEscalator", dependency2.getJavaSourceFrom().getName());
    assertEquals("Snapshot", dependency2.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 42 with JavaSource

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

the class ExaminerObservesTest method testObservesWithPhases.

@Test
public void testObservesWithPhases() {
    JavaSource javaSource;
    Dependency dependency;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("SnapshotEscalator");
    sourceCode = TestDataProvider.getTestSourceCodeBeforeBody() + "public void onToDoChange(@Observes(during = TransactionPhase.AFTER_SUCCESS) @ChangeEvent(ChangeEvent.Type.CREATION) ToDo todo) throws EncodeException {\n" + "List<Script> scripts = this.scripting.activeScripts();\n" + "try {\n" + "Bindings binding = this.scriptEngine.createBindings();\n" + "} catch (Exception e) {\n" + "throw new IllegalStateException(\"Exception during script evaluation: \" + e, e);\n" + "}\n" + "}\n";
    javaSource.setSourceCode(sourceCode);
    examiner.examine(javaSource);
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(1, DependencyContainer.getInstance().getDependencies(javaSource).size());
    assertEquals(DependencyType.OBSERVES, dependency.getDependencyType());
    assertEquals("SnapshotEscalator", dependency.getJavaSourceFrom().getName());
    assertEquals("ToDo", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 43 with JavaSource

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

the class ExaminerResourceTest method testFindAndSetAttributesResourceInstance.

@Test
public void testFindAndSetAttributesResourceInstance() {
    JavaSource javaSource;
    Dependency dependency;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("ResourceCollector");
    sourceCode = "@SnapshotDataCollector\n" + "public class ResourceCollector extends AbstractRestDataCollector<List<ConnectionPool>> {\n" + "    private static final String RESOURCES = \"resources\";\n" + "    @Inject\n" + "    @ResourceDataCollector\n" + "    Instance<SpecificResourceCollector> specificCollector;\n" + "    @Inject\n" + "    Instance<Boolean> parallelDataCollection;\n" + "    @Resource\n" + "    TimerService timerService;\n" + "    @Inject\n" + "    ParallelDataCollectionExecutor parallelExecutor;\n" + "}\n";
    javaSource.setSourceCode(sourceCode);
    examiner.examine(javaSource);
    assertEquals(1, DependencyContainer.getInstance().getDependencies(javaSource).size());
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(DependencyType.RESOURCE, dependency.getDependencyType());
    assertEquals("ResourceCollector", dependency.getJavaSourceFrom().getName());
    assertEquals("TimerService", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 44 with JavaSource

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

the class JavaSourceInspectorTest method testFindAndSetAttributesIgnoreComments.

@Test
public void testFindAndSetAttributesIgnoreComments() {
    JavaSource javaSource;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("Cocktail");
    sourceCode = "//@Entity\n" + "//@Access(AccessType.FIELD)\n" + "public class Cocktail implements Comparable<Cocktail>\n" + "{\n" + "// @Id\n" + "private String             id;\n" + "private String             name;\n" + "// @ManyToMany\n" + "private Set<CocktailZutat> zutaten = new HashSet<CocktailZutat>();\n" + "// @ManyToOne\n" + "private CocktailZutat      basisZutat;\n" + "public Cocktail(String id, String name)\n" + "{\n" + "this.id = id;\n" + "this.name = name;\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)

Example 45 with JavaSource

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

the class ExaminerInstanceTest method testFindAndSetAttributesSetInstance.

@Test
public void testFindAndSetAttributesSetInstance() {
    JavaSource javaSource;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("EscalationNotificationBroker");
    sourceCode = "@Singleton\n" + "@ConcurrencyManagement(ConcurrencyManagementType.BEAN)\n" + "public class EscalationNotificationBroker {\n" + "private static final Logger LOG = Logger.getLogger(EscalationNotificationBroker.class.getName());\n" + "@Inject NotifierStore notifierStore;\n" + "@Inject @Any Instance<Transmitter> transmitters;\n" + "@Inject AsyncTransmitterService asyncService;\n" + "}";
    javaSource.setSourceCode(sourceCode);
    examiner.examine(javaSource);
    assertEquals(1, DependencyContainer.getInstance().getDependencies(javaSource).size());
    Dependency dependency;
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(DependencyType.INSTANCE, dependency.getDependencyType());
    assertEquals("EscalationNotificationBroker", dependency.getJavaSourceFrom().getName());
    assertEquals("Transmitter", dependency.getJavaSourceTo().getName());
}
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