Search in sources :

Example 1 with Dependency

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

the class ExaminerObservesTest method testFindAndSetAttributesObserves.

@Test
public void testFindAndSetAttributesObserves() {
    JavaSource javaSource;
    Dependency dependency;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("SnapshotEscalator");
    sourceCode = TestDataProvider.getTestSourceCodeBeforeBody() + "public void escalate(@Observes @Severity(Severity.Level.HEARTBEAT) Snapshot current) {\n" + "List<Script> scripts = this.scripting.activeScripts();\n" + "try {\n" + "Bindings binding = this.scriptEngine.createBindings();\n" + "binding.put(\"current\", current);\n" + "Snapshot recent = this.recentSnapshots.get(current.getInstanceName());\n" + "binding.put(\"previous\", recent);\n" + "long start = System.currentTimeMillis();\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("Snapshot", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 2 with Dependency

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

the class ExaminerObservesTest method testObservesNotify.

@Test
public void testObservesNotify() {
    JavaSource javaSource;
    Dependency dependency;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("SnapshotEscalator");
    sourceCode = TestDataProvider.getTestSourceCodeBeforeBody() + "public void escalate(@Observes(notifyObserver=IF_EXISTS) @Severity(Severity.Level.HEARTBEAT) Snapshot current) {\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("Snapshot", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 3 with Dependency

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

the class ExaminerResourceTest method testFindAndSetAttributesResourceMappedName.

@Test
public void testFindAndSetAttributesResourceMappedName() {
    JavaSource javaSource;
    Dependency dependency;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("SimplifiedMessageReceiver");
    sourceCode = "package de.x.y;\n" + "public class SimplifiedMessageReceiver {\n" + "@Resource(mappedName=\"java:global/jms/myQueue2\")\n" + "Queue myQueue;\n" + "}\n";
    javaSource.setSourceCode(sourceCode);
    examiner.examine(javaSource);
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(1, DependencyContainer.getInstance().getDependencies(javaSource).size());
    assertEquals(DependencyType.RESOURCE, dependency.getDependencyType());
    assertEquals("SimplifiedMessageReceiver", dependency.getJavaSourceFrom().getName());
    assertEquals("Queue", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 4 with Dependency

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

the class ExaminerResourceTest method testFindAndSetAttributesResource.

@Test
public void testFindAndSetAttributesResource() {
    JavaSource javaSource;
    Dependency dependency;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("DatabaseConnectionProducer");
    sourceCode = "package de.gedoplan.buch.eedemos.cdi.producer;\n" + "import javax.annotation.Resource;\n" + "import javax.enterprise.context.ApplicationScoped;\n" + "import javax.enterprise.inject.Produces;\n" + "import javax.sql.DataSource;\n" + "@ApplicationScoped\n" + "public class DatabaseConnectionProducer\n" + "{\n" + "@Resource(lookup = \"jdbc/ee-demos\")\n" + "@Produces\n" + "private DataSource dataSource;\n" + "}\n";
    javaSource.setSourceCode(sourceCode);
    examiner.examine(javaSource);
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(1, DependencyContainer.getInstance().getDependencies(javaSource).size());
    assertEquals(DependencyType.RESOURCE, dependency.getDependencyType());
    assertEquals("DatabaseConnectionProducer", dependency.getJavaSourceFrom().getName());
    assertEquals("DataSource", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 5 with Dependency

use of de.strullerbaumann.visualee.dependency.entity.Dependency 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)

Aggregations

Dependency (de.strullerbaumann.visualee.dependency.entity.Dependency)33 JavaSource (de.strullerbaumann.visualee.source.entity.JavaSource)31 Test (org.junit.Test)28 DependencyType (de.strullerbaumann.visualee.dependency.entity.DependencyType)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 JsonArrayBuilder (javax.json.JsonArrayBuilder)1 JsonObjectBuilder (javax.json.JsonObjectBuilder)1 Ignore (org.junit.Ignore)1