Search in sources :

Example 11 with JavaSource

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());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Test(org.junit.Test)

Example 12 with JavaSource

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());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 13 with JavaSource

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());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 14 with JavaSource

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());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 15 with JavaSource

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());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Aggregations

JavaSource (de.strullerbaumann.visualee.source.entity.JavaSource)50 Test (org.junit.Test)44 Dependency (de.strullerbaumann.visualee.dependency.entity.Dependency)31 Scanner (java.util.Scanner)5 DependencyType (de.strullerbaumann.visualee.dependency.entity.DependencyType)3 ArrayList (java.util.ArrayList)3 JsonArrayBuilder (javax.json.JsonArrayBuilder)2 JsonObjectBuilder (javax.json.JsonObjectBuilder)2 ExaminerInject (de.strullerbaumann.visualee.examiner.cdi.ExaminerInject)1 ExaminerProduces (de.strullerbaumann.visualee.examiner.cdi.ExaminerProduces)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 JsonArray (javax.json.JsonArray)1 JsonObject (javax.json.JsonObject)1 Ignore (org.junit.Ignore)1