diff --git a/plugin/java/src/main/resources/META-INF/jqassistant-rules/java-classpath.xml b/plugin/java/src/main/resources/META-INF/jqassistant-rules/java-classpath.xml
index 7df79de77..d26f78ef9 100644
--- a/plugin/java/src/main/resources/META-INF/jqassistant-rules/java-classpath.xml
+++ b/plugin/java/src/main/resources/META-INF/jqassistant-rules/java-classpath.xml
@@ -70,8 +70,8 @@
MERGE
(t)-[dependsOn1:DEPENDS_ON]->(t2)
SET
- dependsOn1=dependsOn,
- dependsOn1.resolved=true
+ dependsOn1 = properties(dependsOn),
+ dependsOn1.resolved = true
} IN TRANSACTIONS
RETURN
count(*) as ResolvedDependencies
@@ -95,8 +95,8 @@
MERGE
(t)-[extends1:EXTENDS]->(t2)
SET
- extends1=extends,
- extends1.resolved=true
+ extends1 = properties(extends),
+ extends1.resolved = true
} IN TRANSACTIONS
RETURN
count(*) as ResolvedSuperClass
@@ -120,8 +120,8 @@
MERGE
(t)-[implements1:IMPLEMENTS]->(t2)
SET
- implements1=implements,
- implements1.resolved=true
+ implements1 = properties(implements),
+ implements1.resolved = true
} IN TRANSACTIONS
RETURN
count(*) as ResolvedInterfaces
@@ -145,8 +145,8 @@
MERGE
(f)-[ofType1:OF_TYPE]->(t)
SET
- ofType1=ofType,
- ofType1.resolved=true
+ ofType1 = properties(ofType),
+ ofType1.resolved = true
} IN TRANSACTIONS
RETURN
count(*) as ResolvedFieldTypes
@@ -163,15 +163,40 @@
(:Java:Type)-[:RESOLVES_TO]->(t:Java:Type)
+ (m:Method)-[throws:THROWS{declaration:false}]->(:Java:Type)-[:RESOLVES_TO]->(t:Java:Type)
CALL {
WITH
m, throws, t
MERGE
- (m)-[throws1:THROWS]->(t)
+ (m)-[throws1:THROWS{lineNumber:throws.lineNumber}]->(t)
SET
- throws1=throws,
- throws1.resolved=true
+ throws1 = properties(throws),
+ throws1.resolved = true
+ }
+ RETURN
+ count(*) as ResolvedExceptionTypes
+ ]]>
+
+
+
+
+
+
+
+ Propagates declared "THROWS" relations between methods and types to their resolved types with a property
+ "resolved:true".
+
+ (:Java:Type)-[:RESOLVES_TO]->(t:Java:Type)
+ CALL {
+ WITH
+ m, throws, t
+ MERGE
+ (m)-[throws1:THROWS{declaration:true}]->(t)
+ SET
+ throws1 = properties(throws),
+ throws1.resolved = true
}
RETURN
count(*) as ResolvedExceptionTypes
@@ -195,8 +220,8 @@
MERGE
(m)-[returns1:RETURNS]->(t)
SET
- returns1=returns,
- returns1.resolved=true
+ returns1 = properties(returns),
+ returns1.resolved = true
} IN TRANSACTIONS
RETURN
count(*) as ResolvedReturnTypes
@@ -220,8 +245,8 @@
MERGE
(m)-[ofType1:OF_TYPE]->(t)
SET
- ofType1=ofType,
- ofType1.resolved=true
+ ofType1 = properties(ofType),
+ ofType1.resolved = true
} IN TRANSACTIONS
RETURN
count(*) as ResolvedParameterTypes
@@ -245,8 +270,8 @@
MERGE
(a)-[ofType1:OF_TYPE]->(t)
SET
- ofType1=ofType,
- ofType1.resolved=true
+ ofType1 = properties(ofType),
+ ofType1.resolved = true
} IN TRANSACTIONS
RETURN
count(*) as ResolvedAnnotationTypes
@@ -270,8 +295,8 @@
MERGE
(b)-[ofRawType1:OF_RAW_TYPE]->(t)
SET
- ofRawType1=ofRawType,
- ofRawType1.resolved=true
+ ofRawType1 = properties(ofRawType),
+ ofRawType1.resolved = true
} IN TRANSACTIONS
RETURN
count(*) as ResolvedRawTypes
@@ -296,8 +321,8 @@
MERGE
(v)-[is1:IS]->(e2)
SET
- is1=is,
- is1.resolved=true
+ is1= properties(is),
+ is1.resolved = true
} IN TRANSACTIONS
RETURN
count(*) as ResolvedValueTypes
@@ -321,8 +346,8 @@
MERGE
(m)-[reads1:READS {relationId: id(reads)}]->(f2)
SET
- reads1=reads,
- reads1.resolved=true
+ reads1 = properties(reads),
+ reads1.resolved = true
REMOVE
reads1.relationId
} IN TRANSACTIONS
@@ -348,8 +373,8 @@
MERGE
(m)-[writes1:WRITES {relationId: id(writes)}]->(f2)
SET
- writes1=writes,
- writes1.resolved=true
+ writes1 = properties(writes),
+ writes1.resolved = true
REMOVE
writes1.relationId
} IN TRANSACTIONS
@@ -375,8 +400,8 @@
MERGE
(m)-[invokes1:INVOKES {relationId : id(invokes)}]->(m2)
SET
- invokes1=invokes,
- invokes1.resolved=true
+ invokes1 = properties(invokes),
+ invokes1.resolved = true
REMOVE
invokes1.relationId
}
@@ -394,6 +419,7 @@
+
diff --git a/plugin/java/src/test/java/com/buschmais/jqassistant/plugin/java/test/rules/ClasspathIT.java b/plugin/java/src/test/java/com/buschmais/jqassistant/plugin/java/test/rules/ClasspathIT.java
index a088f3c18..57d18177c 100644
--- a/plugin/java/src/test/java/com/buschmais/jqassistant/plugin/java/test/rules/ClasspathIT.java
+++ b/plugin/java/src/test/java/com/buschmais/jqassistant/plugin/java/test/rules/ClasspathIT.java
@@ -33,22 +33,23 @@ class ClasspathIT extends AbstractJavaPluginIT {
* Verifies the concept "java-classpath:resolveType".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveType() throws Exception {
scanClassesAndApply("java-classpath:ResolveType");
store.beginTransaction();
Map params = MapBuilder.builder()
- .entry("a1", "b")
- .entry("a2", "a")
- .build();
+ .entry("a1", "b")
+ .entry("a2", "a")
+ .build();
List resolvedTypes = query(
- "MATCH (a1:Artifact)-[:REQUIRES]->(t1:Type)-[:RESOLVES_TO]->(rt:Type)<-[:CONTAINS]-(a2:Artifact) WHERE a1.fqn=$a1 and a2.fqn=$a2 RETURN rt",
- params).getColumn("rt");
+ "MATCH (a1:Artifact)-[:REQUIRES]->(t1:Type)-[:RESOLVES_TO]->(rt:Type)<-[:CONTAINS]-(a2:Artifact) WHERE a1.fqn=$a1 and a2.fqn=$a2 RETURN rt",
+ params).getColumn("rt");
assertThat(resolvedTypes).hasSize(6);
- assertThat(resolvedTypes, hasItems(typeDescriptor(AnnotationType.class), typeDescriptor(ClassType.class), typeDescriptor(InterfaceType.class),
- typeDescriptor(EnumType.class), typeDescriptor(ExceptionType.class), typeDescriptor(ValueType.class)));
+ assertThat(resolvedTypes,
+ hasItems(typeDescriptor(AnnotationType.class), typeDescriptor(ClassType.class), typeDescriptor(InterfaceType.class), typeDescriptor(EnumType.class),
+ typeDescriptor(ExceptionType.class), typeDescriptor(ValueType.class)));
store.commitTransaction();
}
@@ -56,26 +57,26 @@ void resolveType() throws Exception {
* Verifies the concept "java-classpath:resolveMember".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveMember() throws Exception {
scanClassesAndApply("java-classpath:ResolveMember");
store.beginTransaction();
Map params = MapBuilder.builder()
- .entry("a1", "b")
- .entry("a2", "a")
- .build();
+ .entry("a1", "b")
+ .entry("a2", "a")
+ .build();
// Methods
List resolvedMethods = query(
- "MATCH (a1:Artifact)-[:REQUIRES]->(:Type)-[:DECLARES]->()-[:RESOLVES_TO]->(rm:Method)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a2:Artifact) WHERE a1.fqn=$a1 and a2.fqn=$a2 RETURN rm",
- params).getColumn("rm");
+ "MATCH (a1:Artifact)-[:REQUIRES]->(:Type)-[:DECLARES]->()-[:RESOLVES_TO]->(rm:Method)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a2:Artifact) WHERE a1.fqn=$a1 and a2.fqn=$a2 RETURN rm",
+ params).getColumn("rm");
assertThat(resolvedMethods).hasSize(3);
assertThat(resolvedMethods, hasItems(constructorDescriptor(ClassType.class), methodDescriptor(ClassType.class, "bar", int.class)));
// Fields
List resolvedFields = query(
- "MATCH (a1:Artifact)-[:REQUIRES]->(:Type)-[:DECLARES]->()-[:RESOLVES_TO]->(rf:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a2:Artifact) WHERE a1.fqn=$a1 and a2.fqn=$a2 RETURN rf",
- params).getColumn("rf");
+ "MATCH (a1:Artifact)-[:REQUIRES]->(:Type)-[:DECLARES]->()-[:RESOLVES_TO]->(rf:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a2:Artifact) WHERE a1.fqn=$a1 and a2.fqn=$a2 RETURN rf",
+ params).getColumn("rf");
assertThat(resolvedFields).hasSize(2);
assertThat(resolvedFields, hasItems(fieldDescriptor(ClassType.class, "foo"), fieldDescriptor(EnumType.B)));
store.commitTransaction();
@@ -85,7 +86,7 @@ void resolveMember() throws Exception {
* Verifies the concept "java-classpath:resolveDependsOn".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveDependsOn() throws Exception {
@@ -96,15 +97,16 @@ private void resolver(String concept) throws Exception {
scanClassesAndApply(concept);
store.beginTransaction();
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("a", "a")
+ .build();
List dependencies = query(
- "MATCH (dependentType:Type)-[d:DEPENDS_ON{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a and d.weight is not null RETURN t",
- params).getColumn("t");
+ "MATCH (dependentType:Type)-[d:DEPENDS_ON{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a and d.weight is not null RETURN t",
+ params).getColumn("t");
assertThat(dependencies).hasSize(6);
- assertThat(dependencies, hasItems(typeDescriptor(AnnotationType.class), typeDescriptor(ClassType.class), typeDescriptor(InterfaceType.class),
- typeDescriptor(EnumType.class), typeDescriptor(ExceptionType.class), typeDescriptor(ValueType.class)));
+ assertThat(dependencies,
+ hasItems(typeDescriptor(AnnotationType.class), typeDescriptor(ClassType.class), typeDescriptor(InterfaceType.class), typeDescriptor(EnumType.class),
+ typeDescriptor(ExceptionType.class), typeDescriptor(ValueType.class)));
store.commitTransaction();
}
@@ -112,19 +114,19 @@ private void resolver(String concept) throws Exception {
* Verifies the concept "java-classpath:resolveExtends".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveExtends() throws Exception {
scanClassesAndApply("java-classpath:ResolveExtends");
store.beginTransaction();
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("a", "a")
+ .build();
List extendedTypes = query(
- "MATCH (dependentType:Type)-[:EXTENDS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a RETURN t",
- params).getColumn("t");
+ "MATCH (dependentType:Type)-[:EXTENDS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a RETURN t",
+ params).getColumn("t");
assertThat(extendedTypes).hasSize(1);
assertThat(extendedTypes, hasItems(typeDescriptor(ClassType.class)));
store.commitTransaction();
@@ -134,19 +136,19 @@ void resolveExtends() throws Exception {
* Verifies the concept "java-classpath:resolveImplements".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveImplements() throws Exception {
scanClassesAndApply("java-classpath:ResolveImplements");
store.beginTransaction();
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("a", "a")
+ .build();
List implementedTypes = query(
- "MATCH (dependentType:Type)-[:IMPLEMENTS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a RETURN t",
- params).getColumn("t");
+ "MATCH (dependentType:Type)-[:IMPLEMENTS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a RETURN t",
+ params).getColumn("t");
assertThat(implementedTypes).hasSize(1);
assertThat(implementedTypes, hasItems(typeDescriptor(InterfaceType.class)));
store.commitTransaction();
@@ -156,66 +158,62 @@ void resolveImplements() throws Exception {
* Verifies the concept "java-classpath:resolveFieldType".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveFieldType() throws Exception {
scanClassesAndApply("java-classpath:ResolveFieldType");
store.beginTransaction();
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("f", "field")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("f", "field")
+ .entry("a", "a")
+ .build();
List fieldTypes = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(f:Field)-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and f.name=$f and a.fqn=$a RETURN t",
- params).getColumn("t");
+ "MATCH (dependentType:Type)-[:DECLARES]->(f:Field)-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and f.name=$f and a.fqn=$a RETURN t",
+ params).getColumn("t");
assertThat(fieldTypes).hasSize(1);
assertThat(fieldTypes, hasItems(typeDescriptor(ClassType.class)));
store.commitTransaction();
}
/**
- * Verifies the concept "java-classpath:resolveThrows".
+ * Verifies the concept "java-classpath:resolveThrows" for exceptions thrown within a message body.
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
- void resolveDeclaredThrows() throws Exception {
+ void resolveThrows() throws Exception {
scanClassesAndApply("java-classpath:ResolveThrows");
store.beginTransaction();
- Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("m", "signature")
- .entry("a", "a")
- .build();
+ Map params = Map.of("dependentType", DependentType.class.getName(), //
+ "m", "throwsException", //
+ "a", "a");
List exceptionTypes = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[:THROWS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN t",
- params).getColumn("t");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[throws:THROWS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a and throws.lineNumber is not null RETURN t",
+ params).getColumn("t");
assertThat(exceptionTypes).hasSize(1);
assertThat(exceptionTypes, hasItems(typeDescriptor(ExceptionType.class)));
store.commitTransaction();
}
/**
- * Verifies the concept "java-classpath:resolveThrows" for exceptions thrown within a message body.
+ * Verifies the concept "java-classpath:resolveThrowsDeclaration" for declared exceptions .
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
- void resolveThrows() throws Exception {
- scanClassesAndApply("java-classpath:ResolveThrows");
+ void resolveThrowsDeclaration() throws Exception {
+ scanClassesAndApply("java-classpath:ResolveThrowsDeclaration");
store.beginTransaction();
- Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("m", "throwsException")
- .entry("a", "a")
- .build();
+ Map params = Map.of("dependentType", DependentType.class.getName(), //
+ "m", "throwsException", //
+ "a", "a");
List exceptionTypes = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[throws:THROWS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a and throws.lineNumber is not null RETURN t",
- params).getColumn("t");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[throws:THROWS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a and throws.declaration RETURN t",
+ params).getColumn("t");
assertThat(exceptionTypes).hasSize(1);
assertThat(exceptionTypes, hasItems(typeDescriptor(ExceptionType.class)));
store.commitTransaction();
@@ -225,20 +223,20 @@ void resolveThrows() throws Exception {
* Verifies the concept "java-classpath:resolveReturns".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveReturns() throws Exception {
scanClassesAndApply("java-classpath:ResolveReturns");
store.beginTransaction();
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("m", "signature")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("m", "signature")
+ .entry("a", "a")
+ .build();
List returnTypes = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[:RETURNS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN t",
- params).getColumn("t");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[:RETURNS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN t",
+ params).getColumn("t");
assertThat(returnTypes).hasSize(1);
assertThat(returnTypes, hasItems(typeDescriptor(ClassType.class)));
store.commitTransaction();
@@ -248,20 +246,20 @@ void resolveReturns() throws Exception {
* Verifies the concept "java-classpath:resolveParameterType".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveParameterType() throws Exception {
scanClassesAndApply("java-classpath:ResolveParameterType");
store.beginTransaction();
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("m", "signature")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("m", "signature")
+ .entry("a", "a")
+ .build();
List parameterTypes = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[:HAS]->(:Parameter)-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN t",
- params).getColumn("t");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[:HAS]->(:Parameter)-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN t",
+ params).getColumn("t");
assertThat(parameterTypes).hasSize(1);
assertThat(parameterTypes, hasItems(typeDescriptor(ClassType.class)));
store.commitTransaction();
@@ -271,7 +269,7 @@ void resolveParameterType() throws Exception {
* Verifies the concept "java-classpath:resolveAnnotationType".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveAnnotationType() throws Exception {
@@ -279,40 +277,40 @@ void resolveAnnotationType() throws Exception {
store.beginTransaction();
// type annotation
Map typeParams = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("a", "a")
+ .build();
List typeAnnotationTypes = query(
- "MATCH (dependentType:Type)-[:ANNOTATED_BY]->()-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a RETURN t",
- typeParams).getColumn("t");
+ "MATCH (dependentType:Type)-[:ANNOTATED_BY]->()-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a RETURN t",
+ typeParams).getColumn("t");
assertThat(typeAnnotationTypes).hasSize(1);
assertThat(typeAnnotationTypes, hasItems(typeDescriptor(AnnotationType.class)));
// field annotation
Map fieldParams = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("f", "field")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("f", "field")
+ .entry("a", "a")
+ .build();
List fieldAnnotationTypes = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(f:Field)-[:ANNOTATED_BY]->()-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and f.name=$f and a.fqn=$a RETURN t",
- fieldParams).getColumn("t");
+ "MATCH (dependentType:Type)-[:DECLARES]->(f:Field)-[:ANNOTATED_BY]->()-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and f.name=$f and a.fqn=$a RETURN t",
+ fieldParams).getColumn("t");
assertThat(fieldAnnotationTypes).hasSize(1);
assertThat(fieldAnnotationTypes, hasItems(typeDescriptor(AnnotationType.class)));
// method annotation
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("m", "signature")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("m", "signature")
+ .entry("a", "a")
+ .build();
List methodAnnotationTypes = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[:ANNOTATED_BY]->()-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN t",
- params).getColumn("t");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[:ANNOTATED_BY]->()-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN t",
+ params).getColumn("t");
assertThat(methodAnnotationTypes).hasSize(1);
assertThat(methodAnnotationTypes, hasItems(typeDescriptor(AnnotationType.class)));
// parameter annotation
List parameterAnnotationTypes = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[:HAS]->(:Parameter)-[:ANNOTATED_BY]->()-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN t",
- params).getColumn("t");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[:HAS]->(:Parameter)-[:ANNOTATED_BY]->()-[:OF_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN t",
+ params).getColumn("t");
assertThat(parameterAnnotationTypes).hasSize(1);
assertThat(parameterAnnotationTypes, hasItems(typeDescriptor(AnnotationType.class)));
store.commitTransaction();
@@ -322,20 +320,20 @@ void resolveAnnotationType() throws Exception {
* Verifies the concept "java-classpath:resolveOfRawType".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveOfRawType() throws Exception {
scanClassesAndApply("java-classpath:ResolveOfRawType");
store.beginTransaction();
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("f", "genericType")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("f", "genericType")
+ .entry("a", "a")
+ .build();
List parameterTypes = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(f:Field)-[:OF_GENERIC_TYPE]->(:ParameterizedType)-[:HAS_ACTUAL_TYPE_ARGUMENT]->(:Bound)-[:OF_RAW_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and f.name=$f and a.fqn=$a RETURN t",
- params).getColumn("t");
+ "MATCH (dependentType:Type)-[:DECLARES]->(f:Field)-[:OF_GENERIC_TYPE]->(:ParameterizedType)-[:HAS_ACTUAL_TYPE_ARGUMENT]->(:Bound)-[:OF_RAW_TYPE{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and f.name=$f and a.fqn=$a RETURN t",
+ params).getColumn("t");
assertThat(parameterTypes).hasSize(1);
assertThat(parameterTypes, hasItems(typeDescriptor(ClassType.class)));
store.commitTransaction();
@@ -345,7 +343,7 @@ void resolveOfRawType() throws Exception {
* Verifies the concept "java-classpath:resolveValue".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveValue() throws Exception {
@@ -353,22 +351,22 @@ void resolveValue() throws Exception {
store.beginTransaction();
// type value
Map typeParams = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("a", "a")
+ .build();
List typeValues = query(
- "MATCH (dependentType:Type)-[:ANNOTATED_BY]->()-[:HAS]->(:Value)-[:IS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a RETURN t",
- typeParams).getColumn("t");
+ "MATCH (dependentType:Type)-[:ANNOTATED_BY]->()-[:HAS]->(:Value)-[:IS{resolved:true}]->(t:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a RETURN t",
+ typeParams).getColumn("t");
assertThat(typeValues).hasSize(1);
assertThat(typeValues, hasItems(typeDescriptor(ValueType.class)));
// enum value
Map enumParams = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("a", "a")
+ .build();
List enumValues = query(
- "MATCH (dependentType:Type)-[:ANNOTATED_BY]->()-[:HAS]->(:Value)-[:IS{resolved:true}]->(f:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a RETURN f",
- enumParams).getColumn("f");
+ "MATCH (dependentType:Type)-[:ANNOTATED_BY]->()-[:HAS]->(:Value)-[:IS{resolved:true}]->(f:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and a.fqn=$a RETURN f",
+ enumParams).getColumn("f");
assertThat(enumValues).hasSize(1);
assertThat(enumValues, hasItems(fieldDescriptor(EnumType.B)));
store.commitTransaction();
@@ -378,7 +376,7 @@ void resolveValue() throws Exception {
* Verifies the concept "java-classpath:resolveReads".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveReads() throws Exception {
@@ -386,13 +384,13 @@ void resolveReads() throws Exception {
store.beginTransaction();
// type value
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("m", "fieldAccess")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("m", "fieldAccess")
+ .entry("a", "a")
+ .build();
List reads = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[r:READS{resolved:true}]->(:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN r",
- params).getColumn("r");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[r:READS{resolved:true}]->(:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN r",
+ params).getColumn("r");
assertThat(reads).hasSize(2);
verifyAllLineNumbers(reads, greaterThan(0));
store.commitTransaction();
@@ -402,7 +400,7 @@ void resolveReads() throws Exception {
* Verifies the concept "java-classpath:resolveReads".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
@@ -415,13 +413,13 @@ void resolveReadsWithoutLineNumber() throws Exception {
store.beginTransaction();
// type value
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("m", "fieldAccess")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("m", "fieldAccess")
+ .entry("a", "a")
+ .build();
List reads = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[r:READS{resolved:true}]->(:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN r",
- params).getColumn("r");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[r:READS{resolved:true}]->(:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN r",
+ params).getColumn("r");
assertThat(reads).hasSize(2);
verifyAllLineNumbers(reads, nullValue());
store.commitTransaction();
@@ -431,7 +429,7 @@ void resolveReadsWithoutLineNumber() throws Exception {
* Verifies the concept "java-classpath:resolveWrites".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveWrites() throws Exception {
@@ -439,13 +437,13 @@ void resolveWrites() throws Exception {
store.beginTransaction();
// type value
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("m", "fieldAccess")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("m", "fieldAccess")
+ .entry("a", "a")
+ .build();
List writes = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[w:WRITES{resolved:true}]->(:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN w",
- params).getColumn("w");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[w:WRITES{resolved:true}]->(:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN w",
+ params).getColumn("w");
assertThat(writes).hasSize(2);
verifyAllLineNumbers(writes, greaterThan(0));
store.commitTransaction();
@@ -456,7 +454,7 @@ void resolveWrites() throws Exception {
* information.
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
@@ -469,13 +467,13 @@ void resolveWritesWithoutLineNumber() throws Exception {
store.beginTransaction();
// type value
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("m", "fieldAccess")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("m", "fieldAccess")
+ .entry("a", "a")
+ .build();
List writes = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[w:WRITES{resolved:true}]->(:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN w",
- params).getColumn("w");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[w:WRITES{resolved:true}]->(:Field)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN w",
+ params).getColumn("w");
assertThat(writes).hasSize(2);
verifyAllLineNumbers(writes, nullValue());
store.commitTransaction();
@@ -485,7 +483,7 @@ void resolveWritesWithoutLineNumber() throws Exception {
* Verifies the concept "java-classpath:resolveInvokes".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveInvokes() throws Exception {
@@ -493,13 +491,13 @@ void resolveInvokes() throws Exception {
store.beginTransaction();
// type value
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("m", "methodInvocation")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("m", "methodInvocation")
+ .entry("a", "a")
+ .build();
List invocations = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[i:INVOKES{resolved:true}]->(:Method)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN i",
- params).getColumn("i");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[i:INVOKES{resolved:true}]->(:Method)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN i",
+ params).getColumn("i");
assertThat(invocations).hasSize(2);
verifyAllLineNumbers(invocations, greaterThan(0));
store.commitTransaction();
@@ -510,7 +508,7 @@ void resolveInvokes() throws Exception {
* information.
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolveInvokesWithoutLineNumber() throws Exception {
@@ -522,13 +520,13 @@ void resolveInvokesWithoutLineNumber() throws Exception {
store.beginTransaction();
// type value
Map params = MapBuilder.builder()
- .entry("dependentType", DependentType.class.getName())
- .entry("m", "methodInvocation")
- .entry("a", "a")
- .build();
+ .entry("dependentType", DependentType.class.getName())
+ .entry("m", "methodInvocation")
+ .entry("a", "a")
+ .build();
List invocations = query(
- "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[i:INVOKES{resolved:true}]->(:Method)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN i",
- params).getColumn("i");
+ "MATCH (dependentType:Type)-[:DECLARES]->(m:Method)-[i:INVOKES{resolved:true}]->(:Method)<-[:DECLARES]-(:Type)<-[:CONTAINS]-(a) WHERE dependentType.fqn=$dependentType and m.name=$m and a.fqn=$a RETURN i",
+ params).getColumn("i");
assertThat(invocations).hasSize(2);
verifyAllLineNumbers(invocations, nullValue());
store.commitTransaction();
@@ -544,17 +542,18 @@ private void verifyAllLineNumbers(List extends LineNumberDescriptor> lineNumbe
* Verifies the concept "java-classpath:Resolve".
*
* @throws IOException
- * If the test fails.
+ * If the test fails.
*/
@Test
void resolve() throws Exception {
scanClassesAndApply("java-classpath:Resolve");
store.beginTransaction();
List concepts = query("MATCH (c:Concept) RETURN c.id as id").getColumn("id");
- assertThat(concepts, hasItems("java-classpath:ResolveDependsOn", "java-classpath:ResolveExtends", "java-classpath:ResolveImplements",
- "java-classpath:ResolveFieldType", "java-classpath:ResolveThrows", "java-classpath:ResolveReturns", "java-classpath:ResolveParameterType",
- "java-classpath:ResolveAnnotationType", "java-classpath:ResolveValue", "java-classpath:ResolveReads", "java-classpath:ResolveWrites",
- "java-classpath:ResolveInvokes"));
+ assertThat(concepts,
+ hasItems("java-classpath:ResolveDependsOn", "java-classpath:ResolveExtends", "java-classpath:ResolveImplements", "java-classpath:ResolveFieldType",
+ "java-classpath:ResolveThrows", "java-classpath:ResolveThrowsDeclaration", "java-classpath:ResolveReturns",
+ "java-classpath:ResolveParameterType", "java-classpath:ResolveAnnotationType", "java-classpath:ResolveValue", "java-classpath:ResolveReads",
+ "java-classpath:ResolveWrites", "java-classpath:ResolveInvokes"));
store.commitTransaction();
}