Support for UserDefinedValue can be fetched from configured json DataSource #183
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Created support for UsedDefinedValue to be fetched from a Json or http endpoint along with option to apply filter on the Datasource. This requirement is needed for me, when I tried creating berserker configurations in the form of a workflow for a Rest service having dependent rest Endpoints. And I believe that this is a requirement that most berserker users like.
Method Usage:
userDefinedValue("DataSourceName","JsonPathQuery","refreshIntervalInSeconds","regExpressionToFetchExpectedStringFromFetchedField")
DataSourceName: Can be a name of JSON file available in classpath/ A Rest endpoint that return a JSON response
JsonPathQuery: JSON path query to extract a Filed from specified Data Source. For semantics, please refer to https://github.com/json-path/JsonPath
refreshIntervalInSeconds: To refresh the data at configured intervals if the source support dynamic data retrieval.
regExpressionToFetchExpectedStringFromFetchedField: To support the case where the requirement is not complete field and only specific part.
example definitions:
Sample JSON:
{
"firstName": "John",
"lastName" : "doe",
"age" : 26,
"address" : {
"streetAddress": "naist street",
"city" : "Nara",
"postalCode" : "630-0192"
},
"phoneNumbers": [
{
"type" : "iPhone",
"number": "0123-4567-8888"
},
{
"type" : "home",
"number": "0123-4567-8910"
}
]
}
userDefinedValue("resources","$.phoneNumbers[].type","100"," ")
userDefinedValue("http:/url/resources","$.phoneNumbers[].type","100"," ")
above Value Definition will evaluate to Values
"iPhone",
"home"