### Question:
CallOptions { @ExperimentalApi("https: public CallOptions withStreamTracerFactory(ClientStreamTracer.Factory factory) { CallOptions newOptions = new CallOptions(this); ArrayList<ClientStreamTracer.Factory> newList = new ArrayList<ClientStreamTracer.Factory>(streamTracerFactories.size() + 1); newList.addAll(streamTracerFactories); newList.add(factory); newOptions.streamTracerFactories = Collections.unmodifiableList(newList); return newOptions; } private  CallOptions(); private  CallOptions(CallOptions other); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1767") CallOptions withAuthority(@Nullable String authority); CallOptions withCallCredentials(@Nullable CallCredentials credentials); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704") CallOptions withCompression(@Nullable String compressorName); CallOptions withDeadline(@Nullable Deadline deadline); CallOptions withDeadlineAfter(long duration, TimeUnit unit); @Nullable Deadline getDeadline(); CallOptions withWaitForReady(); CallOptions withoutWaitForReady(); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704") @Nullable String getCompressor(); @Nullable @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1767") String getAuthority(); @Nullable CallCredentials getCredentials(); CallOptions withExecutor(Executor executor); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2861") CallOptions withStreamTracerFactory(ClientStreamTracer.Factory factory); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2861") List<ClientStreamTracer.Factory> getStreamTracerFactories(); CallOptions withOption(Key<T> key, T value); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1869") @SuppressWarnings("unchecked") T getOption(Key<T> key); @Nullable Executor getExecutor(); boolean isWaitForReady(); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563") CallOptions withMaxInboundMessageSize(int maxSize); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563") CallOptions withMaxOutboundMessageSize(int maxSize); @Nullable @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563") Integer getMaxInboundMessageSize(); @Nullable @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2563") Integer getMaxOutboundMessageSize(); @Override String toString(); static final CallOptions DEFAULT; }### Answer:
@Test public void withStreamTracerFactory() { CallOptions opts1 = CallOptions.DEFAULT.withStreamTracerFactory(tracerFactory1); CallOptions opts2 = opts1.withStreamTracerFactory(tracerFactory2); CallOptions opts3 = opts2.withStreamTracerFactory(tracerFactory2); assertThat(opts1.getStreamTracerFactories()).containsExactly(tracerFactory1); assertThat(opts2.getStreamTracerFactories()).containsExactly(tracerFactory1, tracerFactory2) .inOrder(); assertThat(opts3.getStreamTracerFactories()) .containsExactly(tracerFactory1, tracerFactory2, tracerFactory2).inOrder(); try { CallOptions.DEFAULT.getStreamTracerFactories().add(tracerFactory1); fail("Should have thrown. The list should be unmodifiable."); } catch (UnsupportedOperationException e) { } try { opts2.getStreamTracerFactories().clear(); fail("Should have thrown. The list should be unmodifiable."); } catch (UnsupportedOperationException e) { } }