Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
added IT for artifacts and their dependencies created by Maven projects
Browse files Browse the repository at this point in the history
  • Loading branch information
DirkMahler committed Jun 23, 2024
1 parent 82d5ee7 commit fa181e5
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<jqa:jqassistant-rules xmlns:jqa="http://www.buschmais.com/jqassistant/core/rule/schema/v1.3">

<group id="default" severity="blocker">
<includeConcept refId="test:*"/>
</group>

<!-- These concepts verify the as-is status, there are currently more artifacts created than actually exist in the scanned code -->

<concept id="test:ArtifactDependencies">
<description>Verifies expected artifact dependencies.</description>
<cypher><![CDATA[
MATCH
(:Maven:Project)-[:CREATES]->(a1:Artifact),
(:Maven:Project)-[:CREATES]->(a2:Artifact),
(a1)-[:DEPENDS_ON]->(a2)
RETURN
count(*) as count
]]></cypher>
<verify>
<aggregation column="count" min="5" max="5"/>
</verify>
</concept>

<concept id="test:ExpectedArtifactDependencies">
<description>Verifies expected artifact dependencies.</description>
<cypher><![CDATA[
WITH
[
{
from: { name: "test-only", type:"jar"},
to: [ { name: "main-only", type:"jar"} ]
},
{
from: { name: "main-only", type:"test-jar"},
to: [ { name: "main-only", type:"jar"} ]
},
{
from: { name: "test-only", type:"test-jar"},
to: [ { name: "test-only", type:"jar"} ]
},
{
from: { name: "main-and-test", type:"test-jar"},
to: [ { name: "main-and-test", type:"jar"} ]
},
{
from: { name: "project-artifacts", type:"test-jar"},
to: [ { name: "project-artifacts", type:"pom"} ]
}
] as expectedDependencies
UNWIND
expectedDependencies as expectedDependency
UNWIND
expectedDependency.to as to
MATCH
(:Maven:Project)-[:CREATES]->(a1:Artifact),
(:Maven:Project)-[:CREATES]->(a2:Artifact),
(a1)-[:DEPENDS_ON]->(a2)
WHERE
a1.name ends with expectedDependency.from.name and a1.type=expectedDependency.from.type
and a2.name ends with to.name and a2.type=to.type
RETURN
count(*) as count
]]></cypher>
<verify>
<aggregation column="count" min="5" max="5"/>
</verify>
</concept>

</jqa:jqassistant-rules>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>@project.groupId@</groupId>
<artifactId>@[email protected]</artifactId>
<version>@project.version@</version>
</parent>
<artifactId>@[email protected]</artifactId>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.buschmais.jqassistant.maven.main_and_test;

/**
* Created by dmahler on 3/6/17.
*/
public class B {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.buschmais.jqassistant.maven.main_and_test;

import com.buschmais.jqassistant.maven.main_and_test.B;

/**
* Created by dmahler on 3/6/17.
*/
public class BTest {

private B b;

public BTest(B b) {
this.b = b;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>@project.groupId@</groupId>
<artifactId>@[email protected]</artifactId>
<version>@project.version@</version>
</parent>
<artifactId>@[email protected]</artifactId>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.buschmais.jqassistant.maven.main_only;

/**
* Created by dmahler on 3/6/17.
*/
public class A {
}
17 changes: 17 additions & 0 deletions src/it/multimodule/singleparent/project-artifacts/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>@project.groupId@</groupId>
<artifactId>@[email protected]</artifactId>
<version>@project.version@</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<artifactId>@[email protected]</artifactId>
<packaging>pom</packaging>

<modules>
<module>main-only</module>
<module>test-only</module>
<module>main-and-test</module>
</modules>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>@project.groupId@</groupId>
<artifactId>@[email protected]</artifactId>
<version>@project.version@</version>
</parent>
<artifactId>@[email protected]</artifactId>

<dependencies>
<dependency>
<groupId>@project.groupId@</groupId>
<artifactId>@[email protected]</artifactId>
<version>@project.version@</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.buschmais.jqassistant.maven.test_only;

import com.buschmais.jqassistant.maven.main_only.A;

/**
* Created by dmahler on 3/6/17.
*/
public class ATest {

private A a;

public ATest(A a) {
this.a = a;
}

}

0 comments on commit fa181e5

Please sign in to comment.