use of org.wso2.carbon.apimgt.core.template.CustomThrottlePolicyTemplateBuilder in project carbon-apimgt by wso2.
the class ThrottleTemplateBuilderTestCase method testSiddhiQueryForCustomPolicy.
@Test
public void testSiddhiQueryForCustomPolicy() throws APITemplateException {
CustomPolicy policy = SampleTestObjectCreator.createDefaultCustomPolicy();
CustomThrottlePolicyTemplateBuilder templateBuilder = new CustomThrottlePolicyTemplateBuilder(policy);
String siddhiQuery = templateBuilder.getThrottlePolicyTemplateForCustomPolicy();
String sampleQuery = SampleTestObjectCreator.createDefaultCustomPolicySiddhiApp();
Assert.assertEquals(siddhiQuery, sampleQuery);
}
use of org.wso2.carbon.apimgt.core.template.CustomThrottlePolicyTemplateBuilder in project carbon-apimgt by wso2.
the class PolicyExportManager method getCustomPolicySiddhiApps.
/**
* Get execution plan/ siddhi apps for custom policies.
*
* @param customPolicies custom policy object list
* @return Map<String, String> containing execution plan name and execution plans.
* @throws APITemplateException If template generating fails
*/
private Map<String, String> getCustomPolicySiddhiApps(List<CustomPolicy> customPolicies) throws APITemplateException {
if (log.isDebugEnabled()) {
log.debug("Get execution plans for custom policies.");
}
Map<String, String> siddhiApps = new HashMap<>();
String name;
String executionPlan;
CustomThrottlePolicyTemplateBuilder templateBuilder;
for (CustomPolicy policy : customPolicies) {
templateBuilder = new CustomThrottlePolicyTemplateBuilder(policy);
name = CUSTOM + policy.getPolicyName();
executionPlan = templateBuilder.getThrottlePolicyTemplateForCustomPolicy();
siddhiApps.put(name, executionPlan);
}
return siddhiApps;
}
Aggregations