private void buildRequests(Map<String, String> parentHeaders, ResourceDefinition resource, AstAction astAction, AstTransactionExample example) {
if (null != example.getRequests() && example.getRequests().size() > 0) {
// get all requests
for (AstRequest astRequest : example.getRequests()) {
// build request
final RequestDefinition request = new RequestDefinition();
resource.getRequests().add(request);
request.setVerb(astAction.getMethod());
// set headers for inbound matching / request selection
final Map<String, String> requestHeaders = new HashMap<>();
requestHeaders.putAll(parentHeaders);
requestHeaders.putAll(asMap(astRequest.getHeaders()));
request.setHeaders(requestHeaders);
LOGGER.trace("Added request from example: {}", request);
}
} else {
// add a default request if none is specified
final RequestDefinition request = new RequestDefinition();
resource.getRequests().add(request);
request.setVerb(astAction.getMethod());
// set headers for inbound matching / request selection
final Map<String, String> requestHeaders = new HashMap<>();
requestHeaders.putAll(parentHeaders);
request.setHeaders(requestHeaders);
LOGGER.trace("Added default request: {}", request);
}
LOGGER.debug("Built {} request(s) from example", resource.getRequests().size());