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
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly.common</groupId>
<artifactId>wildfly-common</artifactId>
<version>2.0.1</version>
<scope>test</scope>
<!-- Need to exclude jboss-logging as it conflicts with smallrye config. -->
<exclusions>
<exclusion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -165,5 +178,10 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly.common</groupId>
<artifactId>wildfly-common</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
1 change: 1 addition & 0 deletions src/main/resources/META-INF/jqassistant-plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<resource>mockito.xml</resource>
<resource>camunda-bpmn.xml</resource>
<resource>projectreactor.xml</resource>
<resource>wildfly-assert.xml</resource>
</rules>
</jqassistant-plugin>
23 changes: 23 additions & 0 deletions src/main/resources/META-INF/jqassistant-rules/wildfly-assert.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<jqassistant-rules xmlns="http://schema.jqassistant.org/rule/v2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schema.jqassistant.org/rule/v2.2 https://jqassistant.github.io/jqassistant/current/schema/jqassistant-rule-v2.2.xsd">

<concept id="java-testing-wildfly-assert:AssertMethod">
<providesConcept refId="java:AssertMethod"/>
<description>
Sets labels :Assert and :Wildfly for assert methods of the Wildfly Common Library.
</description>
<cypher><![CDATA[
MATCH
(assertType:Type)-[:DECLARES]->(assertMethod)
WHERE
assertType.fqn =~ 'org\\.wildfly\\.common\\.Assert.*'
AND assertMethod.signature =~ '.* assert.*'
SET
assertMethod:Wildfly:Assert
RETURN
assertMethod
]]></cypher>
</concept>

</jqassistant-rules>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests;
import org.mockito.BDDMockito;
import org.mockito.MockedStatic;
import org.wildfly.common.Assert;
import org.xmlunit.assertj.XmlAssert;
import reactor.test.StepVerifier;

Expand Down Expand Up @@ -54,4 +55,8 @@ void projectReactorAssertExampleMethod() {
StepVerifier.create(null).expectComplete().verify();
}

void wildflyAssertExampleMethod() {
Assert.assertTrue(true);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package org.jqassistant.plugin.java_testing.concept;

import com.buschmais.jqassistant.core.report.api.model.Column;
import com.buschmais.jqassistant.core.report.api.model.Result;
import com.buschmais.jqassistant.core.report.api.model.Row;
import com.buschmais.jqassistant.core.rule.api.model.Concept;
import com.buschmais.jqassistant.plugin.java.api.model.MethodDescriptor;
import com.buschmais.jqassistant.plugin.java.api.model.TypeDescriptor;
import com.buschmais.jqassistant.plugin.java.test.AbstractJavaPluginIT;
import org.junit.jupiter.api.Test;
import org.wildfly.common.Assert;

import java.util.List;
import java.util.stream.Collectors;

import static com.buschmais.jqassistant.core.report.api.model.Result.Status.SUCCESS;
import static com.buschmais.jqassistant.plugin.java.test.assertj.MethodDescriptorCondition.methodDescriptor;
import static com.buschmais.jqassistant.plugin.java.test.assertj.TypeDescriptorCondition.typeDescriptor;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.InstanceOfAssertFactories.type;

public class WildflyAssertIT extends AbstractJavaPluginIT {

@Test
void wildflyAssertMethod() throws Exception {
scanClasses(AssertExample.class);

final Result<Concept> conceptResult = applyConcept("java-testing-wildfly-assert:AssertMethod");
assertThat(conceptResult.getStatus()).isEqualTo(SUCCESS);

store.beginTransaction();

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

verifyResultGraph();

store.commitTransaction();
}

@Test
void providedConceptAssertMethod() throws Exception {
scanClasses(AssertExample.class);

final Result<Concept> conceptResult = applyConcept("java:AssertMethod");
assertThat(conceptResult.getStatus()).isEqualTo(SUCCESS);

store.beginTransaction();

final List<TypeDescriptor> declaringTypes = conceptResult.getRows().stream()
.map(Row::getColumns)
.map(columns -> columns.get("DeclaringType"))
.map(Column::getValue)
.map(TypeDescriptor.class::cast)
.collect(Collectors.toList());
assertThat(declaringTypes).haveExactly(1, typeDescriptor(Assert.class));

verifyResultGraph();

store.commitTransaction();
}

// Expects an open transaction
private void verifyResultGraph() throws NoSuchMethodException {
final TestResult methodQueryResult = query(
"MATCH (testMethod:Method)-[:INVOKES]->(assertMethod:Method) "
+ "WHERE assertMethod:Wildfly:Assert "
+ "RETURN testMethod, assertMethod");
assertThat(methodQueryResult.<MethodDescriptor>getColumn("testMethod"))
.haveExactly(1, methodDescriptor(AssertExample.class, "wildflyAssertExampleMethod"));
assertThat(methodQueryResult.<MethodDescriptor>getColumn("assertMethod"))
.haveExactly(1, methodDescriptor(Assert.class, "assertTrue", boolean.class));
}
}
Loading