Skip to content

Commit

Permalink
#15 added support for transactional interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
DirkMahler authored Jul 19, 2024
2 parents 3c1a12e + 8f08f21 commit 2a631dd
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@

<concept id="spring-transaction:TransactionalClass">
<description>
Label all classes annotated with "@org.springframework.transaction.annotation.Transactional", "jakarta.transaction.Transactional",
Label all classes directly or indirectly annotated with "@org.springframework.transaction.annotation.Transactional", "jakarta.transaction.Transactional",
or "javax.transaction.Transactional", and their declared methods with "Spring" and "Transactional".
</description>
<cypher><![CDATA[
MATCH
(transactionalClass:Class)-[:EXTENDS*0..]->(:Class)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(annotationType:Type)
(transactionalClass:Type)-[:EXTENDS|IMPLEMENTS*0..]->(:Type)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(annotationType:Type)
WHERE
annotationType.fqn in [
"org.springframework.transaction.annotation.Transactional",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;


class TransactionalMethodIT extends AbstractSpringIT {

@Test
Expand All @@ -30,19 +29,30 @@ void transactionalMethod() throws Exception {

@Test
void transactionalClass() throws Exception {
scanClasses(SpringTransactionalClass.class, SpringTransactionalSubClass.class, JtaTransactionalClass.class, JtaJakartaTransactionalClass.class);
scanClasses(SpringTransactionalClass.class, SpringTransactionalSubClass.class,
SpringTransactionalInterface.class, SpringTransactionalImplementingClass.class,
JtaTransactionalClass.class, JtaJakartaTransactionalClass.class);
assertThat(applyConcept("spring-transaction:TransactionalClass").getStatus(), equalTo(SUCCESS));
store.beginTransaction();
List<Object> classes = query("MATCH (c:Spring:Class:Transactional) RETURN c").getColumn("c");
assertThat(classes.size(), equalTo(4));
List<Object> classes = query("MATCH (c:Spring:Type:Transactional) RETURN c").getColumn("c");
assertThat(classes.size(), equalTo(6));
assertThat(classes, hasItem(typeDescriptor(SpringTransactionalClass.class)));
assertThat(classes, hasItem(typeDescriptor(SpringTransactionalSubClass.class)));
assertThat(classes, hasItem(typeDescriptor(SpringTransactionalInterface.class)));
assertThat(classes,
hasItem(typeDescriptor(SpringTransactionalImplementingClass.class)));
assertThat(classes, hasItem(typeDescriptor(JtaTransactionalClass.class)));
assertThat(classes, hasItem(typeDescriptor(JtaJakartaTransactionalClass.class)));
List<Object> methods = query("MATCH (m:Spring:Method:Transactional) RETURN m").getColumn("m");
assertThat(methods.size(), equalTo(4));
assertThat(methods.size(), equalTo(7));
assertThat(methods, hasItem(methodDescriptor(SpringTransactionalClass.class, "transactionalMethod")));
assertThat(methods, hasItem(methodDescriptor(SpringTransactionalSubClass.class, "transactionalSubClassMethod")));
assertThat(methods,
hasItem(methodDescriptor(SpringTransactionalSubClass.class, "transactionalSubClassMethod")));
assertThat(methods, hasItem(methodDescriptor(SpringTransactionalInterface.class, "transactionalMethod")));
assertThat(methods,
hasItem(methodDescriptor(SpringTransactionalImplementingClass.class, "transactionalMethod")));
assertThat(methods,
hasItem(methodDescriptor(SpringTransactionalImplementingClass.class, "transactionalImplementingClassMethod")));
assertThat(methods, hasItem(methodDescriptor(JtaTransactionalClass.class, "transactionalMethod")));
assertThat(methods, hasItem(methodDescriptor(JtaJakartaTransactionalClass.class, "transactionalMethod")));
store.commitTransaction();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.jqassistant.plugin.spring.test.set.transaction;

import org.springframework.stereotype.Service;

@Service
public class SpringTransactionalImplementingClass implements SpringTransactionalInterface {

public static void staticMethod() {
// intentionally left blank
}

public void transactionalImplementingClassMethod() {
// intentionally left blank
}

@Override
public void transactionalMethod() {
// intentionally left blank
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.jqassistant.plugin.spring.test.set.transaction;

import org.springframework.transaction.annotation.Transactional;

@Transactional
public interface SpringTransactionalInterface {

void transactionalMethod();

}

0 comments on commit 2a631dd

Please sign in to comment.