use of de.strullerbaumann.visualee.source.entity.JavaSource 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());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource 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());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource 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());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource 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());
}
use of de.strullerbaumann.visualee.source.entity.JavaSource in project visualee by Thomas-S-B.
the class ExaminerObservesTest method testObservesDuring.
@Test
public void testObservesDuring() {
JavaSource javaSource;
Dependency dependency;
String sourceCode;
javaSource = JavaSourceFactory.getInstance().newJavaSource("SnapshotEscalator");
sourceCode = TestDataProvider.getTestSourceCodeBeforeBody() + "public void escalate(@Observes(during=BEFORE_COMPLETION) @Severity(Severity.Level.HEARTBEAT) Snapshot current) {\n" + "}\n";
javaSource.setSourceCode(sourceCode);
examiner.examine(javaSource);
dependency = DependencyContainer.getInstance().getDependencies(javaSource).get(0);
assertEquals(1, DependencyContainer.getInstance().getDependencies(javaSource).size());
assertEquals(DependencyType.OBSERVES, dependency.getDependencyType());
assertEquals("SnapshotEscalator", dependency.getJavaSourceFrom().getName());
assertEquals("Snapshot", dependency.getJavaSourceTo().getName());
}
Aggregations