use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.QueryParameterConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromQueryParameterConditionToDTO.
/**
* Converts a Query Parameter Condition model object into a DTO
*
* @param condition Query Parameter Condition model object
* @return DTO object that was derived from Query Parameter Condition model object
*/
public static ThrottleConditionDTO fromQueryParameterConditionToDTO(QueryParameterCondition condition) {
ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
throttleConditionDTO.setType(PolicyConstants.QUERY_PARAMS_CONDITION_TYPE);
throttleConditionDTO.setQueryParameterCondition(new QueryParameterConditionDTO());
throttleConditionDTO = updateFieldsFromConditionToDTO(condition, throttleConditionDTO);
throttleConditionDTO.getQueryParameterCondition().setParameterName(condition.getParameter());
throttleConditionDTO.getQueryParameterCondition().setParameterValue(condition.getValue());
return throttleConditionDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.QueryParameterConditionDTO 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.v1.dto.QueryParameterConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromDTOToQueryParameterCondition.
/**
* Converts a Query Parameter Condition DTO object into a model object
*
* @param dto Query Parameter Condition DTO object
* @param invertCondition Invert condition relevant to the DTO
* @return Query Parameter Condition model object derived from Query Parameter Condition DTO
*/
public static QueryParameterCondition fromDTOToQueryParameterCondition(QueryParameterConditionDTO dto, boolean invertCondition) {
QueryParameterCondition queryParameterCondition = new QueryParameterCondition();
queryParameterCondition.setConditionEnabled(Boolean.TRUE.toString());
queryParameterCondition.setInvertCondition(invertCondition);
queryParameterCondition.setParameter(dto.getParameterName());
queryParameterCondition.setValue(dto.getParameterValue());
return queryParameterCondition;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.QueryParameterConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromQueryParameterConditionToDTO.
/**
* Converts a Query Parameter Condition model object into a DTO
*
* @param condition Query Parameter Condition model object
* @return DTO object that was derived from Query Parameter Condition model object
*/
public static QueryParameterConditionDTO fromQueryParameterConditionToDTO(QueryParameterCondition condition) {
QueryParameterConditionDTO dto = new QueryParameterConditionDTO();
dto.setParameterName(condition.getParameter());
dto.setParameterValue(condition.getValue());
return dto;
}
Aggregations