Search in sources :

Example 1 with TemplateBuilder

use of org.wso2.siddhi.core.util.transport.TemplateBuilder 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 TemplateBuilder

use of org.wso2.siddhi.core.util.transport.TemplateBuilder in project carbon-apimgt by wso2.

the class ThrottleTemplateBuilderTestCase method testSiddhiQueryForAPIPolicy.

@Test
public void testSiddhiQueryForAPIPolicy() throws APITemplateException {
    APIPolicy apiPolicy = SampleTestObjectCreator.createDefaultAPIPolicy();
    APIThrottlePolicyTemplateBuilder templateBuilder = new APIThrottlePolicyTemplateBuilder(apiPolicy);
    Map<String, String> siddhiQueryMap = templateBuilder.getThrottlePolicyTemplateForPipelines();
    String actualQuery = siddhiQueryMap.get("resource_SampleAPIPolicy_condition_0");
    String expectedQuery = SampleTestObjectCreator.createDefaultSiddhiAppForAPIThrottlePolicy();
    Assert.assertEquals(actualQuery, expectedQuery);
}
Also used : APIPolicy(org.wso2.carbon.apimgt.core.models.policy.APIPolicy) Test(org.testng.annotations.Test)

Example 3 with TemplateBuilder

use of org.wso2.siddhi.core.util.transport.TemplateBuilder 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 4 with TemplateBuilder

use of org.wso2.siddhi.core.util.transport.TemplateBuilder 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);
}
Also used : CustomPolicy(org.wso2.carbon.apimgt.core.models.policy.CustomPolicy) Test(org.testng.annotations.Test)

Example 5 with TemplateBuilder

use of org.wso2.siddhi.core.util.transport.TemplateBuilder in project carbon-apimgt by wso2.

the class ThrottleTemplateBuilderTestCase method testSiddhiQueryForAPILevelDefaultConditions.

@Test
public void testSiddhiQueryForAPILevelDefaultConditions() throws APITemplateException {
    APIPolicy apiPolicy = SampleTestObjectCreator.createDefaultAPIPolicy();
    APIThrottlePolicyTemplateBuilder templateBuilder = new APIThrottlePolicyTemplateBuilder(apiPolicy);
    String actualQuery = templateBuilder.getThrottlePolicyTemplateForAPILevelDefaultCondition();
    String expectedQuery = SampleTestObjectCreator.createDefaultSiddhiAppForAPILevelDefaultThrottlePolicy();
    Assert.assertEquals(actualQuery, expectedQuery);
}
Also used : APIPolicy(org.wso2.carbon.apimgt.core.models.policy.APIPolicy) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)5 HashMap (java.util.HashMap)4 APIPolicy (org.wso2.carbon.apimgt.core.models.policy.APIPolicy)3 ApplicationPolicy (org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)2 CustomPolicy (org.wso2.carbon.apimgt.core.models.policy.CustomPolicy)2 SubscriptionPolicy (org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 APIThrottlePolicyTemplateBuilder (org.wso2.carbon.apimgt.core.template.APIThrottlePolicyTemplateBuilder)1 ApplicationThrottlePolicyTemplateBuilder (org.wso2.carbon.apimgt.core.template.ApplicationThrottlePolicyTemplateBuilder)1 CustomThrottlePolicyTemplateBuilder (org.wso2.carbon.apimgt.core.template.CustomThrottlePolicyTemplateBuilder)1 SubscriptionThrottlePolicyTemplateBuilder (org.wso2.carbon.apimgt.core.template.SubscriptionThrottlePolicyTemplateBuilder)1 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)1 TemplateBuilder (org.wso2.siddhi.core.util.transport.TemplateBuilder)1 Element (org.wso2.siddhi.query.api.annotation.Element)1