Search in sources :

Example 6 with GlobalPolicyEvent

use of org.wso2.carbon.apimgt.impl.notifier.events.GlobalPolicyEvent in project carbon-apimgt by wso2.

the class PolicyUtilTest method testAddPolicy_GlobalType.

@Test
public void testAddPolicy_GlobalType() throws ExecutionPlanConfigurationException, ExecutionPlanDependencyValidationException {
    ExecutionPlanConfigurationException executionPlanConfigurationException = Mockito.mock(ExecutionPlanConfigurationException.class);
    Mockito.when(eventProcessorService.getActiveExecutionPlan(Mockito.anyString())).thenThrow(executionPlanConfigurationException);
    GlobalPolicy policy = TestUtil.getPolicyGlobalLevel();
    GlobalPolicyEvent policyEvent = new GlobalPolicyEvent(UUID.randomUUID().toString(), System.currentTimeMillis(), APIConstants.EventType.POLICY_CREATE.name(), -1234, policy.getTenantDomain(), policy.getId(), policy.getName());
    PolicyUtil.deployPolicy(policy, policyEvent);
    Mockito.verify(eventProcessorService, Mockito.times(1)).deployExecutionPlan(Mockito.anyString());
}
Also used : GlobalPolicy(org.wso2.carbon.apimgt.throttle.policy.deployer.dto.GlobalPolicy) ExecutionPlanConfigurationException(org.wso2.carbon.event.processor.core.exception.ExecutionPlanConfigurationException) GlobalPolicyEvent(org.wso2.carbon.apimgt.impl.notifier.events.GlobalPolicyEvent) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with GlobalPolicyEvent

use of org.wso2.carbon.apimgt.impl.notifier.events.GlobalPolicyEvent in project carbon-apimgt by wso2.

the class PolicyUtilTest method testDeletePolicy_GlobalType.

@Test
public void testDeletePolicy_GlobalType() throws ExecutionPlanConfigurationException {
    GlobalPolicy policy = TestUtil.getPolicyGlobalLevel();
    GlobalPolicyEvent policyEvent = new GlobalPolicyEvent(UUID.randomUUID().toString(), System.currentTimeMillis(), APIConstants.EventType.POLICY_DELETE.name(), -1234, policy.getTenantDomain(), policy.getId(), policy.getName());
    Mockito.when(eventProcessorService.getActiveExecutionPlan(PolicyConstants.POLICY_LEVEL_GLOBAL + "_" + policy.getName())).thenReturn("EXECUTION_PLAN");
    PolicyUtil.undeployPolicy(policyEvent);
    Mockito.verify(eventProcessorService, Mockito.times(1)).undeployActiveExecutionPlan(Mockito.anyString());
}
Also used : GlobalPolicy(org.wso2.carbon.apimgt.throttle.policy.deployer.dto.GlobalPolicy) GlobalPolicyEvent(org.wso2.carbon.apimgt.impl.notifier.events.GlobalPolicyEvent) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

GlobalPolicyEvent (org.wso2.carbon.apimgt.impl.notifier.events.GlobalPolicyEvent)7 APIPolicyEvent (org.wso2.carbon.apimgt.impl.notifier.events.APIPolicyEvent)4 ApplicationPolicyEvent (org.wso2.carbon.apimgt.impl.notifier.events.ApplicationPolicyEvent)4 SubscriptionPolicyEvent (org.wso2.carbon.apimgt.impl.notifier.events.SubscriptionPolicyEvent)4 GlobalPolicy (org.wso2.carbon.apimgt.throttle.policy.deployer.dto.GlobalPolicy)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 APIPolicy (org.wso2.carbon.apimgt.api.model.policy.APIPolicy)3 ApplicationPolicy (org.wso2.carbon.apimgt.api.model.policy.ApplicationPolicy)3 GlobalPolicy (org.wso2.carbon.apimgt.api.model.policy.GlobalPolicy)3 Pipeline (org.wso2.carbon.apimgt.api.model.policy.Pipeline)3 SubscriptionPolicy (org.wso2.carbon.apimgt.api.model.policy.SubscriptionPolicy)3 UnsupportedPolicyTypeException (org.wso2.carbon.apimgt.api.UnsupportedPolicyTypeException)2 Gson (com.google.gson.Gson)1 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 OperationPolicy (org.wso2.carbon.apimgt.api.model.OperationPolicy)1 Condition (org.wso2.carbon.apimgt.api.model.policy.Condition)1 Policy (org.wso2.carbon.apimgt.api.model.policy.Policy)1 PolicyEvent (org.wso2.carbon.apimgt.impl.notifier.events.PolicyEvent)1