use of com.alibaba.cloud.sentinel.datasource.converter.JsonConverter in project spring-cloud-alibaba by alibaba.
the class SentinelConverterTests method testConverterEmptyContent.
@Test
public void testConverterEmptyContent() {
JsonConverter jsonConverter = new JsonConverter(objectMapper, FlowRule.class);
List<FlowRule> flowRules = (List<FlowRule>) jsonConverter.convert("");
assertThat(flowRules.size()).isEqualTo(0);
}
use of com.alibaba.cloud.sentinel.datasource.converter.JsonConverter in project spring-cloud-alibaba by alibaba.
the class SentinelConverterTests method testJsonConverter.
@Test
public void testJsonConverter() {
JsonConverter jsonConverter = new JsonConverter(objectMapper, FlowRule.class);
List<FlowRule> flowRules = (List<FlowRule>) jsonConverter.convert(readFileContent("classpath: flowrule.json"));
assertThat(flowRules.size()).isEqualTo(1);
assertThat(flowRules.get(0).getResource()).isEqualTo("resource");
assertThat(flowRules.get(0).getLimitApp()).isEqualTo("default");
assertThat(String.valueOf(flowRules.get(0).getCount())).isEqualTo("1.0");
assertThat(flowRules.get(0).getControlBehavior()).isEqualTo(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
assertThat(flowRules.get(0).getStrategy()).isEqualTo(RuleConstant.STRATEGY_DIRECT);
assertThat(flowRules.get(0).getGrade()).isEqualTo(RuleConstant.FLOW_GRADE_QPS);
}
use of com.alibaba.cloud.sentinel.datasource.converter.JsonConverter in project spring-cloud-alibaba by alibaba.
the class SentinelConverterTests method testConverterErrorContent.
@Test(expected = RuntimeException.class)
public void testConverterErrorContent() {
JsonConverter jsonConverter = new JsonConverter(objectMapper, FlowRule.class);
jsonConverter.convert(readFileContent("classpath: flowrule-errorcontent.json"));
}
use of com.alibaba.cloud.sentinel.datasource.converter.JsonConverter in project spring-cloud-alibaba by alibaba.
the class SentinelConverterTests method testConverterErrorFormat.
@Test(expected = RuntimeException.class)
public void testConverterErrorFormat() {
JsonConverter jsonConverter = new JsonConverter(objectMapper, FlowRule.class);
jsonConverter.convert(readFileContent("classpath: flowrule-errorformat.json"));
}
Aggregations