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