Search in sources :

Example 1 with QueryParameterConditionDTO

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

Example 3 with QueryParameterConditionDTO

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;
}
Also used : QueryParameterCondition(org.wso2.carbon.apimgt.api.model.policy.QueryParameterCondition)

Example 4 with QueryParameterConditionDTO

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

Aggregations

Test (org.testng.annotations.Test)1 QueryParameterCondition (org.wso2.carbon.apimgt.api.model.policy.QueryParameterCondition)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 QueryParameterConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.QueryParameterConditionDTO)1