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