Search in sources :

Example 1 with ApplicationThrottlePolicyTemplateBuilder

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);
}
Also used : ApplicationPolicy(org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy) Test(org.testng.annotations.Test)

Example 2 with ApplicationThrottlePolicyTemplateBuilder

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;
}
Also used : HashMap(java.util.HashMap) ApplicationThrottlePolicyTemplateBuilder(org.wso2.carbon.apimgt.core.template.ApplicationThrottlePolicyTemplateBuilder) ApplicationPolicy(org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)

Aggregations

ApplicationPolicy (org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)2 HashMap (java.util.HashMap)1 Test (org.testng.annotations.Test)1 ApplicationThrottlePolicyTemplateBuilder (org.wso2.carbon.apimgt.core.template.ApplicationThrottlePolicyTemplateBuilder)1