Search in sources :

Example 21 with Dependency

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

the class ExaminerEJBTest method testFindAndSetAttributesEJBSetterWithAnnotations.

@Test
public void testFindAndSetAttributesEJBSetterWithAnnotations() {
    JavaSource javaSource;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("ZeiterfassungEingabeModel");
    sourceCode = "public class ZeiterfassungEingabeModel implements Serializable\n" + "{\n" + "@EJB\n" + "protected void setBuchungsMonat(@Current @Zeiterfassung Date buchungsMonat)\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.EJB, dependency.getDependencyType());
    assertEquals("ZeiterfassungEingabeModel", dependency.getJavaSourceFrom().getName());
    assertEquals("Date", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 22 with Dependency

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

the class ExaminerEJBTest method testFindAndSetAttributesSetEJBPackageView.

@Test
public void testFindAndSetAttributesSetEJBPackageView() {
    JavaSource javaSource;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("MyTestClass");
    sourceCode = "public abstract class MyTestClass {\n" + "@EJB\n" + "PersonSessionBean bean;" + "}\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.EJB, dependency.getDependencyType());
    assertEquals("MyTestClass", dependency.getJavaSourceFrom().getName());
    assertEquals("PersonSessionBean", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 23 with Dependency

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

the class ExaminerEJBTest method testFindAndSetAttributesEJBWithParameter.

@Test
public void testFindAndSetAttributesEJBWithParameter() {
    JavaSource javaSource;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("AlbumServiceImpl");
    sourceCode = "@Stateless\n" + "@EJB(name = \"java:global/galleria/galleria-ejb/AlbumService\", beanInterface = AlbumService.class)\n" + "@RolesAllowed({ \"RegisteredUsers\" })\n" + "@TransactionAttribute(TransactionAttributeType.REQUIRED)\n" + "public class AlbumServiceImpl implements AlbumService\n" + "{\n" + "private static final Logger logger = LoggerFactory.getLogger(AlbumServiceImpl.class);\n" + " @Resource\n" + "	private SessionContext context;\n" + "	@EJB\n" + "	private UserRepository userRepository;\n" + "	@EJB(name = \"java:global/test/test-ejb/TestService\", beanInterface = TestService.class)\n" + "	private AlbumRepository albumRepository;\n" + "	@Override\n" + "	public Album createAlbum(Album album) throws AlbumException\n" + "	{\n" + "		validateAlbum(album);\n" + "		User user = findCurrentUser(CREATE_ALBUM_INTERNAL_ERROR);\n" + "		logger.debug(\"User's albums: {}\", user.getAlbums());\n" + "		if (user.getAlbums().contains(album))\n" + "		{\n" + "			logger.error(\"The album to be created, already exists.\");\n" + "			throw new AlbumException(DUPLICATE_ALBUM);\n" + "		}\n" + "		user.addToAlbums(album);\n" + "		Album createdAlbum = albumRepository.create(album);\n" + "		return createdAlbum;\n" + "	}\n";
    javaSource.setSourceCode(sourceCode);
    examiner.examine(javaSource);
    assertEquals(2, DependencyContainer.getInstance().getDependencies(javaSource).size());
    Dependency dependency;
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(DependencyType.EJB, dependency.getDependencyType());
    assertEquals("AlbumServiceImpl", dependency.getJavaSourceFrom().getName());
    assertEquals("UserRepository", dependency.getJavaSourceTo().getName());
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(1);
    assertEquals(DependencyType.EJB, dependency.getDependencyType());
    assertEquals("AlbumServiceImpl", dependency.getJavaSourceFrom().getName());
    assertEquals("AlbumRepository", dependency.getJavaSourceTo().getName());
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) Dependency(de.strullerbaumann.visualee.dependency.entity.Dependency) Test(org.junit.Test)

Example 24 with Dependency

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

the class ExaminerInjectTest method testFindAndSetAttributesSetInject.

@Test
public void testFindAndSetAttributesSetInject() {
    JavaSource javaSource;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("MyTestClass");
    sourceCode = "public abstract class MyTestClass<K, E extends SingleIdEntity<K>> implements CrudAccessor<K, E>, Serializable {\n" + "protected EntityManager entityManager;\n" + "private Class<E> entityClass;\n" + "@Inject\n" + "TestClass testclass;\n" + "@Inject\n" + "Instance<TestClass2> testclass2;\n" + "@Inject\n" + "Event<TestClass3> testclass3;\n" + "@Inject\n" + "Instance<SnapshotCollector> snapshotCollectorInstance;\n" + "@Inject\n" + "protected void setEntityManager(EntityManager entityManager) {\n" + "        this.entityManager = entityManager;\n" + "}\n";
    javaSource.setSourceCode(sourceCode);
    examiner.examine(javaSource);
    assertEquals(2, DependencyContainer.getInstance().getDependencies(javaSource).size());
    Dependency dependency;
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(DependencyType.INJECT, dependency.getDependencyType());
    assertEquals("MyTestClass", dependency.getJavaSourceFrom().getName());
    assertEquals("TestClass", dependency.getJavaSourceTo().getName());
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(1);
    assertEquals(DependencyType.INJECT, dependency.getDependencyType());
    assertEquals("MyTestClass", 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 25 with Dependency

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

the class ExaminerInjectTest method testFindEventNamedClass.

@Test
public void testFindEventNamedClass() {
    DependencyContainer.getInstance().clear();
    JavaSource javaSource;
    String sourceCode;
    javaSource = JavaSourceFactory.getInstance().newJavaSource("Events");
    sourceCode = "     @Stateless\n" + "public class Events {\n" + " @Inject\n" + " private EventValidator validator;\n" + " @Inject\n" + " private PrintingService ps;\n" + "    }\n";
    javaSource.setSourceCode(sourceCode);
    examiner.examine(javaSource);
    assertEquals(2, DependencyContainer.getInstance().getDependencies(javaSource).size());
    Dependency dependency;
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
    assertEquals(DependencyType.INJECT, dependency.getDependencyType());
    assertEquals("Events", dependency.getJavaSourceFrom().getName());
    assertEquals("EventValidator", dependency.getJavaSourceTo().getName());
    dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(1);
    assertEquals(DependencyType.INJECT, dependency.getDependencyType());
    assertEquals("Events", dependency.getJavaSourceFrom().getName());
    assertEquals("PrintingService", 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