요청 로그 수정
This commit is contained in:
@@ -41,7 +41,9 @@ public class MockApiController {
|
|||||||
|
|
||||||
for (MockRoute mockRoute : mockRouteService.getAllRoutes()) {
|
for (MockRoute mockRoute : mockRouteService.getAllRoutes()) {
|
||||||
if (isRouteMatch(mockRoute, request)) {
|
if (isRouteMatch(mockRoute, request)) {
|
||||||
|
logger.debug("===========================");
|
||||||
logger.debug(request.getBody());
|
logger.debug(request.getBody());
|
||||||
|
logger.debug("===========================");
|
||||||
Map<String, String> pathVariables = pathMatcher.extractUriTemplateVariables(mockRoute.getPathPattern(), request.getUri());
|
Map<String, String> pathVariables = pathMatcher.extractUriTemplateVariables(mockRoute.getPathPattern(), request.getUri());
|
||||||
MockResponse matchingResponse = findMatchingResponse(mockRoute, request, pathVariables);
|
MockResponse matchingResponse = findMatchingResponse(mockRoute, request, pathVariables);
|
||||||
if (matchingResponse != null) {
|
if (matchingResponse != null) {
|
||||||
|
|||||||
@@ -22,18 +22,46 @@ import java.util.Map;
|
|||||||
unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
@Component
|
@Component
|
||||||
public abstract class MockRouteMapper {
|
public abstract class MockRouteMapper {
|
||||||
|
|
||||||
|
private static final Map<String, String> XML_ESCAPE_MAP;
|
||||||
|
|
||||||
|
static {
|
||||||
|
XML_ESCAPE_MAP = new HashMap<>();
|
||||||
|
XML_ESCAPE_MAP.put("<", "<");
|
||||||
|
XML_ESCAPE_MAP.put(">", ">");
|
||||||
|
XML_ESCAPE_MAP.put("&", "&");
|
||||||
|
XML_ESCAPE_MAP.put(""", "\"");
|
||||||
|
XML_ESCAPE_MAP.put("'", "'");
|
||||||
|
}
|
||||||
|
|
||||||
public abstract MockRoute map(MockRouteDTO dto);
|
public abstract MockRoute map(MockRouteDTO dto);
|
||||||
|
|
||||||
|
|
||||||
public abstract MockRouteDTO map(MockRoute entity);
|
public abstract MockRouteDTO map(MockRoute entity);
|
||||||
|
|
||||||
@Mapping(target = "headers", source = "headers", qualifiedByName = "mapHeadersToMap")
|
@Mapping(target = "headers", source = "headers", qualifiedByName = "mapHeadersToMap")
|
||||||
@Mapping(target = "defaultResponse", source = "defaultResponse", qualifiedByName = "mapEntityDefaultResponse")
|
@Mapping(target = "defaultResponse", source = "defaultResponse", qualifiedByName = "mapEntityDefaultResponse")
|
||||||
|
@Mapping(target = "body", source="body" , qualifiedByName = "unescapeBody")
|
||||||
public abstract MockResponse map(MockResponseDTO dto);
|
public abstract MockResponse map(MockResponseDTO dto);
|
||||||
|
|
||||||
@Mapping(target = "headers", source = "headers", qualifiedByName = "mapHeadersToList")
|
@Mapping(target = "headers", source = "headers", qualifiedByName = "mapHeadersToList")
|
||||||
@Mapping(target = "defaultResponse", source = "defaultResponse", qualifiedByName = "mapDTODefaultResponse")
|
@Mapping(target = "defaultResponse", source = "defaultResponse", qualifiedByName = "mapDTODefaultResponse")
|
||||||
|
@Mapping(target = "body", source="body" , qualifiedByName = "unescapeBody")
|
||||||
public abstract MockResponseDTO map(MockResponse entity);
|
public abstract MockResponseDTO map(MockResponse entity);
|
||||||
|
|
||||||
|
@Named("unescapeBody")
|
||||||
|
public static String unescapeXml(String escapedXml) {
|
||||||
|
if (escapedXml == null || escapedXml.isEmpty()) {
|
||||||
|
return escapedXml;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<String, String> entry : XML_ESCAPE_MAP.entrySet()) {
|
||||||
|
escapedXml = escapedXml.replace(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return escapedXml;
|
||||||
|
}
|
||||||
|
|
||||||
@Named("mapDTODefaultResponse")
|
@Named("mapDTODefaultResponse")
|
||||||
public String map(boolean value) {
|
public String map(boolean value) {
|
||||||
return value ? "true" : "false";
|
return value ? "true" : "false";
|
||||||
|
|||||||
Reference in New Issue
Block a user