use of com.alibaba.cloud.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean in project spring-cloud-alibaba by alibaba.
the class ApolloDataSourceFactoryBeanTests method testApolloFactoryBean.
@Test
public void testApolloFactoryBean() throws Exception {
ApolloDataSourceFactoryBean factoryBean = spy(new ApolloDataSourceFactoryBean());
Converter converter = mock(JsonConverter.class);
factoryBean.setDefaultFlowRuleValue(defaultFlowValue);
factoryBean.setFlowRulesKey(flowRuleKey);
factoryBean.setNamespaceName(namespace);
factoryBean.setConverter(converter);
ApolloDataSource apolloDataSource = mock(ApolloDataSource.class);
when(apolloDataSource.readSource()).thenReturn("{}");
doReturn(apolloDataSource).when(factoryBean).getObject();
assertThat(factoryBean.getObject()).isEqualTo(apolloDataSource);
assertThat(factoryBean.getObject().readSource()).isEqualTo("{}");
assertThat(factoryBean.getConverter()).isEqualTo(converter);
assertThat(factoryBean.getFlowRulesKey()).isEqualTo(flowRuleKey);
assertThat(factoryBean.getNamespaceName()).isEqualTo(namespace);
assertThat(factoryBean.getDefaultFlowRuleValue()).isEqualTo(defaultFlowValue);
}
Aggregations