Search in sources :

Example 6 with IPConditionDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.IPConditionDTO 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 7 with IPConditionDTO

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

the class CommonThrottleMappingUtil method fromIPConditionToDTO.

/**
 * Converts an IP Condition model object into a DTO
 *
 * @param ipCondition IP Condition model object
 * @return DTO object derived from model object
 */
public static IPConditionDTO fromIPConditionToDTO(IPCondition ipCondition) {
    IPConditionDTO.IpConditionTypeEnum ipConditionType = mapIPConditionTypeFromModelToDTO(ipCondition.getType());
    IPConditionDTO dto = new IPConditionDTO();
    dto.setIpConditionType(ipConditionType);
    dto.setSpecificIP(ipCondition.getSpecificIP());
    dto.setStartingIP(ipCondition.getStartingIP());
    dto.setEndingIP(ipCondition.getEndingIP());
    return dto;
}
Also used : IPConditionDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.IPConditionDTO)

Aggregations

Test (org.testng.annotations.Test)3 IPConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.IPConditionDTO)3 IPCondition (org.wso2.carbon.apimgt.core.models.policy.IPCondition)2 IPCondition (org.wso2.carbon.apimgt.api.model.policy.IPCondition)1 BlockConditions (org.wso2.carbon.apimgt.core.models.BlockConditions)1 BlockingConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.BlockingConditionDTO)1 ThrottleConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO)1 IPConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.IPConditionDTO)1