Search in sources :

Example 1 with BandwidthLimitDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.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;
}
Also used : ThrottleLimitDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleLimitDTO) BandwidthLimitDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.BandwidthLimitDTO)

Example 2 with BandwidthLimitDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.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);
}
Also used : QuotaPolicy(org.wso2.carbon.apimgt.core.models.policy.QuotaPolicy) BandwidthLimit(org.wso2.carbon.apimgt.core.models.policy.BandwidthLimit) Test(org.testng.annotations.Test)

Example 3 with BandwidthLimitDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.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;
}
Also used : BandwidthLimitDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BandwidthLimitDTO)

Example 4 with BandwidthLimitDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.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;
}
Also used : BandwidthLimitDTO(org.wso2.carbon.apimgt.internal.service.dto.BandwidthLimitDTO)

Example 5 with BandwidthLimitDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.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;
}
Also used : BandwidthLimit(org.wso2.carbon.apimgt.api.model.policy.BandwidthLimit)

Aggregations

Test (org.testng.annotations.Test)1 BandwidthLimit (org.wso2.carbon.apimgt.api.model.policy.BandwidthLimit)1 BandwidthLimit (org.wso2.carbon.apimgt.core.models.policy.BandwidthLimit)1 QuotaPolicy (org.wso2.carbon.apimgt.core.models.policy.QuotaPolicy)1 BandwidthLimitDTO (org.wso2.carbon.apimgt.internal.service.dto.BandwidthLimitDTO)1 BandwidthLimitDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.BandwidthLimitDTO)1 ThrottleLimitDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleLimitDTO)1 BandwidthLimitDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BandwidthLimitDTO)1