forked from alibaba/jvm-sandbox-repeater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MockStrategy.java
58 lines (48 loc) · 1.25 KB
/
MockStrategy.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.alibaba.jvm.sandbox.repeater.plugin.spi;
import com.alibaba.jvm.sandbox.repeater.plugin.domain.mock.MockRequest;
import com.alibaba.jvm.sandbox.repeater.plugin.domain.mock.MockResponse;
/**
* {@link MockStrategy} 作为Mock回放的选择策略;负责在N个子调用中选择正确的子调用作为Mock返回
* <p>
* 回放策略来讲开放的实现比较少;用户可以自己定义和实现更多的策略
* </p>
*
* @author zhaoyb1990
*/
public interface MockStrategy {
/**
* 回放策略的类型
*
* @return 回放策略
*/
StrategyType type();
/**
* 执行策略
*
* @param request mock请求对象
* @return mock返回结果
*/
MockResponse execute(final MockRequest request);
enum StrategyType {
/**
* 参数相似度对比
*/
PARAMETER_MATCH("parameter_match"),
/**
* 默认回放策略,阻断所有子调用
*/
DEFAULT("default"),
/**
* 对象对比
*/
OBJECT_DFF("object_dff")
;
private String type;
StrategyType(String type) {
this.type = type;
}
public String getType() {
return type;
}
}
}