Search in sources :

Example 1 with DiscoveryFilter

use of org.apache.servicecomb.registry.discovery.DiscoveryFilter in project java-chassis by ServiceComb.

the class TestDiscoveryTree method discovery_filterReturnNull.

@Test
public void discovery_filterReturnNull(@Mocked InstanceCacheManager instanceCacheManager) {
    new Expectations(DiscoveryManager.class) {

        {
            DiscoveryManager.INSTANCE.getInstanceCacheManager();
            result = instanceCacheManager;
            instanceCacheManager.getOrCreateVersionedCache(anyString, anyString, anyString);
            result = parent;
        }
    };
    DiscoveryFilter filter = new DiscoveryFilter() {

        @Override
        public int getOrder() {
            return 0;
        }

        @Override
        public DiscoveryTreeNode discovery(DiscoveryContext context, DiscoveryTreeNode parent) {
            return null;
        }
    };
    discoveryTree.addFilter(filter);
    expectedException.expect(ServiceCombException.class);
    expectedException.expectMessage(Matchers.is(filter.getClass().getName() + " discovery return null."));
    result = discoveryTree.discovery(context, null, null, null);
}
Also used : Expectations(mockit.Expectations) DiscoveryContext(org.apache.servicecomb.registry.discovery.DiscoveryContext) DiscoveryTreeNode(org.apache.servicecomb.registry.discovery.DiscoveryTreeNode) DiscoveryFilter(org.apache.servicecomb.registry.discovery.DiscoveryFilter) Test(org.junit.Test)

Aggregations

Expectations (mockit.Expectations)1 DiscoveryContext (org.apache.servicecomb.registry.discovery.DiscoveryContext)1 DiscoveryFilter (org.apache.servicecomb.registry.discovery.DiscoveryFilter)1 DiscoveryTreeNode (org.apache.servicecomb.registry.discovery.DiscoveryTreeNode)1 Test (org.junit.Test)1