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
21 changes: 18 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@

<properties>
<camunda-bpm-assert.version>7.24.0</camunda-bpm-assert.version>
<wildfly-common.version>2.0.1</wildfly-common.version>
<projectreactor.version>3.8.5</projectreactor.version>
<spring-boot-starter-test.version>4.0.6</spring-boot-starter-test.version>
<springframework-ws-test.version>5.0.2</springframework-ws-test.version>
</properties>


Expand Down Expand Up @@ -101,13 +105,13 @@
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<version>3.8.5</version>
<version>${projectreactor.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly.common</groupId>
<artifactId>wildfly-common</artifactId>
<version>2.0.1</version>
<version>${wildfly-common.version}</version>
<scope>test</scope>
<!-- Need to exclude jboss-logging as it conflicts with smallrye config. -->
<exclusions>
Expand All @@ -120,7 +124,13 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>4.0.6</version>
<version>${spring-boot-starter-test.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-test</artifactId>
<version>${springframework-ws-test.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -194,5 +204,10 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-test</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 @@ -13,5 +13,6 @@
<resource>projectreactor.xml</resource>
<resource>wildfly-assert.xml</resource>
<resource>spring-reactive.xml</resource>
<resource>spring-ws.xml</resource>
</rules>
</jqassistant-plugin>
25 changes: 25 additions & 0 deletions src/main/resources/META-INF/jqassistant-rules/spring-ws.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<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-spring-ws:AssertMethod">
<providesConcept refId="java:AssertMethod"/>
<description>
Sets labels :Assert and :Spring:WebService for Spring Web Service assert methods.
</description>
<cypher><![CDATA[
MATCH
(assertType:Type)-[:DECLARES]->(assertMethod)
WHERE
assertType.fqn =~ 'org\\.springframework\\.ws\\.test\\.server\\.ResponseActions'
AND assertMethod.signature =~ '.* andExpect.*'
SET
assertMethod:Spring:WebService:Assert
RETURN
assertMethod
ORDER BY
assertMethod.signature
]]></cypher>
</concept>

</jqassistant-rules>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import org.mockito.BDDMockito;
import org.mockito.MockedStatic;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.ws.test.server.MockWebServiceClient;
import org.springframework.ws.test.server.RequestCreators;
import org.springframework.ws.test.server.ResponseMatchers;
import org.springframework.xml.transform.StringSource;
import org.wildfly.common.Assert;
import org.xmlunit.assertj.XmlAssert;
import reactor.test.StepVerifier;
Expand Down Expand Up @@ -65,4 +69,10 @@ void springWebTestClientAssertExampleMethod() {
webTestClient.get().exchange().expectStatus().isOk();
}

void springWebServiceAssertExampleMethod() {
MockWebServiceClient mockWebServiceClient = mock(MockWebServiceClient.class);
mockWebServiceClient.sendRequest(RequestCreators.withPayload(new StringSource("")))
.andExpect(ResponseMatchers.clientOrSenderFault());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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.core.test.plugin.AbstractPluginIT;
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.springframework.ws.test.server.ResponseActions;
import org.springframework.ws.test.server.ResponseMatcher;

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 SpringWebServiceIT extends AbstractJavaPluginIT {

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

final Result<Concept> conceptResult = applyConcept("java-testing-spring-ws: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(ResponseActions.class, "andExpect", ResponseMatcher.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(ResponseActions.class));

verifyResultGraph();

store.commitTransaction();
}

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