CallOptions { @Deprecated public CallOptions withDeadlineNanoTime(@Nullable Long deadlineNanoTime) { Deadline deadline = deadlineNanoTime != null ? Deadline.after(deadlineNanoTime - System.nanoTime(), TimeUnit.NANOSECONDS) : null; return withDeadline(deadline); } private  CallOptions(); private  CallOptions(CallOptions other); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1767") CallOptions withAuthority(@Nullable String authority); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704") CallOptions withCompression(@Nullable String compressorName); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1706") CallOptions withDeadline(@Nullable Deadline deadline); @Deprecated CallOptions withDeadlineNanoTime(@Nullable Long deadlineNanoTime); CallOptions withDeadlineAfter(long duration, TimeUnit unit); @Deprecated Long getDeadlineNanoTime(); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1706") @Nullable Deadline getDeadline(); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1766") CallOptions withAffinity(Attributes affinity); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1766") Attributes getAffinity(); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704") @Nullable String getCompressor(); @Nullable @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1767") String getAuthority(); CallOptions withExecutor(Executor executor); @Nullable Executor getExecutor(); @Override String toString(); static final CallOptions DEFAULT; }
@Test @SuppressWarnings("deprecation") public void withDeadlineNanoTime() { Deadline reference = Deadline.after(-1, NANOSECONDS); long rawDeadline = System.nanoTime() - 1; CallOptions opts = CallOptions.DEFAULT.withDeadlineNanoTime(rawDeadline); assertThat(opts.getDeadlineNanoTime()).isNotNull(); assertThat(opts.getDeadlineNanoTime()).isAtMost(System.nanoTime()); assertThat(opts.getDeadline().isExpired()).isTrue(); assertAbout(deadline()).that(opts.getDeadline()).isWithin(50, MILLISECONDS).of(reference); }