Search in sources :

Example 1 with SubscriptionThrottlePolicyTemplateBuilder

use of org.wso2.carbon.apimgt.core.template.SubscriptionThrottlePolicyTemplateBuilder in project carbon-apimgt by wso2.

the class ThrottleTemplateBuilderTestCase method testSiddhiQueryForSubscriptionPolicy.

@Test
public void testSiddhiQueryForSubscriptionPolicy() throws APITemplateException {
    SubscriptionPolicy policy = SampleTestObjectCreator.createDefaultSubscriptionPolicy();
    SubscriptionThrottlePolicyTemplateBuilder templateBuilder = new SubscriptionThrottlePolicyTemplateBuilder(policy);
    String siddhiQuery = templateBuilder.getThrottlePolicyForSubscriptionLevel();
    String sampleQuery = SampleTestObjectCreator.createDefaultSiddhiAppforSubscriptionPolicy();
    Assert.assertEquals(siddhiQuery, sampleQuery);
}
Also used : SubscriptionPolicy(org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy) Test(org.testng.annotations.Test)

Example 2 with SubscriptionThrottlePolicyTemplateBuilder

use of org.wso2.carbon.apimgt.core.template.SubscriptionThrottlePolicyTemplateBuilder in project carbon-apimgt by wso2.

the class PolicyExportManager method getSubscriptionPolicySiddhiApps.

/**
 * Get execution plan/ siddhi apps for custom policies.
 *
 * @param subscriptionPolicies SubscriptionPolicy object list
 * @return Map<String, String> containing execution plan name and execution plans.
 * @throws APITemplateException If template generating fails
 */
private Map<String, String> getSubscriptionPolicySiddhiApps(List<SubscriptionPolicy> subscriptionPolicies) throws APITemplateException {
    if (log.isDebugEnabled()) {
        log.debug("Get execution plans for Subscription policies.");
    }
    Map<String, String> siddhiApps = new HashMap<>();
    String name;
    String executionPlan;
    SubscriptionThrottlePolicyTemplateBuilder templateBuilder;
    for (SubscriptionPolicy policy : subscriptionPolicies) {
        name = SUBSCRIPTION + policy.getPolicyName();
        templateBuilder = new SubscriptionThrottlePolicyTemplateBuilder(policy);
        executionPlan = templateBuilder.getThrottlePolicyForSubscriptionLevel();
        siddhiApps.put(name, executionPlan);
    }
    return siddhiApps;
}
Also used : HashMap(java.util.HashMap) SubscriptionPolicy(org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy) SubscriptionThrottlePolicyTemplateBuilder(org.wso2.carbon.apimgt.core.template.SubscriptionThrottlePolicyTemplateBuilder)

Aggregations

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