Search code examples
neo4jcypherjqassistant

jQAssistant scan missing value for retrofit2.http.GET


After scanning my project with cli-jqassistant-commandline-neo4jv4-2.1.0.jar and executing a cypher to get the value of @GET(value = "/test/two"), no record is returned.

I tried the following: I have the following interface in my project

import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;

interface TestService
{
    @POST(value = "/test/one")
    Call<ResponseBody> executeQuery(@Path("test") String test);

    @GET(value = "/test/two")
    Call<ResponseBody> getQuery(@Path("test") String test);

}

I'm running cli-jqassistant-commandline-neo4jv4-2.1.0.jar to scan the project When I execute the following cypher:

MATCH (client:Interface)-[:DECLARES]->(m:Method)
MATCH (m)-[:ANNOTATED_BY]->(ann:Annotation)-[:HAS]->(:Value{name:"value"})-[:CONTAINS]->(url:Value)
return url.value

OR

MATCH (client:Interface)-[:DECLARES]->(m:Method)
MATCH (m)-[:ANNOTATED_BY]->(ann:Annotation)-[:OF_TYPE]->(:Type{name:"GET"})
MATCH (ann)-[:HAS]->(:Value{name:"value"})-[:CONTAINS]->(url:Value)
return m

I don't get anything as result. I expect to get both values value = "/test/one" and value = "/test/two"

if I execute the following cypher:

MATCH (client:Interface)-[:DECLARES]->(m:Method)
return m

I get the following result:

{
  "identity": 12598,
  "labels": [
    "Java",
    "ByteCode",
    "Method",
    "Member"
  ],
  "properties": {
    "visibility": "public",
    "signature": "retrofit2.Call executeQuery(java.lang.String)",
    "name": "executeQuery",
    "abstract": true,
    "cyclomaticComplexity": 0
  },
  "elementId": "12598"
},
{
  "identity": 12611,
  "labels": [
    "Java",
    "ByteCode",
    "Method",
    "Member"
  ],
  "properties": {
    "visibility": "public",
    "signature": "retrofit2.Call getQuery(java.lang.String)",
    "name": "getQuery",
    "abstract": true,
    "cyclomaticComplexity": 0
  },
  "elementId": "12611"
}

The methods are there, but the values are missing. Is this a problem of the cypher or it is not scanning and recording these values?


Solution

  • The query for getting the value for the GET annotation should be like this:

    MATCH
      (client:Interface)-[:DECLARES]->(m:Method),
      (m)-[:ANNOTATED_BY]->(ann)-[:OF_TYPE]->(:Type{fqn: "retrofit2.http.GET"}),
      (ann)-[:HAS]->(v:Value:Primitive{name:"value"})
    RETURN
      client.fqn, m.signature, v.value
    

    Notice the fully qualified name for the annotation which is needed (because the annotation class itself is not scanned and therefore the property name is not available, only fqn)