DubboParser { @Nullable static String service(Invoker<?> invoker) { URL url = invoker.getUrl(); if (url == null) return null; String service = url.getServiceInterface(); return service != null && !service.isEmpty() ? service : null; }    }
@Test public void service() { URL url = URL.valueOf("dubbo: when(invoker.getUrl()).thenReturn(url); assertThat(DubboParser.service(invoker)) .isEqualTo("brave.dubbo.GreeterService"); }
@Test public void service_nullUrl() { assertThat(DubboParser.service(invoker)).isNull(); }
@Test public void service_nullServiceInterface() { URL url = URL.valueOf("dubbo: when(invoker.getUrl()).thenReturn(url); assertThat(DubboParser.service(invoker)).isNull(); }
@Test public void service_malformed() { URL url = URL.valueOf("dubbo: when(invoker.getUrl()).thenReturn(url); assertThat(DubboParser.service(invoker)).isNull(); }
@Test public void service() { when(invoker.getUrl()).thenReturn(url); when(url.getServiceInterface()).thenReturn("brave.dubbo.GreeterService"); assertThat(DubboParser.service(invoker)) .isEqualTo("brave.dubbo.GreeterService"); }
@Test public void service_nullServiceInterface() { when(invoker.getUrl()).thenReturn(url); assertThat(DubboParser.service(invoker)).isNull(); }
@Test public void service_malformed() { when(invoker.getUrl()).thenReturn(url); when(url.getServiceInterface()).thenReturn(""); assertThat(DubboParser.service(invoker)).isNull(); }