@Test
public void testGetSpanNameInvalid() {

  List<String> invalidNames = ImmutableList.of("BareMethod", "/MethodWithoutService");
  for (String invalidName : invalidNames) {
    @SuppressWarnings("unchecked")
    MethodDescriptor descriptor =
        MethodDescriptor.newBuilder()
            .setType(MethodType.SERVER_STREAMING)
            .setFullMethodName(invalidName)
            .setRequestMarshaller(Mockito.mock(Marshaller.class))
            .setResponseMarshaller(Mockito.mock(Marshaller.class))
            .build();
    IllegalArgumentException actualError = null;
    try {
      SpanName spanName = GrpcCallableFactory.getSpanName(descriptor);
      Truth.assertWithMessage(
              "Invalid method descriptor should not have a valid span name: %s should not generate the spanName: %s",
              invalidName, spanName)
          .fail();
    } catch (IllegalArgumentException e) {
      actualError = e;
    }
    assertThat(actualError).isNotNull();
  }
}