use of de.strullerbaumann.visualee.source.entity.JavaSource 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());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource 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());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource 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());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource 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());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class JavaSourceContainerTest method testGetJavaSourceByName.
@Test
public void testGetJavaSourceByName() {
JavaSourceContainer.getInstance().clear();
JavaSource javaSource1 = JavaSourceFactory.getInstance().newJavaSource("DataPoint");
JavaSourceContainer.getInstance().add(javaSource1);
JavaSource javaSource2 = JavaSourceFactory.getInstance().newJavaSource("int");
JavaSourceContainer.getInstance().add(javaSource2);
JavaSource javaSource3 = JavaSourceFactory.getInstance().newJavaSource("MyTestClass");
JavaSourceContainer.getInstance().add(javaSource3);
assertNotNull(JavaSourceContainer.getInstance().getJavaSourceByName("MyTestClass"));
assertEquals("MyTestClass", JavaSourceContainer.getInstance().getJavaSourceByName("MyTestClass").getName());
assertNotNull(JavaSourceContainer.getInstance().getJavaSourceByName("int"));
assertEquals("int", JavaSourceContainer.getInstance().getJavaSourceByName("int").getName());
assertNotNull(JavaSourceContainer.getInstance().getJavaSourceByName("DataPoint"));
assertEquals("DataPoint", JavaSourceContainer.getInstance().getJavaSourceByName("DataPoint").getName());
}
Aggregations