use of org.wso2.carbon.apimgt.core.models.events.PolicyEvent in project carbon-apimgt by wso2.
the class PolicyUtilTest method testAddPolicy_SubType.
@Test
public void testAddPolicy_SubType() throws ExecutionPlanConfigurationException, ExecutionPlanDependencyValidationException {
ExecutionPlanConfigurationException executionPlanConfigurationException = Mockito.mock(ExecutionPlanConfigurationException.class);
Mockito.when(eventProcessorService.getActiveExecutionPlan(Mockito.anyString())).thenThrow(executionPlanConfigurationException);
SubscriptionPolicy policy = TestUtil.getPolicySubLevel();
SubscriptionPolicyEvent policyEvent = new SubscriptionPolicyEvent(UUID.randomUUID().toString(), System.currentTimeMillis(), APIConstants.EventType.POLICY_CREATE.name(), -1234, policy.getTenantDomain(), policy.getId(), policy.getName(), policy.getDefaultLimit().getQuotaType(), policy.getRateLimitCount(), policy.getRateLimitTimeUnit(), policy.isStopOnQuotaReach(), policy.getGraphQLMaxDepth(), policy.getGraphQLMaxComplexity(), policy.getSubscriberCount());
PolicyUtil.deployPolicy(policy, policyEvent);
Mockito.verify(eventProcessorService, Mockito.times(1)).deployExecutionPlan(Mockito.anyString());
}
use of org.wso2.carbon.apimgt.core.models.events.PolicyEvent in project carbon-apimgt by wso2.
the class PolicyUtilTest method testAddPolicy_APIType.
@Test
public void testAddPolicy_APIType() throws ExecutionPlanConfigurationException, ExecutionPlanDependencyValidationException {
ExecutionPlanConfigurationException executionPlanConfigurationException = Mockito.mock(ExecutionPlanConfigurationException.class);
Mockito.when(eventProcessorService.getActiveExecutionPlan(Mockito.anyString())).thenThrow(executionPlanConfigurationException);
ApiPolicy policy = TestUtil.getPolicyAPILevel();
APIPolicyEvent policyEvent = new APIPolicyEvent(UUID.randomUUID().toString(), System.currentTimeMillis(), APIConstants.EventType.POLICY_CREATE.name(), -1234, policy.getTenantDomain(), policy.getId(), policy.getName(), policy.getDefaultLimit().getQuotaType(), null, null);
PolicyUtil.deployPolicy(policy, policyEvent);
Mockito.verify(eventProcessorService, Mockito.times(2)).deployExecutionPlan(Mockito.anyString());
}
use of org.wso2.carbon.apimgt.core.models.events.PolicyEvent 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());
}
Aggregations