use of org.wso2.carbon.apimgt.internal.service.dto.BandwidthLimitDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromBandwidthLimitToDTO.
/**
* Converts a Bandwidth Limit model object into a Bandwidth Limit DTO object
*
* @param bandwidthLimit Bandwidth Limit model object
* @return Bandwidth Limit DTO object derived from model
*/
public static ThrottleLimitDTO fromBandwidthLimitToDTO(BandwidthLimit bandwidthLimit) {
// done
ThrottleLimitDTO dto = new ThrottleLimitDTO();
dto = updateFieldsFromLimitToDTO(bandwidthLimit, dto);
dto.setType(PolicyConstants.BANDWIDTH_LIMIT_TYPE);
dto.setBandwidthLimit(new BandwidthLimitDTO());
dto.getBandwidthLimit().setDataAmount(bandwidthLimit.getDataAmount());
dto.getBandwidthLimit().setDataUnit(bandwidthLimit.getDataUnit());
return dto;
}
use of org.wso2.carbon.apimgt.internal.service.dto.BandwidthLimitDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtilTestCase method fromBandwidthThrottleLimitDtoToQuotaPolicyTest.
@Test(description = "Convert Bandwidth Throttle Limit DTO to Quota Policy")
public void fromBandwidthThrottleLimitDtoToQuotaPolicyTest() throws Exception {
ThrottleLimitDTO throttleLimitDTO = new ThrottleLimitDTO();
throttleLimitDTO.setType(PolicyConstants.BANDWIDTH_LIMIT_TYPE);
BandwidthLimitDTO bandwidthLimitDTO = new BandwidthLimitDTO();
bandwidthLimitDTO.setDataAmount(10);
bandwidthLimitDTO.setDataUnit(KB);
throttleLimitDTO.setBandwidthLimit(bandwidthLimitDTO);
throttleLimitDTO.setTimeUnit("min");
throttleLimitDTO.setUnitTime(1);
QuotaPolicy policy = CommonThrottleMappingUtil.fromDTOToQuotaPolicy(throttleLimitDTO);
Assert.assertNotNull(policy);
assertEquals(policy.getType(), PolicyConstants.BANDWIDTH_TYPE);
BandwidthLimit bandwidthLimit = (BandwidthLimit) policy.getLimit();
assertEquals(bandwidthLimit.getDataAmount(), 10);
assertEquals(bandwidthLimit.getDataUnit(), KB);
assertEquals(bandwidthLimit.getTimeUnit(), "min");
assertEquals(bandwidthLimit.getUnitTime(), 1);
}
use of org.wso2.carbon.apimgt.internal.service.dto.BandwidthLimitDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromBandwidthLimitToDTO.
/**
* Converts a Bandwidth Limit model object into a Bandwidth Limit DTO object
*
* @param bandwidthLimit Bandwidth Limit model object
* @return Bandwidth Limit DTO object derived from model
*/
public static BandwidthLimitDTO fromBandwidthLimitToDTO(BandwidthLimit bandwidthLimit) {
// done
BandwidthLimitDTO dto = new BandwidthLimitDTO();
dto.setTimeUnit(bandwidthLimit.getTimeUnit());
dto.setUnitTime(bandwidthLimit.getUnitTime());
dto.setDataAmount(bandwidthLimit.getDataAmount());
dto.setDataUnit(bandwidthLimit.getDataUnit());
return dto;
}
use of org.wso2.carbon.apimgt.internal.service.dto.BandwidthLimitDTO in project carbon-apimgt by wso2.
the class SubscriptionValidationDataUtil method fromBandwidthLimitToDTO.
/**
* Converts a Bandwidth Limit model object into a Bandwidth Limit DTO object.
*
* @param bandwidthLimit Bandwidth Limit model object
* @return Bandwidth Limit DTO object derived from model
*/
private static BandwidthLimitDTO fromBandwidthLimitToDTO(BandwidthLimit bandwidthLimit) {
BandwidthLimitDTO dto = new BandwidthLimitDTO();
dto.setTimeUnit(bandwidthLimit.getTimeUnit());
dto.setUnitTime(bandwidthLimit.getUnitTime());
dto.setDataAmount(bandwidthLimit.getDataAmount());
dto.setDataUnit(bandwidthLimit.getDataUnit());
return dto;
}
use of org.wso2.carbon.apimgt.internal.service.dto.BandwidthLimitDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromDTOToBandwidthLimit.
/**
* Converts a Bandwidth Limit DTO object into a Bandwidth Limit model object
*
* @param dto Bandwidth Limit DTO object
* @return Bandwidth Limit model object derived from DTO
*/
public static BandwidthLimit fromDTOToBandwidthLimit(BandwidthLimitDTO dto) {
BandwidthLimit bandwidthLimit = new BandwidthLimit();
bandwidthLimit.setTimeUnit(dto.getTimeUnit());
bandwidthLimit.setUnitTime(dto.getUnitTime());
bandwidthLimit.setDataAmount(dto.getDataAmount());
bandwidthLimit.setDataUnit(dto.getDataUnit());
return bandwidthLimit;
}
Aggregations