Search in sources :

Example 31 with Dependency

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

the class ExaminerProducesTest method testFindAndSetAttributesStaticProduces.

@Test
public void testFindAndSetAttributesStaticProduces() {
    JavaSource javaSource;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("LoggerProducer");
    sourceCode = "package de.dasd.dasdas.utils.logging;\n" + "import javax.enterprise.inject.Produces;\n" + "import javax.enterprise.inject.spi.InjectionPoint;\n" + "import org.apache.commons.logging.Log;\n" + "import org.apache.commons.logging.LogFactory;\n" + "public class LoggerProducer {\n" + "    @Produces\n" + "    public static Log getLogger(InjectionPoint injectionPoint) {\n" + "        Class<?> targetClass = injectionPoint.getMember().getDeclaringClass();\n" + "        return LogFactory.getLog(targetClass);\n" + "    }\n" + "    private LoggerProducer() {\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.PRODUCES, dependency.getDependencyType());
    assertEquals("LoggerProducer", dependency.getJavaSourceFrom().getName());
    assertEquals("Log", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 32 with Dependency

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

the class JavaSourceTest method testGetDependenciesOfType.

@Test
public void testGetDependenciesOfType() {
    JavaSource javaSource1 = new JavaSource("Testclass01");
    JavaSource javaSource2 = new JavaSource("Testclass02");
    JavaSource javaSource3 = new JavaSource("Testclass03");
    JavaSource javaSource4 = new JavaSource("Testclass04");
    Dependency dependency1_2 = new Dependency(DependencyType.INJECT, javaSource1, javaSource2);
    Dependency dependency1_3 = new Dependency(DependencyType.INJECT, javaSource1, javaSource3);
    Dependency dependency1_4 = new Dependency(DependencyType.EVENT, javaSource1, javaSource4);
    DependencyContainer.getInstance().add(dependency1_2);
    DependencyContainer.getInstance().add(dependency1_3);
    DependencyContainer.getInstance().add(dependency1_4);
    assertEquals(2, DependencyContainer.getInstance().getDependenciesOfType(DependencyType.INJECT).size());
    assertEquals(1, DependencyContainer.getInstance().getDependenciesOfType(DependencyType.EVENT).size());
    assertEquals(0, DependencyContainer.getInstance().getDependenciesOfType(DependencyType.EJB).size());
}
Also used : Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 33 with Dependency

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

the class TestDataProvider method createSampleDependencies.

public static void createSampleDependencies() {
    JavaSourceContainer.getInstance().clear();
    DependencyContainer.getInstance().clear();
    JavaSource producer = JavaSourceFactory.getInstance().newJavaSource("Producer");
    JavaSourceContainer.getInstance().add(producer);
    JavaSource product1 = JavaSourceFactory.getInstance().newJavaSource("Product1");
    JavaSourceContainer.getInstance().add(product1);
    JavaSource product2 = JavaSourceFactory.getInstance().newJavaSource("Product2");
    JavaSourceContainer.getInstance().add(product2);
    JavaSource product3 = JavaSourceFactory.getInstance().newJavaSource("Product3");
    JavaSourceContainer.getInstance().add(product3);
    JavaSource product4 = JavaSourceFactory.getInstance().newJavaSource("Product4");
    JavaSourceContainer.getInstance().add(product4);
    JavaSource instance1 = JavaSourceFactory.getInstance().newJavaSource("Instance1");
    JavaSourceContainer.getInstance().add(instance1);
    JavaSource instance2 = JavaSourceFactory.getInstance().newJavaSource("Instance2");
    JavaSourceContainer.getInstance().add(instance2);
    JavaSource instance3 = JavaSourceFactory.getInstance().newJavaSource("Instance3");
    JavaSourceContainer.getInstance().add(instance3);
    JavaSource instance4 = JavaSourceFactory.getInstance().newJavaSource("Instance4");
    JavaSourceContainer.getInstance().add(instance4);
    Dependency dProducer_Product1 = new Dependency(DependencyType.PRODUCES, producer, product1);
    DependencyContainer.getInstance().add(dProducer_Product1);
    Dependency dProducer_Product2 = new Dependency(DependencyType.PRODUCES, producer, product2);
    DependencyContainer.getInstance().add(dProducer_Product2);
    Dependency dProducer_Product3 = new Dependency(DependencyType.PRODUCES, producer, product3);
    DependencyContainer.getInstance().add(dProducer_Product3);
    Dependency dProducer_Product4 = new Dependency(DependencyType.PRODUCES, producer, product4);
    DependencyContainer.getInstance().add(dProducer_Product4);
    Dependency dProduct1_Instance1 = new Dependency(DependencyType.INSTANCE, instance1, product1);
    DependencyContainer.getInstance().add(dProduct1_Instance1);
    Dependency dProduct2_Instance2 = new Dependency(DependencyType.INSTANCE, instance2, product2);
    DependencyContainer.getInstance().add(dProduct2_Instance2);
    Dependency dProduct3_Instance3 = new Dependency(DependencyType.INSTANCE, instance3, product3);
    DependencyContainer.getInstance().add(dProduct3_Instance3);
    Dependency dProduct4_Instance4 = new Dependency(DependencyType.INSTANCE, instance4, product4);
    DependencyContainer.getInstance().add(dProduct4_Instance4);
    // Add some not relevant (direct connected) JavaSources
    JavaSource notRelevant1 = JavaSourceFactory.getInstance().newJavaSource("NotRelevant1");
    JavaSourceContainer.getInstance().add(notRelevant1);
    JavaSource notRelevant2 = JavaSourceFactory.getInstance().newJavaSource("NotRelevant2");
    JavaSourceContainer.getInstance().add(notRelevant2);
    JavaSource notRelevant3 = JavaSourceFactory.getInstance().newJavaSource("NotRelevant3");
    JavaSourceContainer.getInstance().add(notRelevant3);
    Dependency dInject1_notRelevant1 = new Dependency(DependencyType.INSTANCE, instance1, notRelevant1);
    DependencyContainer.getInstance().add(dInject1_notRelevant1);
    Dependency dInject1_notRelevant2 = new Dependency(DependencyType.INSTANCE, instance1, notRelevant2);
    DependencyContainer.getInstance().add(dInject1_notRelevant2);
    Dependency dInject3_notRelevant1 = new Dependency(DependencyType.INSTANCE, instance3, notRelevant1);
    DependencyContainer.getInstance().add(dInject3_notRelevant1);
    Dependency dInject3_notRelevant3 = new Dependency(DependencyType.INSTANCE, instance3, notRelevant3);
    DependencyContainer.getInstance().add(dInject3_notRelevant3);
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency)

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