Search in sources :

Example 6 with Dependency

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

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

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

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

Example 10 with Dependency

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

the class JPAExaminerTest method testFindAndSetAttributesManyToMany.

@Test
public void testFindAndSetAttributesManyToMany() {
    ExaminerJPA jpaExaminer = new ExaminerJPA();
    JavaSource javaSource;
    Dependency dependency;
    String sourceCode;
    // Many to many
    javaSource = JavaSourceFactory.getInstance().newJavaSource("User");
    sourceCode = TestDataProvider.getTestSourceCodeBeforeBody() + "@ManyToMany(cascade = {CascadeType.REFRESH, CascadeType.DETACH}, fetch = FetchType.LAZY)\n" + "@JoinTable(name = \"USERS_GROUPS\", joinColumns = {\n" + "   @JoinColumn(name = \"USERID\", nullable = false)}, inverseJoinColumns = {\n" + "   @JoinColumn(name = \"GROUPID\", nullable = false)})\n" + "private Set<Group> groups;\n";
    javaSource.setSourceCode(sourceCode);
    jpaExaminer.examine(javaSource);
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(1, DependencyContainer.getInstance().getDependencies(javaSource).size());
    assertEquals(DependencyType.MANY_TO_MANY, dependency.getDependencyType());
    assertEquals("User", dependency.getJavaSourceFrom().getName());
    assertEquals("Group", 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