use of org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromDTOToJWTClaimsCondition.
/**
* Converts a JWT Claims Condition DTO object into a model object
*
* @param dto JWT Claims Condition DTO object
* @return JWT Claims Condition model object derived from JWT Claims Condition DTO
*/
public static JWTClaimsCondition fromDTOToJWTClaimsCondition(ThrottleConditionDTO dto) {
JWTClaimsCondition jwtClaimsCondition = new JWTClaimsCondition();
jwtClaimsCondition = updateFieldsFromDTOToCondition(dto, jwtClaimsCondition);
jwtClaimsCondition.setAttribute(dto.getJwtClaimsCondition().getAttribute());
jwtClaimsCondition.setClaimUrl(dto.getJwtClaimsCondition().getClaimUrl());
return jwtClaimsCondition;
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromIPConditionToDTO.
/**
* Converts an IP Condition model object into a DTO
*
* @param ipCondition IP Condition model object
* @return DTO object derived from model object
*/
public static ThrottleConditionDTO fromIPConditionToDTO(IPCondition ipCondition) throws UnsupportedThrottleConditionTypeException {
String ipConditionType = mapIPConditionTypeFromModelToDTO(ipCondition.getType());
ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
throttleConditionDTO.setType(PolicyConstants.IP_CONDITION_TYPE);
throttleConditionDTO.setIpCondition(new IPConditionDTO());
throttleConditionDTO = updateFieldsFromConditionToDTO(ipCondition, throttleConditionDTO);
throttleConditionDTO.getIpCondition().setIpConditionType(ipConditionType);
throttleConditionDTO.getIpCondition().setSpecificIP(ipCondition.getSpecificIP());
throttleConditionDTO.getIpCondition().setStartingIP(ipCondition.getStartingIP());
throttleConditionDTO.getIpCondition().setEndingIP(ipCondition.getEndingIP());
return throttleConditionDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtilTestCase method fromJWTConditionDtoToJWTConditionModelTest.
@Test(description = "Convert JWT Condition DTO to JWTCondition Model object")
public void fromJWTConditionDtoToJWTConditionModelTest() throws Exception {
ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
throttleConditionDTO.setType(PolicyConstants.JWT_CLAIMS_CONDITION_TYPE);
JWTClaimsConditionDTO jwtClaimsConditionDTO = new JWTClaimsConditionDTO();
jwtClaimsConditionDTO.setAttribute("testAttribute");
jwtClaimsConditionDTO.setClaimUrl("http://wso2.org/claims");
throttleConditionDTO.setJwtClaimsCondition(jwtClaimsConditionDTO);
JWTClaimsCondition condition = (JWTClaimsCondition) CommonThrottleMappingUtil.fromDTOToCondition(throttleConditionDTO);
Assert.assertNotNull(condition);
assertEquals(condition.getAttribute(), "testAttribute");
assertEquals(condition.getClaimUrl(), "http://wso2.org/claims");
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtilTestCase method fromSpecificIPConditionDtoToIPConditionModelTest.
@Test(description = "Convert IP specific IPCondition DTO to IPCondition Model object")
public void fromSpecificIPConditionDtoToIPConditionModelTest() throws Exception {
ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
throttleConditionDTO.setType(PolicyConstants.IP_CONDITION_TYPE);
IPConditionDTO ipConditionDTO = new IPConditionDTO();
ipConditionDTO.setIpConditionType(PolicyConstants.IP_SPECIFIC_TYPE);
ipConditionDTO.setSpecificIP("10.100.0.168");
throttleConditionDTO.setIpCondition(ipConditionDTO);
IPCondition condition = (IPCondition) CommonThrottleMappingUtil.fromDTOToCondition(throttleConditionDTO);
Assert.assertNotNull(condition);
Assert.assertNotNull(condition.getCondition());
assertEquals(condition.getSpecificIP(), "10.100.0.168");
}
Aggregations