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;
}
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");
}
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;
}
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;
}
Aggregations