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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations