Search in sources :

Example 16 with ThrottleConditionDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ThrottleConditionDTO in project carbon-apimgt by wso2.

the class CommonThrottleMappingUtilTestCase method fromSpecificIPConditionDtoToIPConditionModelTest.

@Test(description = "Convert IP specific IPCondition DTO to IPCondition Model object")
public void fromSpecificIPConditionDtoToIPConditionModelTest() throws Exception {
    ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
    throttleConditionDTO.setType(PolicyConstants.IP_CONDITION_TYPE);
    IPConditionDTO ipConditionDTO = new IPConditionDTO();
    ipConditionDTO.setIpConditionType(PolicyConstants.IP_SPECIFIC_TYPE);
    ipConditionDTO.setSpecificIP("10.100.0.168");
    throttleConditionDTO.setIpCondition(ipConditionDTO);
    IPCondition condition = (IPCondition) CommonThrottleMappingUtil.fromDTOToCondition(throttleConditionDTO);
    Assert.assertNotNull(condition);
    Assert.assertNotNull(condition.getCondition());
    assertEquals(condition.getSpecificIP(), "10.100.0.168");
}
Also used : IPCondition(org.wso2.carbon.apimgt.core.models.policy.IPCondition) Test(org.testng.annotations.Test)

Example 17 with ThrottleConditionDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ThrottleConditionDTO in project carbon-apimgt by wso2.

the class CommonThrottleMappingUtil method fromPipelineToConditionalGroupDTO.

/**
 * Converts a single Pipeline object into a Conditional Group DTO object
 *
 * @param pipeline Pipeline object
 * @return Derived DTO object from Pipeline object
 * @throws UnsupportedThrottleLimitTypeException
 * @throws UnsupportedThrottleConditionTypeException
 */
public static ConditionalGroupDTO fromPipelineToConditionalGroupDTO(Pipeline pipeline) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
    ConditionalGroupDTO groupDTO = new ConditionalGroupDTO();
    groupDTO.setDescription(pipeline.getDescription());
    groupDTO.setLimit(fromQuotaPolicyToDTO(pipeline.getQuotaPolicy()));
    List<ThrottleConditionDTO> conditionDTOList = fromConditionListToDTOList(pipeline.getConditions());
    groupDTO.setConditions(conditionDTOList);
    return groupDTO;
}
Also used : ConditionalGroupDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ConditionalGroupDTO) ThrottleConditionDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ThrottleConditionDTO)

Aggregations

Test (org.testng.annotations.Test)5 ThrottleConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO)5 IPCondition (org.wso2.carbon.apimgt.core.models.policy.IPCondition)3 ThrottleConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ThrottleConditionDTO)3 UnsupportedThrottleConditionTypeException (org.wso2.carbon.apimgt.api.UnsupportedThrottleConditionTypeException)2 HeaderCondition (org.wso2.carbon.apimgt.api.model.policy.HeaderCondition)2 IPCondition (org.wso2.carbon.apimgt.api.model.policy.IPCondition)2 JWTClaimsCondition (org.wso2.carbon.apimgt.api.model.policy.JWTClaimsCondition)2 QueryParameterCondition (org.wso2.carbon.apimgt.api.model.policy.QueryParameterCondition)2 HeaderCondition (org.wso2.carbon.apimgt.core.models.policy.HeaderCondition)2 JWTClaimsCondition (org.wso2.carbon.apimgt.core.models.policy.JWTClaimsCondition)2 QueryParameterCondition (org.wso2.carbon.apimgt.core.models.policy.QueryParameterCondition)2 ArrayList (java.util.ArrayList)1 Condition (org.wso2.carbon.apimgt.api.model.policy.Condition)1 ConditionalGroupDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ConditionalGroupDTO)1 HeaderConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.HeaderConditionDTO)1 IPConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.IPConditionDTO)1 JWTClaimsConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.JWTClaimsConditionDTO)1 QueryParameterConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.QueryParameterConditionDTO)1 ConditionalGroupDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ConditionalGroupDTO)1