use of com.mulesoft.tools.migration.library.gateway.TestConstants.POLICY_TAG_NAME in project mule-migration-assistant by mulesoft.
the class AbstractThrottlingTestCase method createPolicy.
protected Element createPolicy(int rateLimitElements, String algorithmTagName, boolean isRateLimit) {
Element policy = new Element(POLICY_TAG_NAME, MULE_3_POLICY_NAMESPACE);
Element throttlingPolicy = new Element(POLICY_TAG_NAME, THROTTLING_GW_MULE_3_NAMESPACE);
throttlingPolicy.addContent(isRateLimit ? getNewElement(DISCARD_RESPONSE_TAG_NAME) : getDelayResponseElement());
Element algorithmElement = getNewElement(algorithmTagName);
IntStream.range(0, rateLimitElements).mapToObj(i -> getRateLimitElement(String.valueOf(i))).forEach(algorithmElement::addContent);
throttlingPolicy.addContent(algorithmElement);
new Document().setRootElement(policy.addContent(throttlingPolicy));
return algorithmElement;
}
Aggregations