我正在尝试在项目中实现存根,但是在尝试构建它时出现以下错误:
email
由于错误发生的代码是自动生成的,因此我不确定该怎么做。
这是正在自动生成的测试类:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project customer-previous-address-older-version: Compilation failure
[ERROR] /archive/target/generated-test-sources/contracts/address/ContractVerifierTest.java:[18,63] cannot find symbol
[ERROR] symbol: class ContractVerifierUtil
[ERROR] location: package org.springframework.cloud.contract.verifier.util
我添加了以下依赖关系,我认为这可以解决问题,但事实并非如此:
package ie.aib.customer.address;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import PreviousAddressBaseTest;
import io.restassured.module.mockmvc.specification.MockMvcRequestSpecification;
import io.restassured.response.ResponseOptions;
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.junit.Test;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;
import static io.restassured.module.mockmvc.RestAssuredMockMvc.*;
import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat;
import static org.springframework.cloud.contract.verifier.util.ContractVerifierUtil.*;
public class ContractVerifierTest extends PreviousAddressBaseTest {
@Test
public void validate_shouldReturnPreviousAddress() throws Exception {
// given:
MockMvcRequestSpecification request = given();
// when:
ResponseOptions response = given().spec(request)
.get("/previous-address");
// then:
assertThat(response.statusCode()).isEqualTo(200);
assertThat(response.header("Content-Type")).matches("text/plain;charset=ISO-8859-1");
// and:
String responseBody = response.getBody().asString();
assertThat(responseBody).isEqualTo("Send me something!");
}
}
答案 0 :(得分:0)
尝试在我们的Maven POM部分中添加spring-cloud-dependencies。还应确保spring-cloud.version到处都相同,包括依赖项spring-cloud-contract-verifier,因为我因此而遇到了此错误。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>