spring-cloud / spring-cloud-contract

Support for Consumer Driven Contracts in Spring
https://cloud.spring.io/spring-cloud-contract
Apache License 2.0
719 stars 438 forks source link

Issue generating Pact files using PactContractConverter #1421

Closed lukes1979 closed 4 years ago

lukes1979 commented 4 years ago

I'm trying to generate the pact files as specified here so I can verify the results to my broker. I also get an error running the sample projects with the approach below. Version: spring cloud 2.2.2 & Pact JVM 3.5.23. I've configured the plugin as shown below...

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.6.0</version>
  <executions>
    <execution>
      <id>convert-dsl-to-pact</id>
      <phase>process-test-classes</phase>
      <configuration>
        <classpathScope>test</classpathScope>
        <mainClass>org.springframework.cloud.contract.verifier.util.ToFileContractsTransformer</mainClass>
        <arguments>
          <argument>org.springframework.cloud.contract.verifier.spec.pact.PactContractConverter</argument>
          <argument>${project.basedir}/target/pacts</argument>
          <argument>${project.basedir}/target/generated-test-sources/contracts</argument>
        </arguments>
      </configuration>
      <goals>
        <goal>java</goal>
      </goals>
    </execution>
  </executions>
</plugin>

I get the following error...

[INFO] --- exec-maven-plugin:1.6.0:java (convert-dsl-to-pact) @ employee ---
...
10:55:24.349 [org.springframework.cloud.contract.verifier.util.ToFileContractsTransformer.main()] WARN org.springframework.cloud.contract.verifier.util.ContractVerifierDslConverter - Exception occurred while trying to parse the file [/Users/luke/workspaces/dbs/employee/employee-service/employee/target/generated-test-sources/contracts/com/backbase/dbs/employee/contract/com/backbase/dbs/employee/employee_serviceagreements_get_api_producer_pact/ContractsTest.java] as a contract. Will not parse it.
java.lang.IllegalStateException: Class with name [ContractsTest] not found
    at org.springframework.cloud.contract.verifier.util.ContractVerifierDslConverter.classConstructor(ContractVerifierDslConverter.groovy:166)
    at org.springframework.cloud.contract.verifier.util.ContractVerifierDslConverter.parseJavaFile(ContractVerifierDslConverter.groovy:144)
    at org.springframework.cloud.contract.verifier.util.ContractVerifierDslConverter.toObject(ContractVerifierDslConverter.groovy:131)
    at org.springframework.cloud.contract.verifier.util.ContractVerifierDslConverter.convertAsCollection(ContractVerifierDslConverter.groovy:98)
    at org.springframework.cloud.contract.verifier.util.ContractScanner$1.visitFile(ContractScanner.groovy:88)
    at org.springframework.cloud.contract.verifier.util.ContractScanner$1.visitFile(ContractScanner.groovy)
    at java.nio.file.Files.walkFileTree(Files.java:2670)
    at java.nio.file.Files.walkFileTree(Files.java:2742)
    at org.springframework.cloud.contract.verifier.util.ContractScanner.collectContractDescriptors(ContractScanner.groovy:77)
    at org.springframework.cloud.contract.verifier.util.ContractScanner.collectContractDescriptors(ContractScanner.groovy:59)
    at org.springframework.cloud.contract.verifier.util.ToFileContractsTransformer.storeContractsAsFiles(ToFileContractsTransformer.groovy:75)
    at org.springframework.cloud.contract.verifier.util.ToFileContractsTransformer.main(ToFileContractsTransformer.groovy:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
    at java.lang.Thread.run(Thread.java:748)

The generated sources and generated tests seem to be in the correct place. Any ideas?

marcingrzejszczak commented 4 years ago

Do you have a sample that replicates the issue?

spring-projects-issues commented 4 years ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues commented 4 years ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.