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");
}
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;
}
Aggregations