MemoryServiceProxy extends ServiceProxy { @Override public ServerServiceDefinition getServiceDefinition() { Map<MethodDescriptor, ServerCallHandler> overrides = new HashMap<>(); overrides.put(MemoryServiceGrpc.METHOD_START_MONITORING_APP, ServerCalls.asyncUnaryCall((request, observer) -> { startMonitoringApp((MemoryStartRequest)request, (StreamObserver)observer); })); overrides.put(MemoryServiceGrpc.METHOD_STOP_MONITORING_APP, ServerCalls.asyncUnaryCall((request, observer) -> { stopMonitoringApp((MemoryStopRequest)request, (StreamObserver)observer); })); overrides.put(MemoryServiceGrpc.METHOD_GET_DATA, ServerCalls.asyncUnaryCall((request, observer) -> { getData((MemoryRequest)request, (StreamObserver)observer); })); overrides.put(MemoryServiceGrpc.METHOD_TRACK_ALLOCATIONS, ServerCalls.asyncUnaryCall((request, observer) -> { trackAllocations((TrackAllocationsRequest)request, (StreamObserver)observer); })); overrides.put(MemoryServiceGrpc.METHOD_FORCE_GARBAGE_COLLECTION, ServerCalls.asyncUnaryCall((request, observer) -> { forceGarbageCollection((ForceGarbageCollectionRequest)request, (StreamObserver)observer); })); return generatePassThroughDefinitions(overrides, myServiceStub); } MemoryServiceProxy(@NotNull IDevice device,
                            @NotNull ManagedChannel channel,
                            @NotNull Executor fetchExecutor,
                            @NotNull BiFunction<IDevice, Integer, LegacyAllocationTracker> legacyTrackerSupplier,
                            Map<String, ByteString> proxyBytesCache); void startMonitoringApp(MemoryProfiler.MemoryStartRequest request,
                                 StreamObserver<MemoryProfiler.MemoryStartResponse> responseObserver); void stopMonitoringApp(MemoryProfiler.MemoryStopRequest request,
                                StreamObserver<MemoryProfiler.MemoryStopResponse> responseObserver); void getData(MemoryProfiler.MemoryRequest request, StreamObserver<MemoryProfiler.MemoryData> responseObserver); void trackAllocations(TrackAllocationsRequest request,
                               StreamObserver<TrackAllocationsResponse> responseObserver); void forceGarbageCollection(ForceGarbageCollectionRequest request, StreamObserver<ForceGarbageCollectionResponse> observer); @Override ServerServiceDefinition getServiceDefinition();  }
@Test public void testBindServiceContainsAllMethods() throws Exception { ServerServiceDefinition serverDefinition = myProxy.getServiceDefinition(); Collection<MethodDescriptor<?, ?>> allMethods = MemoryServiceGrpc.getServiceDescriptor().getMethods(); Set<MethodDescriptor<?, ?>> definedMethods = serverDefinition.getMethods().stream().map(method -> method.getMethodDescriptor()).collect(Collectors.toSet()); assertThat(definedMethods.size()).isEqualTo(allMethods.size()); definedMethods.containsAll(allMethods); }