Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/main/resources/META-INF/jqassistant-rules/assertj.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
(assertType:Type)-[:DECLARES]->(assertMethod)
WHERE
assertType.fqn =~ 'org\\.assertj\\.core\\.api\\..*Assertions.*'
AND assertMethod.signature =~ '.* assert.*'
AND (
assertMethod.signature =~ '.* assert.*' OR
assertMethod.signature =~ '.* fail.*'
)
SET
assertMethod:AssertJ:Assert
RETURN
assertMethod
ORDER BY
assertMethod.signature
]]></cypher>
</concept>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ void assertjAssertExampleMethod() {
Assertions.assertThat(true).isTrue();
}

void assertjFailExampleMethod() { Assertions.fail("fail"); }

void xmlAssertExampleMethod() {
XmlAssert.assertThat("<nop/>").and("<nop />").normalizeWhitespace().areSimilar();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ void assertjAssertMethod() throws Exception {

store.beginTransaction();

assertThat(conceptResult.getRows().size()).isEqualTo(1);
assertThat(conceptResult.getRows().size()).isEqualTo(2);
assertThat(conceptResult.getRows()
.get(0)
.getColumns()
.get("assertMethod")
.getValue()).asInstanceOf(type(MethodDescriptor.class))
.is(methodDescriptor(Assertions.class, "fail", String.class));
assertThat(conceptResult.getRows()
.get(1)
.getColumns()
.get("assertMethod")
.getValue()).asInstanceOf(type(MethodDescriptor.class))
.is(methodDescriptor(Assertions.class, "assertThat", boolean.class));

verifyResultGraph();
Expand Down Expand Up @@ -74,8 +80,12 @@ private void verifyResultGraph() throws NoSuchMethodException {
+ "RETURN testMethod, assertMethod");
assertThat(methodQueryResult.<MethodDescriptor>getColumn("testMethod"))
.haveExactly(1, methodDescriptor(AssertExample.class, "assertjAssertExampleMethod"));
assertThat(methodQueryResult.<MethodDescriptor>getColumn("testMethod"))
.haveExactly(1, methodDescriptor(AssertExample.class, "assertjFailExampleMethod"));
assertThat(methodQueryResult.<MethodDescriptor>getColumn("assertMethod"))
.haveExactly(1, methodDescriptor(Assertions.class, "assertThat", boolean.class));
assertThat(methodQueryResult.<MethodDescriptor>getColumn("assertMethod"))
.haveExactly(1, methodDescriptor(Assertions.class, "fail", String.class));
}

}
Loading