| 34 | import org.junit.runners.JUnit4; |
| 35 | |
| 36 | @RunWith(JUnit4.class) |
| 37 | public class AbstractStubTest extends BaseAbstractStubTest<NoopStub> { |
| 38 | |
| 39 | @Override |
| 40 | NoopStub create(Channel channel, CallOptions callOptions) { |
| 41 | return new NoopStub(channel, callOptions); |
| 42 | } |
| 43 | |
| 44 | @Test |
| 45 | public void defaultCallOptions() { |
| 46 | NoopStub stub = NoopStub.newStub(new StubFactory<NoopStub>() { |
| 47 | @Override |
| 48 | public NoopStub newStub(Channel channel, CallOptions callOptions) { |
| 49 | return create(channel, callOptions); |
| 50 | } |
| 51 | }, channel, CallOptions.DEFAULT); |
| 52 | |
| 53 | assertThat(stub.getCallOptions().getOption(ClientCalls.STUB_TYPE_OPTION)) |
| 54 | .isNull(); |
| 55 | } |
| 56 | |
| 57 | @Test |
| 58 | @IgnoreJRERequirement |
| 59 | public void testDuration() { |
| 60 | NoopStub stub = NoopStub.newStub(new StubFactory<NoopStub>() { |
| 61 | @Override |
| 62 | public NoopStub newStub(Channel channel, CallOptions callOptions) { |
| 63 | return create(channel, callOptions); |
| 64 | } |
| 65 | }, channel, CallOptions.DEFAULT); |
| 66 | NoopStub stubInstance = stub.withDeadlineAfter(Duration.ofMinutes(1L)); |
| 67 | Deadline actual = stubInstance.getCallOptions().getDeadline(); |
| 68 | Deadline expected = Deadline.after(1, MINUTES); |
| 69 | |
| 70 | assertAbout(deadline()).that(actual).isWithin(10, MILLISECONDS).of(expected); |
| 71 | } |
| 72 | |
| 73 | class NoopStub extends AbstractStub<NoopStub> { |
| 74 | NoopStub(Channel channel, CallOptions options) { |
| 75 | super(channel, options); |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | protected NoopStub build(Channel channel, CallOptions callOptions) { |
| 80 | return new NoopStub(channel, callOptions); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 |
nothing calls this directly
no outgoing calls
no test coverage detected