Search in sources :

Example 1 with TimeoutConfigBean

use of io.apiman.plugins.timeoutpolicy.beans.TimeoutConfigBean in project apiman-plugins by apiman.

the class TimeoutPolicyTest method shouldReturnConfigBeanWithValue_onParseConfiguration.

/**
 * Control the parse system for the configuration
 */
@Test
@Configuration("{\"timeoutConnect\" : \"1\", \"timeoutRead\" : \"2\" }")
public void shouldReturnConfigBeanWithValue_onParseConfiguration() throws PolicyFailureError, Throwable {
    Configuration config = this.getClass().getMethod("shouldReturnConfigBeanWithValue_onParseConfiguration").getAnnotation(Configuration.class);
    // WHEN parse the configuration
    TimeoutConfigBean policyConfigBean = timeoutPolicy.parseConfiguration(config.value());
    // THEN the bean's value equals the test config
    HashMap<?, ?> configMap = new ObjectMapper().readValue(config.value(), HashMap.class);
    assertEquals(configMap.get("timeoutConnect"), policyConfigBean.getTimeoutConnect());
    assertEquals(configMap.get("timeoutRead"), policyConfigBean.getTimeoutRead());
}
Also used : Configuration(io.apiman.test.policies.Configuration) TimeoutConfigBean(io.apiman.plugins.timeoutpolicy.beans.TimeoutConfigBean) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Configuration(io.apiman.test.policies.Configuration) Test(org.junit.Test) ApimanPolicyTest(io.apiman.test.policies.ApimanPolicyTest)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 TimeoutConfigBean (io.apiman.plugins.timeoutpolicy.beans.TimeoutConfigBean)1 ApimanPolicyTest (io.apiman.test.policies.ApimanPolicyTest)1 Configuration (io.apiman.test.policies.Configuration)1 Test (org.junit.Test)1