Search in sources :

Example 26 with Dependency

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

the class ExaminerObservesTest method testObservesDuring.

@Test
public void testObservesDuring() {
    JavaSource javaSource;
    Dependency dependency;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("SnapshotEscalator");
    sourceCode = TestDataProvider.getTestSourceCodeBeforeBody() + "public void escalate(@Observes(during=BEFORE_COMPLETION) @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 27 with Dependency

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

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

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

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

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