Skip to content

Conversation

@tian-pengfei
Copy link
Contributor

@tian-pengfei tian-pengfei commented Dec 5, 2022

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

implement #4235

Function Display

  • config
    image

image

responseContent:

{
  "name": ${expression|#req.json.name},
   "country":${expression|#req.json.address.country},
   "header_name":${expression|#req.headers[header_name]},
    "method":${expression|#req.method},
    "json_id":${expression|#req.json.id},
    "query_id":${expression|#req.queries[id]},
   "uri":${expression|#req.uri}

}
  • send request
    image

image

String expression = params.get(0);
CONTEXT.setVariable("req", mockRequest);
Object val = PARSER.parseExpression(expression).getValue(CONTEXT);
EvaluationContext context = initContext();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to initialize each time?

Copy link
Contributor Author

@tian-pengfei tian-pengfei Dec 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generation mock data on request in multithreading is not safe, this commit slove this preoblem .but it isnt a good method .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here,no thread safety .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean ,thread safety is not required here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes~

@tian-pengfei tian-pengfei changed the title mock plugin supports generation of mock data on request [ISSUE apache#4235]supports generation of mock data on request Dec 5, 2022
@tian-pengfei tian-pengfei changed the title [ISSUE apache#4235]supports generation of mock data on request [ISSUE #4235]supports generation of mock data on request Dec 5, 2022
@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2022

Codecov Report

Merging #4236 (12eccf5) into master (14bc2bd) will decrease coverage by 0.00%.
The diff coverage is 60.78%.

@@             Coverage Diff              @@
##             master    #4236      +/-   ##
============================================
- Coverage     69.58%   69.58%   -0.01%     
- Complexity     7362     7369       +7     
============================================
  Files           992      993       +1     
  Lines         27885    27926      +41     
  Branches       2473     2473              
============================================
+ Hits          19403    19431      +28     
- Misses         7003     7017      +14     
+ Partials       1479     1478       -1     
Impacted Files Coverage Δ
...java/org/apache/shenyu/plugin/mock/MockPlugin.java 0.00% <0.00%> (ø)
...he/shenyu/plugin/mock/generator/BoolGenerator.java 80.00% <ø> (ø)
...yu/plugin/mock/generator/CurrentTimeGenerator.java 77.77% <ø> (ø)
...e/shenyu/plugin/mock/generator/EmailGenerator.java 66.66% <ø> (ø)
...henyu/plugin/mock/generator/EnStringGenerator.java 77.77% <ø> (ø)
...e/shenyu/plugin/mock/generator/PhoneGenerator.java 83.33% <ø> (ø)
...u/plugin/mock/generator/RandomDoubleGenerator.java 75.00% <ø> (ø)
...enyu/plugin/mock/generator/RandomIntGenerator.java 87.50% <ø> (ø)
...enyu/plugin/mock/generator/RangeDataGenerator.java 85.71% <ø> (ø)
...henyu/plugin/mock/generator/ZhStringGenerator.java 77.77% <ø> (ø)
... and 6 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@tian-pengfei tian-pengfei requested a review from yu199195 December 6, 2022 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants