Java Code Examples for org.wso2.carbon.apimgt.impl.APIConstants#DEFAULT_APP_POLICY_TWENTY_REQ_PER_MIN
The following examples show how to use
org.wso2.carbon.apimgt.impl.APIConstants#DEFAULT_APP_POLICY_TWENTY_REQ_PER_MIN .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: APIUtilTierTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testAddDefaultSuperTenantAdvancedThrottlePoliciesAppLevel() throws Exception { ApiMgtDAOMockCreator daoMockHolder = new ApiMgtDAOMockCreator(1); ApiMgtDAO apiMgtDAO = daoMockHolder.getMock(); String[] appPolicies = new String[]{APIConstants.DEFAULT_APP_POLICY_FIFTY_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_TWENTY_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_TEN_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_UNLIMITED}; for (String policy : appPolicies) { Mockito.when( apiMgtDAO.isPolicyExist(eq(PolicyConstants.POLICY_LEVEL_APP), eq(MultitenantConstants.SUPER_TENANT_ID), eq(policy))).thenReturn(false); } try { APIUtil.addDefaultSuperTenantAdvancedThrottlePolicies(); Mockito.verify(apiMgtDAO, Mockito.times(appPolicies.length)).addApplicationPolicy(Mockito.any(ApplicationPolicy.class)); } catch (APIManagementException e) { Assert.assertTrue("Exception thrown", false); } }
Example 2
Source File: APIUtilTierTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testAddDefaultSuperTenantAdvancedThrottlePoliciesAppLevelAlreadyAdded() throws Exception { ApiMgtDAOMockCreator daoMockHolder = new ApiMgtDAOMockCreator(1); ApiMgtDAO apiMgtDAO = daoMockHolder.getMock(); String[] appPolicies = new String[]{APIConstants.DEFAULT_APP_POLICY_FIFTY_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_TWENTY_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_TEN_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_UNLIMITED}; // If policy added already for (String policy : appPolicies) { Mockito.when( apiMgtDAO.isPolicyExist(eq(PolicyConstants.POLICY_LEVEL_APP), eq(MultitenantConstants.SUPER_TENANT_ID), eq(policy))).thenReturn(true); } try { APIUtil.addDefaultSuperTenantAdvancedThrottlePolicies(); Mockito.verify(apiMgtDAO, Mockito.never()).addApplicationPolicy(Mockito.any(ApplicationPolicy.class)); } catch (APIManagementException e) { Assert.assertTrue("Exception thrown", false); } }
Example 3
Source File: APIUtilTierTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testAddDefaultTenantAdvancedThrottlePoliciesAppLevel() throws Exception { int tenantId = 1; String tenantDomain = "test.com"; ApiMgtDAOMockCreator daoMockHolder = new ApiMgtDAOMockCreator(tenantId); ApiMgtDAO apiMgtDAO = daoMockHolder.getMock(); ThrottlePolicyTemplateBuilder templateBuilder = Mockito.mock(ThrottlePolicyTemplateBuilder.class); PowerMockito.whenNew(ThrottlePolicyTemplateBuilder.class).withNoArguments().thenReturn(templateBuilder); String[] appPolicies = new String[]{APIConstants.DEFAULT_APP_POLICY_FIFTY_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_TWENTY_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_TEN_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_UNLIMITED}; for (String policy : appPolicies) { Mockito.when( apiMgtDAO.isPolicyExist(eq(PolicyConstants.POLICY_LEVEL_APP), eq(tenantId), eq(policy))).thenReturn(false); Mockito.when( apiMgtDAO.isPolicyDeployed(eq(PolicyConstants.POLICY_LEVEL_APP), eq(tenantId), eq(policy))).thenReturn(false); } APIUtil.addDefaultTenantAdvancedThrottlePolicies(tenantDomain, tenantId); Mockito.verify(apiMgtDAO, Mockito.times(appPolicies.length)). addApplicationPolicy(Mockito.any(ApplicationPolicy.class)); Mockito.verify(apiMgtDAO, Mockito.times(appPolicies.length)). setPolicyDeploymentStatus(eq(PolicyConstants.POLICY_LEVEL_APP), Mockito.anyString(), eq(tenantId), eq(true)); }
Example 4
Source File: APIUtilTierTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testAddDefaultTenantAdvancedThrottlePoliciesAppLevelAlreadyAdded() throws Exception { int tenantId = 1; String tenantDomain = "test.com"; ApiMgtDAOMockCreator daoMockHolder = new ApiMgtDAOMockCreator(tenantId); ApiMgtDAO apiMgtDAO = daoMockHolder.getMock(); ThrottlePolicyTemplateBuilder templateBuilder = Mockito.mock(ThrottlePolicyTemplateBuilder.class); PowerMockito.whenNew(ThrottlePolicyTemplateBuilder.class).withNoArguments().thenReturn(templateBuilder); String[] appPolicies = new String[]{APIConstants.DEFAULT_APP_POLICY_FIFTY_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_TWENTY_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_TEN_REQ_PER_MIN, APIConstants.DEFAULT_APP_POLICY_UNLIMITED}; for (String policy : appPolicies) { Mockito.when( apiMgtDAO.isPolicyExist(eq(PolicyConstants.POLICY_LEVEL_APP), eq(tenantId), eq(policy))).thenReturn(true); Mockito.when( apiMgtDAO.isPolicyDeployed(eq(PolicyConstants.POLICY_LEVEL_APP), eq(tenantId), eq(policy))).thenReturn(true); } APIUtil.addDefaultTenantAdvancedThrottlePolicies(tenantDomain, tenantId); Mockito.verify(apiMgtDAO, Mockito.never()). addApplicationPolicy(Mockito.any(ApplicationPolicy.class)); Mockito.verify(apiMgtDAO, Mockito.never()). setPolicyDeploymentStatus(eq(PolicyConstants.POLICY_LEVEL_APP), Mockito.anyString(), eq(tenantId), eq(true)); }