EventServiceProxy extends ServiceProxy { @Override public ServerServiceDefinition getServiceDefinition() { return generatePassThroughDefinitions(Collections.emptyMap(), myServiceStub); } EventServiceProxy(@NotNull IDevice device, @NotNull ManagedChannel channel); @Override ServerServiceDefinition getServiceDefinition();  }
@Test public void testBindServiceContainsAllMethods() throws Exception { IDevice mockDevice = mock(IDevice.class); when(mockDevice.getSerialNumber()).thenReturn("Serial"); when(mockDevice.getName()).thenReturn("Device"); when(mockDevice.getVersion()).thenReturn(new AndroidVersion(1, "API")); when(mockDevice.isOnline()).thenReturn(true); when(mockDevice.getClients()).thenReturn(new Client[0]); ManagedChannel channel = InProcessChannelBuilder.forName("EventServiceProxyTest").build(); EventServiceProxy proxy = new EventServiceProxy(mockDevice, channel); ServerServiceDefinition serverDefinition = proxy.getServiceDefinition(); Collection<MethodDescriptor<?, ?>> allMethods = EventServiceGrpc.getServiceDescriptor().getMethods(); Set<MethodDescriptor<?, ?>> definedMethods = serverDefinition.getMethods().stream().map(method -> method.getMethodDescriptor()).collect(Collectors.toSet()); assertThat(definedMethods.size()).isEqualTo(allMethods.size()); definedMethods.containsAll(allMethods); }