use of org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromHeaderConditionToDTO.
/**
* Converts a Header Condition model object into a DTO
*
* @param headerCondition Header Condition model object
* @return DTO object that was derived from Header Condition model object
*/
public static ThrottleConditionDTO fromHeaderConditionToDTO(HeaderCondition headerCondition) {
ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
throttleConditionDTO.setType(PolicyConstants.HEADER_CONDITION_TYPE);
throttleConditionDTO.setHeaderCondition(new HeaderConditionDTO());
throttleConditionDTO = updateFieldsFromConditionToDTO(headerCondition, throttleConditionDTO);
throttleConditionDTO.getHeaderCondition().setHeaderName(headerCondition.getHeaderName());
throttleConditionDTO.getHeaderCondition().setHeaderValue(headerCondition.getValue());
return throttleConditionDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtilTestCase method fromQueryParamsConditionDtoToQueryParamsConditionModelTest.
@Test(description = "Convert Query param Condition DTO to QueryParamCondition Model object")
public void fromQueryParamsConditionDtoToQueryParamsConditionModelTest() throws Exception {
ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
throttleConditionDTO.setType(PolicyConstants.QUERY_PARAMS_CONDITION_TYPE);
QueryParameterConditionDTO queryParameterConditionDTO = new QueryParameterConditionDTO();
queryParameterConditionDTO.setParameterName("testParam");
queryParameterConditionDTO.setParameterValue("testParamValue");
throttleConditionDTO.setQueryParameterCondition(queryParameterConditionDTO);
QueryParameterCondition condition = (QueryParameterCondition) CommonThrottleMappingUtil.fromDTOToCondition(throttleConditionDTO);
Assert.assertNotNull(condition);
assertEquals(condition.getParameter(), "testParam");
assertEquals(condition.getValue(), "testParamValue");
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtilTestCase method fromHeaderConditionDtoToHeaderConditionModelTest.
@Test(description = "Convert Header Condition DTO to HeaderCondition Model object")
public void fromHeaderConditionDtoToHeaderConditionModelTest() throws Exception {
ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
throttleConditionDTO.setType(PolicyConstants.HEADER_CONDITION_TYPE);
HeaderConditionDTO headerConditionDTO = new HeaderConditionDTO();
headerConditionDTO.setHeaderName("testHeader");
headerConditionDTO.setHeaderValue("testHeaderValue");
throttleConditionDTO.setHeaderCondition(headerConditionDTO);
HeaderCondition condition = (HeaderCondition) CommonThrottleMappingUtil.fromDTOToCondition(throttleConditionDTO);
Assert.assertNotNull(condition);
assertEquals(condition.getHeaderName(), "testHeader");
assertEquals(condition.getValue(), "testHeaderValue");
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtilTestCase method fromIPRangeConditionDtoToIPConditionModelTest.
@Test(description = "Convert IP range IPCondition DTO to IPCondition Model object")
public void fromIPRangeConditionDtoToIPConditionModelTest() throws Exception {
ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
throttleConditionDTO.setType(PolicyConstants.IP_CONDITION_TYPE);
IPConditionDTO ipConditionDTO = new IPConditionDTO();
ipConditionDTO.setIpConditionType(IP_RANGE_TYPE);
ipConditionDTO.setStartingIP("10.100.0.158");
ipConditionDTO.setEndingIP("10.100.0.178");
throttleConditionDTO.setIpCondition(ipConditionDTO);
IPCondition condition = (IPCondition) CommonThrottleMappingUtil.fromDTOToCondition(throttleConditionDTO);
Assert.assertNotNull(condition);
assertEquals(condition.getStartingIP(), "10.100.0.158");
assertEquals(condition.getEndingIP(), "10.100.0.178");
assertEquals(condition.getType(), IP_RANGE_TYPE);
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromJWTClaimsConditionToDTO.
/**
* Converts a JWT Claims Condition model object into a DTO
*
* @param condition JWT Claims Condition model object
* @return DTO object that was derived from JWT Claims Condition model object
*/
public static ThrottleConditionDTO fromJWTClaimsConditionToDTO(JWTClaimsCondition condition) {
ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
throttleConditionDTO.setType(PolicyConstants.JWT_CLAIMS_CONDITION_TYPE);
throttleConditionDTO.setJwtClaimsCondition(new JWTClaimsConditionDTO());
throttleConditionDTO = updateFieldsFromConditionToDTO(condition, throttleConditionDTO);
throttleConditionDTO.getJwtClaimsCondition().setClaimUrl(condition.getClaimUrl());
throttleConditionDTO.getJwtClaimsCondition().setAttribute(condition.getAttribute());
return throttleConditionDTO;
}
Aggregations