Skip to content

Commit

Permalink
feat: update docs on providing raw selector JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
uglyog committed Sep 1, 2022
1 parent 416b19d commit d31b3e6
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
12 changes: 12 additions & 0 deletions provider/gradle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,18 @@ Using the generic selector:
}
```

##### Raw JSON

You can also provide the raw JSON snippets for selectors.

```groovy
fromPactBroker {
withSelectors {
rawSelectorJson('{"tag": "tagname"}')
}
}
```

### For Pact-JVM versions before 4.1.0

You configure your service provider and then use the `hasPactsFrom..` methods.
Expand Down
1 change: 1 addition & 0 deletions provider/junit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ The builder has the following methods:
- `environment(environment: String)` - Any versions currently deployed or released and supported in the specified environment.
- `tag(name: String)` - All versions with the specified tag. Tags are deprecated in favor of branches.
- `latestTag(name: String)` - The latest version for each consumer with the specified tag. Tags are deprecated in favor of branches.
- `rawSelectorJson(json: String)` - You can also provide the raw JSON snippets for selectors.

If you require more control, your selector method can also return a list of `au.com.dius.pact.core.pactbroker.ConsumerVersionSelectors`
instead of the builder class.
Expand Down
1 change: 1 addition & 0 deletions provider/junit5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ Used for coordinated development between consumer and provider teams using match
- `environment(environment: String)` - Any versions currently deployed or released and supported in the specified environment.
- `tag(name: String)` - All versions with the specified tag. Tags are deprecated in favor of branches.
- `latestTag(name: String)` - The latest version for each consumer with the specified tag. Tags are deprecated in favor of branches.
- `rawSelectorJson(json: String)` - You can also provide the raw JSON snippets for selectors.

If you require more control, your selector method can also return a list of `au.com.dius.pact.core.pactbroker.ConsumerVersionSelectors`
instead of the builder class.
Expand Down
26 changes: 26 additions & 0 deletions provider/maven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,32 @@ Supports all the forms of selecting Pacts with tags.
</plugin>
```

##### Raw JSON

You can also provide the raw JSON snippets for selectors.

```xml
<plugin>
<groupId>au.com.dius.pact.provider</groupId>
<artifactId>maven</artifactId>
<version>4.3.12</version>
<configuration>
<serviceProviders>
<serviceProvider>
<name>provider1</name>
<PactBroker>
<selectors>
<rawJson>
<json>{"tag": "tagname"}</json>
</rawJson>
</selectors>
</PactBroker>
</serviceProvider>
</serviceProviders>
</configuration>
</plugin>
```

### Verifying pacts from a pact broker that match particular tags [DEPRECATED]

**NOTE: Using tags has been deprecated in favour of using consumer version selectors (above).**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.com.dius.pact.provider.maven

import au.com.dius.pact.core.pactbroker.ConsumerVersionSelectors
import au.com.dius.pact.core.support.json.JsonParser
import org.apache.maven.plugin.MojoFailureException
import java.net.URL

Expand Down Expand Up @@ -180,6 +181,19 @@ open class Selector: BaseSelector() {
}
}

/**
* Corresponds to the old consumer version selectors
*/
open class RawJson: BaseSelector() {
var json: String? = null

override fun toSelector() = ConsumerVersionSelectors.RawSelector(JsonParser.parseString(json.orEmpty()))

override fun toString(): String {
return "RawJson(json=$json)"
}
}

/**
* Bean to configure a pact broker to query
*/
Expand Down

0 comments on commit d31b3e6

Please sign in to comment.