Search in sources :

Example 1 with HeaderConditionDTO

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

Example 2 with HeaderConditionDTO

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

Example 3 with HeaderConditionDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.HeaderConditionDTO 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 HeaderConditionDTO fromHeaderConditionToDTO(HeaderCondition headerCondition) {
    HeaderConditionDTO dto = new HeaderConditionDTO();
    dto.setHeaderName(headerCondition.getHeaderName());
    dto.setHeaderValue(headerCondition.getValue());
    return dto;
}
Also used : HeaderConditionDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.HeaderConditionDTO)

Example 4 with HeaderConditionDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.HeaderConditionDTO in project carbon-apimgt by wso2.

the class CommonThrottleMappingUtil method fromDTOToHeaderCondition.

/**
 * Converts a Header Condition DTO object into a model object
 *
 * @param dto             Header Condition DTO object
 * @param invertCondition Invert condition relevant to the DTO
 * @return Header Condition model object derived from Header Condition DTO
 */
public static HeaderCondition fromDTOToHeaderCondition(HeaderConditionDTO dto, boolean invertCondition) {
    HeaderCondition headerCondition = new HeaderCondition();
    headerCondition.setConditionEnabled(Boolean.TRUE.toString());
    headerCondition.setInvertCondition(invertCondition);
    headerCondition.setHeader(dto.getHeaderName());
    headerCondition.setValue(dto.getHeaderValue());
    return headerCondition;
}
Also used : HeaderCondition(org.wso2.carbon.apimgt.api.model.policy.HeaderCondition)

Aggregations

Test (org.testng.annotations.Test)1 HeaderCondition (org.wso2.carbon.apimgt.api.model.policy.HeaderCondition)1 HeaderCondition (org.wso2.carbon.apimgt.core.models.policy.HeaderCondition)1 HeaderConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.HeaderConditionDTO)1 ThrottleConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO)1 HeaderConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.HeaderConditionDTO)1