Search in sources :

Example 1 with QueryParameterConditionDTO

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

Example 2 with QueryParameterConditionDTO

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

Aggregations

Test (org.testng.annotations.Test)1 QueryParameterCondition (org.wso2.carbon.apimgt.core.models.policy.QueryParameterCondition)1 QueryParameterConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.QueryParameterConditionDTO)1 ThrottleConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO)1