test master 변경
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.eactive.testmaster.api.condition;
|
||||
|
||||
import com.eactive.testmaster.api.dto.MockRequest;
|
||||
import com.eactive.testmaster.api.entity.MockCondition;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.PathNotFoundException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class JsonPathMatcher implements ConditionMatcher {
|
||||
@Override
|
||||
public boolean matches(MockCondition condition, MockRequest request, Map<String, String> pathVariables) {
|
||||
try {
|
||||
Object value = JsonPath.read(request.getBody(), condition.getKey());
|
||||
return value.toString().equals(condition.getValue());
|
||||
} catch (PathNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "jsonpath";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "JSON Path";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user