String name = "MockResponse" + Math.random();
testMockResponse = mockOperation.addNewMockResponse(name, false);
testMockResponse.setConfig((MockResponseConfig) mockResponse.getConfig().copy());
testMockResponse.setName(name);
QueryMatchMockOperationDispatcher dispatcher = (QueryMatchMockOperationDispatcher) mockOperation
.setDispatchStyle(MockOperationDispatchStyleConfig.QUERY_MATCH.toString());
for (QueryMatchMockOperationDispatcher.Query query : dispatcher.getQueries()) {
dispatcher.deleteQuery(query);
}
mockOperation.setDefaultResponse(null);
QueryMatchMockOperationDispatcher.Query query = dispatcher.addQuery("Match");
query.setQuery(PropertyExpander.expandProperties(testRunContext, getQuery()));
query.setMatch(PropertyExpander.expandProperties(testRunContext, getMatch()));
query.setResponse(testMockResponse.getName());
} else {
testMockResponse = mockResponse;