### Question:
ServiceDescriptor { public static Builder newBuilder(String name) { return new Builder(name); } ServiceDescriptor(String name, MethodDescriptor<?, ?>... methods);  ServiceDescriptor(String name, Collection<MethodDescriptor<?, ?>> methods); private  ServiceDescriptor(Builder b); String getName(); Collection<MethodDescriptor<?, ?>> getMethods(); @Nullable @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2222") Object getSchemaDescriptor(); static Builder newBuilder(String name); @Override String toString();  }### Answer:
@Test public void failsOnNonMatchingNames() { List<MethodDescriptor<?, ?>> descriptors = Collections.<MethodDescriptor<?, ?>>singletonList( MethodDescriptor.<Void, Void>newBuilder() .setType(MethodType.UNARY) .setFullMethodName(MethodDescriptor.generateFullMethodName("wrongservice", "method")) .setRequestMarshaller(TestMethodDescriptors.voidMarshaller()) .setResponseMarshaller(TestMethodDescriptors.voidMarshaller()) .build()); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("service names"); new ServiceDescriptor("name", descriptors); }
@Test public void failsOnNonDuplicateNames() { List<MethodDescriptor<?, ?>> descriptors = Arrays.<MethodDescriptor<?, ?>>asList( MethodDescriptor.<Void, Void>newBuilder() .setType(MethodType.UNARY) .setFullMethodName(MethodDescriptor.generateFullMethodName("name", "method")) .setRequestMarshaller(TestMethodDescriptors.voidMarshaller()) .setResponseMarshaller(TestMethodDescriptors.voidMarshaller()) .build(), MethodDescriptor.<Void, Void>newBuilder() .setType(MethodType.UNARY) .setFullMethodName(MethodDescriptor.generateFullMethodName("name", "method")) .setRequestMarshaller(TestMethodDescriptors.voidMarshaller()) .setResponseMarshaller(TestMethodDescriptors.voidMarshaller()) .build()); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("duplicate"); new ServiceDescriptor("name", descriptors); }