use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class JavaSourceInspectorTest method testSetGroupNrs.
@Test
public void testSetGroupNrs() {
JavaSourceContainer.getInstance().clear();
JavaSource javaSource1 = JavaSourceFactory.getInstance().newJavaSource("JavaSource1");
javaSource1.setName("TestClass1");
javaSource1.setPackagePath("package de.strullerbaumann.visualee.test.1;");
JavaSourceContainer.getInstance().add(javaSource1);
JavaSource javaSource2 = JavaSourceFactory.getInstance().newJavaSource("JavaSource2");
javaSource2.setName("TestClass2");
javaSource2.setPackagePath("package de.strullerbaumann.visualee.test.2;");
JavaSourceContainer.getInstance().add(javaSource2);
JavaSource javaSource3 = JavaSourceFactory.getInstance().newJavaSource("JavaSource3");
javaSource3.setName("TestClass3");
javaSource3.setPackagePath("package de.strullerbaumann.visualee.test.1;");
JavaSourceContainer.getInstance().add(javaSource3);
JavaSourceInspector.getInstance().setGroupNrs();
assertEquals(1, javaSource1.getGroup());
assertEquals(javaSource1.getGroup(), javaSource3.getGroup());
assertEquals(2, javaSource2.getGroup());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class ExaminerEventTest method testFindEvents.
@Test
public void testFindEvents() {
DependencyContainer.getInstance().clear();
JavaSource javaSource;
String sourceCode;
javaSource = JavaSourceFactory.getInstance().newJavaSource("Events");
sourceCode = " @Stateless\n" + "public class Events {\n" + " @PersistenceContext\n" + " private EntityManager em;\n" + " @Inject\n" + " private EventValidator validator;\n" + " @Inject\n" + " private PrintingService ps;\n" + " @Inject\n" + " Event<AirEvent> monitoring;\n" + " public List<AirEvent> getEvents() {\n" + " return this.em.createNamedQuery(AirEvent.all).getResultList();\n" + " }\n" + " }\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.EVENT, dependency.getDependencyType());
assertEquals("Events", dependency.getJavaSourceFrom().getName());
assertEquals("AirEvent", dependency.getJavaSourceTo().getName());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class ExaminerEventTest method testFindAndSetAttributesSetInstance.
@Test
public void testFindAndSetAttributesSetInstance() {
DependencyContainer.getInstance().clear();
JavaSource javaSource;
String sourceCode;
javaSource = JavaSourceFactory.getInstance().newJavaSource("TunguskaGate");
sourceCode = "@WebServlet(name = \"TunguskaGate\", urlPatterns = {\"/live/*\"}, asyncSupported = true)\n" + "public class TunguskaGate extends HttpServlet {\n" + " @Inject @SnapshotDataCollector\n" + " Event<BrowserWindow> events;\n" + " private final static Logger LOG = Logger.getLogger(TunguskaGate.class.getName());\n" + " @Override\n" + " protected void doGet(HttpServletRequest request, HttpServletResponse response)\n" + " throws ServletException, IOException {\n" + " AsyncContext startAsync = request.startAsync();\n" + " String channel = extractChannel(request.getRequestURI());\n" + " LOG.info(\"Browser is requesting \" + channel);\n" + " if(channel==null||channel.trim().isEmpty()){\n" + " channel = MonitoringController.COMBINED_SNAPSHOT_NAME;\n" + " }\n" + " BrowserWindow browser = new BrowserWindow(startAsync,channel);\n" + " LOG.info(\"Registering browser window(\"+ browser.hashCode() +\") for channel \" + channel);\n" + " events.fire(browser);\n" + " LOG.fine(\"Event sent\");\n" + " }\n" + " }\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.EVENT, dependency.getDependencyType());
assertEquals("TunguskaGate", dependency.getJavaSourceFrom().getName());
assertEquals("BrowserWindow", dependency.getJavaSourceTo().getName());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class ExaminerInstanceTest method testFindAndSetAttributesSetInstanceGeneric.
@Test
public void testFindAndSetAttributesSetInstanceGeneric() {
JavaSource javaSource;
String sourceCode;
javaSource = JavaSourceFactory.getInstance().newJavaSource("SnapshotProvider");
sourceCode = "public class EscalationNotificationBroker {\n" + "@Inject\n" + " @SnapshotDataCollector" + " Instance<DataCollector<?>> dataCollectors;" + "}";
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("SnapshotProvider", dependency.getJavaSourceFrom().getName());
assertEquals("DataCollector", dependency.getJavaSourceTo().getName());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class ExaminerProducesTest method testFindAndSetAttributesProduces.
@Test
public void testFindAndSetAttributesProduces() {
JavaSource javaSource;
Dependency dependency;
String sourceCode;
javaSource = JavaSourceFactory.getInstance().newJavaSource("DatabaseProducer");
sourceCode = "package org.agoncal.application.petstore.util;\n" + "import javax.enterprise.inject.Produces;\n" + "import javax.persistence.EntityManager;\n" + "import javax.persistence.PersistenceContext;\n" + "public class DatabaseProducer {\n" + "@Produces\n" + " @PersistenceContext(unitName = \"applicationPetstorePU\")\n" + " private EntityManager em;\n" + "}\n";
javaSource.setSourceCode(sourceCode);
examiner.examine(javaSource);
dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
assertEquals(1, DependencyContainer.getInstance().getDependencies(javaSource).size());
assertEquals(DependencyType.PRODUCES, dependency.getDependencyType());
assertEquals("DatabaseProducer", dependency.getJavaSourceFrom().getName());
assertEquals("EntityManager", dependency.getJavaSourceTo().getName());
}
Aggregations