target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test public void testRequestWithProxy() throws IOException, InterruptedException { final String backendHost = "intake.profiling.datadoghq.com:1234"; final String backendUrl = "http: when(config.getFinalProfilingUrl()) .thenReturn("http: when(config.getProfilingProxyHost()).thenReturn(server.url("").host()); when(confi... | public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem uploading profile!", e);... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... |
@Test public void testRequestWithProxyDefaultPassword() throws IOException, InterruptedException { final String backendUrl = "http: when(config.getFinalProfilingUrl()) .thenReturn("http: when(config.getProfilingProxyHost()).thenReturn(server.url("").host()); when(config.getProfilingProxyPort()).thenReturn(server.url(""... | public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem uploading profile!", e);... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... |
@Test void testOkHttpClientForcesCleartextConnspecWhenNotUsingTLS() { when(config.getFinalProfilingUrl()).thenReturn("http: uploader = new ProfileUploader(config); final List<ConnectionSpec> connectionSpecs = uploader.getClient().connectionSpecs(); assertEquals(connectionSpecs.size(), 1); assertTrue(connectionSpecs.con... | OkHttpClient getClient() { return client; } | ProfileUploader { OkHttpClient getClient() { return client; } } | ProfileUploader { OkHttpClient getClient() { return client; } ProfileUploader(final Config config); ProfileUploader(
final Config config, final RatelimitedLogger ratelimitedLogger, final String containerId); } | ProfileUploader { OkHttpClient getClient() { return client; } ProfileUploader(final Config config); ProfileUploader(
final Config config, final RatelimitedLogger ratelimitedLogger, final String containerId); void upload(final RecordingType type, final RecordingData data); void shutdown(); } | ProfileUploader { OkHttpClient getClient() { return client; } ProfileUploader(final Config config); ProfileUploader(
final Config config, final RatelimitedLogger ratelimitedLogger, final String containerId); void upload(final RecordingType type, final RecordingData data); void shutdown(); } |
@Test void testOkHttpClientUsesDefaultConnspecsOverTLS() { when(config.getFinalProfilingUrl()).thenReturn("https: uploader = new ProfileUploader(config); final List<ConnectionSpec> connectionSpecs = uploader.getClient().connectionSpecs(); assertEquals(connectionSpecs.size(), 2); assertTrue(connectionSpecs.contains(Conn... | OkHttpClient getClient() { return client; } | ProfileUploader { OkHttpClient getClient() { return client; } } | ProfileUploader { OkHttpClient getClient() { return client; } ProfileUploader(final Config config); ProfileUploader(
final Config config, final RatelimitedLogger ratelimitedLogger, final String containerId); } | ProfileUploader { OkHttpClient getClient() { return client; } ProfileUploader(final Config config); ProfileUploader(
final Config config, final RatelimitedLogger ratelimitedLogger, final String containerId); void upload(final RecordingType type, final RecordingData data); void shutdown(); } | ProfileUploader { OkHttpClient getClient() { return client; } ProfileUploader(final Config config); ProfileUploader(
final Config config, final RatelimitedLogger ratelimitedLogger, final String containerId); void upload(final RecordingType type, final RecordingData data); void shutdown(); } |
@Test public void testRecordingClosed() throws IOException { server.enqueue(new MockResponse().setResponseCode(200)); final RecordingData recording = mockRecordingData(RECORDING_RESOURCE); uploader.upload(RECORDING_TYPE, recording); verify(recording.getStream()).close(); verify(recording).release(); } | public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem uploading profile!", e);... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... |
@Test public void test500Response() throws IOException, InterruptedException { server.enqueue(new MockResponse().setResponseCode(500)); final RecordingData recording = mockRecordingData(RECORDING_RESOURCE); uploader.upload(RECORDING_TYPE, recording); assertNotNull(server.takeRequest(5, TimeUnit.SECONDS)); verify(record... | public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem uploading profile!", e);... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... |
@Test public void testTimeout() throws IOException, InterruptedException { server.enqueue( new MockResponse() .setHeadersDelay( REQUEST_IO_OPERATION_TIMEOUT.plus(Duration.ofMillis(1000)).toMillis(), TimeUnit.MILLISECONDS)); final RecordingData recording = mockRecordingData(RECORDING_RESOURCE); uploader.upload(RECORDING... | public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem uploading profile!", e);... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... |
@Test public void testUnfinishedRecording() throws IOException { final RecordingData recording = mockRecordingData(RECORDING_RESOURCE); when(recording.getStream()).thenThrow(new IllegalStateException("test exception")); uploader.upload(RECORDING_TYPE, recording); verify(recording).release(); verify(recording, times(2))... | public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem uploading profile!", e);... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... |
@Test void insertInvalid() { assertThrows(IllegalArgumentException.class, () -> instance.insert(1, null)); } | public void insert(int ptr, T constant) { if (constant == null) { if (ptr != -1) { throw new IllegalArgumentException(); } return; } indexMap.put(constant, ptr); reverseIndexMap.put(ptr, constant); offset = Math.max(offset, ptr + 1); } | ConstantPool { public void insert(int ptr, T constant) { if (constant == null) { if (ptr != -1) { throw new IllegalArgumentException(); } return; } indexMap.put(constant, ptr); reverseIndexMap.put(ptr, constant); offset = Math.max(offset, ptr + 1); } } | ConstantPool { public void insert(int ptr, T constant) { if (constant == null) { if (ptr != -1) { throw new IllegalArgumentException(); } return; } indexMap.put(constant, ptr); reverseIndexMap.put(ptr, constant); offset = Math.max(offset, ptr + 1); } ConstantPool(); ConstantPool(int startingIndex); } | ConstantPool { public void insert(int ptr, T constant) { if (constant == null) { if (ptr != -1) { throw new IllegalArgumentException(); } return; } indexMap.put(constant, ptr); reverseIndexMap.put(ptr, constant); offset = Math.max(offset, ptr + 1); } ConstantPool(); ConstantPool(int startingIndex); T get(int index); ... | ConstantPool { public void insert(int ptr, T constant) { if (constant == null) { if (ptr != -1) { throw new IllegalArgumentException(); } return; } indexMap.put(constant, ptr); reverseIndexMap.put(ptr, constant); offset = Math.max(offset, ptr + 1); } ConstantPool(); ConstantPool(int startingIndex); T get(int index); ... |
@Test public void testHeaders() throws IOException, InterruptedException { server.enqueue(new MockResponse().setResponseCode(200)); uploader.upload(RECORDING_TYPE, mockRecordingData(RECORDING_RESOURCE)); final RecordedRequest recordedRequest = server.takeRequest(5, TimeUnit.SECONDS); assertEquals( ProfileUploader.JAVA_... | public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem uploading profile!", e);... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... |
@Test public void testEnqueuedRequestsExecuted() throws IOException, InterruptedException { for (int i = 0; i < ProfileUploader.MAX_RUNNING_REQUESTS; i++) { server.enqueue( new MockResponse() .setHeadersDelay( Duration.ofMillis(1000).toMillis(), TimeUnit.MILLISECONDS) .setResponseCode(200)); } server.enqueue(new MockRe... | public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem uploading profile!", e);... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... |
@Test public void testTooManyRequests() throws IOException, InterruptedException { when(config.getProfilingUploadTimeout()).thenReturn((int) FOREVER_REQUEST_TIMEOUT.getSeconds()); uploader = new ProfileUploader(config); for (int i = 0; i < ProfileUploader.MAX_RUNNING_REQUESTS; i++) { server.enqueue( new MockResponse() ... | public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem uploading profile!", e);... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... | ProfileUploader { public void upload(final RecordingType type, final RecordingData data) { try { if (canEnqueueMoreRequests()) { makeUploadRequest(type, data); } else { log.warn("Cannot upload profile data: too many enqueued requests!"); } } catch (final IllegalStateException | IOException e) { log.warn("Problem upload... |
@Test public void testShutdown() throws IOException, InterruptedException { uploader.shutdown(); final RecordingData recording = mockRecordingData(RECORDING_RESOURCE); uploader.upload(RECORDING_TYPE, recording); assertNull(server.takeRequest(100, TimeUnit.MILLISECONDS), "No more requests"); verify(recording.getStream()... | public void shutdown() { okHttpExecutorService.shutdownNow(); try { okHttpExecutorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.warn("Wait for executor shutdown interrupted"); } client.connectionPool().evictAll(); } | ProfileUploader { public void shutdown() { okHttpExecutorService.shutdownNow(); try { okHttpExecutorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.warn("Wait for executor shutdown interrupted"); } client.connectionPool().evictAll(); } } | ProfileUploader { public void shutdown() { okHttpExecutorService.shutdownNow(); try { okHttpExecutorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.warn("Wait for executor shutdown interrupted"); } client.connectionPool().evictAll(); } ProfileUploader(final ... | ProfileUploader { public void shutdown() { okHttpExecutorService.shutdownNow(); try { okHttpExecutorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.warn("Wait for executor shutdown interrupted"); } client.connectionPool().evictAll(); } ProfileUploader(final ... | ProfileUploader { public void shutdown() { okHttpExecutorService.shutdownNow(); try { okHttpExecutorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.warn("Wait for executor shutdown interrupted"); } client.connectionPool().evictAll(); } ProfileUploader(final ... |
@Test public void testThreadName() { final Thread thread = factory.newThread(() -> {}); assertEquals("test-name", thread.getName()); } | @Override public Thread newThread(final Runnable r) { final Thread t = new Thread(THREAD_GROUP, r, name); t.setDaemon(true); return t; } | ProfilingThreadFactory implements ThreadFactory { @Override public Thread newThread(final Runnable r) { final Thread t = new Thread(THREAD_GROUP, r, name); t.setDaemon(true); return t; } } | ProfilingThreadFactory implements ThreadFactory { @Override public Thread newThread(final Runnable r) { final Thread t = new Thread(THREAD_GROUP, r, name); t.setDaemon(true); return t; } ProfilingThreadFactory(final String name); } | ProfilingThreadFactory implements ThreadFactory { @Override public Thread newThread(final Runnable r) { final Thread t = new Thread(THREAD_GROUP, r, name); t.setDaemon(true); return t; } ProfilingThreadFactory(final String name); @Override Thread newThread(final Runnable r); } | ProfilingThreadFactory implements ThreadFactory { @Override public Thread newThread(final Runnable r) { final Thread t = new Thread(THREAD_GROUP, r, name); t.setDaemon(true); return t; } ProfilingThreadFactory(final String name); @Override Thread newThread(final Runnable r); } |
@Test @EnabledOnJre({JAVA_8}) public void testCreateControllerJava8() { final UnsupportedEnvironmentException unsupportedEnvironmentException = assertThrows( UnsupportedEnvironmentException.class, () -> { ControllerFactory.createController(config); }); String expected = "Not enabling profiling; it requires OpenJDK 11+,... | public static Controller createController(final Config config) throws UnsupportedEnvironmentException, ConfigurationException { try { Class.forName("com.oracle.jrockit.jfr.Producer"); throw new UnsupportedEnvironmentException( "Not enabling profiling; it requires Oracle Java 11+."); } catch (final ClassNotFoundExceptio... | ControllerFactory { public static Controller createController(final Config config) throws UnsupportedEnvironmentException, ConfigurationException { try { Class.forName("com.oracle.jrockit.jfr.Producer"); throw new UnsupportedEnvironmentException( "Not enabling profiling; it requires Oracle Java 11+."); } catch (final C... | ControllerFactory { public static Controller createController(final Config config) throws UnsupportedEnvironmentException, ConfigurationException { try { Class.forName("com.oracle.jrockit.jfr.Producer"); throw new UnsupportedEnvironmentException( "Not enabling profiling; it requires Oracle Java 11+."); } catch (final C... | ControllerFactory { public static Controller createController(final Config config) throws UnsupportedEnvironmentException, ConfigurationException { try { Class.forName("com.oracle.jrockit.jfr.Producer"); throw new UnsupportedEnvironmentException( "Not enabling profiling; it requires Oracle Java 11+."); } catch (final C... | ControllerFactory { public static Controller createController(final Config config) throws UnsupportedEnvironmentException, ConfigurationException { try { Class.forName("com.oracle.jrockit.jfr.Producer"); throw new UnsupportedEnvironmentException( "Not enabling profiling; it requires Oracle Java 11+."); } catch (final C... |
@Test public void testShutdown() throws ConfigurationException { final ProfilingSystem system = new ProfilingSystem( controller, listener, Duration.ofMillis(10), Duration.ZERO, Duration.ofMillis(300), false, pool, threadLocalRandom); startProfilingSystem(system); verify(controller).createRecording(any()); system.shutdo... | public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... |
@Test public void testShutdownWithRunningProfilingRecording() throws ConfigurationException { final ProfilingSystem system = new ProfilingSystem( controller, listener, Duration.ofMillis(10), Duration.ZERO, Duration.ofMillis(300), false, pool, threadLocalRandom); startProfilingSystem(system); verify(controller).createRe... | public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... |
@Test public void testShutdownInterruption() throws ConfigurationException { final Thread mainThread = Thread.currentThread(); doAnswer( (InvocationOnMock invocation) -> { while (!pool.isShutdown()) { try { Thread.sleep(100); } catch (final InterruptedException e) { } } mainThread.interrupt(); return null; }) .when(lis... | public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... |
@Test public void testCanShutDownWithoutStarting() throws ConfigurationException { final ProfilingSystem system = new ProfilingSystem( controller, listener, Duration.ofMillis(10), Duration.ofMillis(5), Duration.ofMillis(300), false, pool, threadLocalRandom); system.shutdown(); assertTrue(pool.isTerminated()); } | public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... |
@Test void insertNull() { assertDoesNotThrow(() -> instance.insert(-1, null)); } | public void insert(int ptr, T constant) { if (constant == null) { if (ptr != -1) { throw new IllegalArgumentException(); } return; } indexMap.put(constant, ptr); reverseIndexMap.put(ptr, constant); offset = Math.max(offset, ptr + 1); } | ConstantPool { public void insert(int ptr, T constant) { if (constant == null) { if (ptr != -1) { throw new IllegalArgumentException(); } return; } indexMap.put(constant, ptr); reverseIndexMap.put(ptr, constant); offset = Math.max(offset, ptr + 1); } } | ConstantPool { public void insert(int ptr, T constant) { if (constant == null) { if (ptr != -1) { throw new IllegalArgumentException(); } return; } indexMap.put(constant, ptr); reverseIndexMap.put(ptr, constant); offset = Math.max(offset, ptr + 1); } ConstantPool(); ConstantPool(int startingIndex); } | ConstantPool { public void insert(int ptr, T constant) { if (constant == null) { if (ptr != -1) { throw new IllegalArgumentException(); } return; } indexMap.put(constant, ptr); reverseIndexMap.put(ptr, constant); offset = Math.max(offset, ptr + 1); } ConstantPool(); ConstantPool(int startingIndex); T get(int index); ... | ConstantPool { public void insert(int ptr, T constant) { if (constant == null) { if (ptr != -1) { throw new IllegalArgumentException(); } return; } indexMap.put(constant, ptr); reverseIndexMap.put(ptr, constant); offset = Math.max(offset, ptr + 1); } ConstantPool(); ConstantPool(int startingIndex); T get(int index); ... |
@Test public void testDoesntSendDataIfNotStarted() throws InterruptedException, ConfigurationException { final ProfilingSystem system = new ProfilingSystem( controller, listener, Duration.ofMillis(10), Duration.ofMillis(5), Duration.ofMillis(1), false); Thread.sleep(50); system.shutdown(); verify(controller, never()).c... | public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... |
@Test public void testDoesntSendPeriodicRecordingIfPeriodicRecordingIsDisabled() throws InterruptedException, ConfigurationException { when(recording.snapshot(any(), any())).thenReturn(recordingData); final ProfilingSystem system = new ProfilingSystem( controller, listener, Duration.ofMillis(10), Duration.ofMillis(5), ... | public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... |
@Test public void testRecordingSnapshotError() throws ConfigurationException { final Duration uploadPeriod = Duration.ofMillis(300); final List<RecordingData> generatedRecordingData = new ArrayList<>(); when(recording.snapshot(any(), any())) .thenThrow(new RuntimeException("Test")) .thenAnswer(generateMockRecordingData... | public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... |
@Test public void testRecordingSnapshotNoData() throws ConfigurationException { final Duration uploadPeriod = Duration.ofMillis(300); final List<RecordingData> generatedRecordingData = new ArrayList<>(); when(recording.snapshot(any(), any())) .thenReturn(null) .thenAnswer(generateMockRecordingData(generatedRecordingDat... | public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... | ProfilingSystem { public final void shutdown() { executorService.shutdownNow(); try { executorService.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS); } catch (final InterruptedException e) { log.error("Wait for executor shutdown interrupted"); } if (recording != null) { recording.close(); } started = false; } ... |
@Test public void testRandomizedStartupDelay() throws ConfigurationException { final Duration startupDelay = Duration.ofMillis(100); final Duration startupDelayRandomRange = Duration.ofMillis(500); final Duration additionalRandomDelay = Duration.ofMillis(300); when(threadLocalRandom.nextLong(startupDelayRandomRange.toM... | final Duration getStartupDelay() { return startupDelay; } | ProfilingSystem { final Duration getStartupDelay() { return startupDelay; } } | ProfilingSystem { final Duration getStartupDelay() { return startupDelay; } ProfilingSystem(
final Controller controller,
final RecordingDataListener dataListener,
final Duration startupDelay,
final Duration startupDelayRandomRange,
final Duration uploadPeriod,
final boolean isStarti... | ProfilingSystem { final Duration getStartupDelay() { return startupDelay; } ProfilingSystem(
final Controller controller,
final RecordingDataListener dataListener,
final Duration startupDelay,
final Duration startupDelayRandomRange,
final Duration uploadPeriod,
final boolean isStarti... | ProfilingSystem { final Duration getStartupDelay() { return startupDelay; } ProfilingSystem(
final Controller controller,
final RecordingDataListener dataListener,
final Duration startupDelay,
final Duration startupDelayRandomRange,
final Duration uploadPeriod,
final boolean isStarti... |
@Test public void testFixedStartupDelay() throws ConfigurationException { final Duration startupDelay = Duration.ofMillis(100); final ProfilingSystem system = new ProfilingSystem( controller, listener, startupDelay, Duration.ZERO, Duration.ofMillis(100), false, pool, threadLocalRandom); assertEquals(startupDelay, syste... | final Duration getStartupDelay() { return startupDelay; } | ProfilingSystem { final Duration getStartupDelay() { return startupDelay; } } | ProfilingSystem { final Duration getStartupDelay() { return startupDelay; } ProfilingSystem(
final Controller controller,
final RecordingDataListener dataListener,
final Duration startupDelay,
final Duration startupDelayRandomRange,
final Duration uploadPeriod,
final boolean isStarti... | ProfilingSystem { final Duration getStartupDelay() { return startupDelay; } ProfilingSystem(
final Controller controller,
final RecordingDataListener dataListener,
final Duration startupDelay,
final Duration startupDelayRandomRange,
final Duration uploadPeriod,
final boolean isStarti... | ProfilingSystem { final Duration getStartupDelay() { return startupDelay; } ProfilingSystem(
final Controller controller,
final RecordingDataListener dataListener,
final Duration startupDelay,
final Duration startupDelayRandomRange,
final Duration uploadPeriod,
final boolean isStarti... |
@Test void size() { String value1 = "test1"; String value2 = "test2"; assertEquals(0, instance.size()); instance.insert(0, value1); assertEquals(1, instance.size()); instance.getOrInsert(value1); assertEquals(1, instance.size()); instance.getOrInsert(value2); assertEquals(2, instance.size()); } | public int size() { return indexMap.size(); } | ConstantPool { public int size() { return indexMap.size(); } } | ConstantPool { public int size() { return indexMap.size(); } ConstantPool(); ConstantPool(int startingIndex); } | ConstantPool { public int size() { return indexMap.size(); } ConstantPool(); ConstantPool(int startingIndex); T get(int index); int getOrInsert(T constant); void insert(int ptr, T constant); int size(); } | ConstantPool { public int size() { return indexMap.size(); } ConstantPool(); ConstantPool(int startingIndex); T get(int index); int getOrInsert(T constant); void insert(int ptr, T constant); int size(); } |
@Test void testGetPackedIntLen() { assertEquals(1, AbstractLEB128Writer.getPackedIntLen(0)); long val = 1L; for (int i = 1; i < 10; i++) { assertEquals(Math.max(i - 1, 1), AbstractLEB128Writer.getPackedIntLen(val - 1)); assertEquals(i, AbstractLEB128Writer.getPackedIntLen(val)); val = val << 7; } } | static int getPackedIntLen(long data) { if ((data & COMPRESSED_INT_MASK) == 0) { return 1; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0) { return 2; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0) { return 3; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0) { return 4; } data >>= 7; if ((data & COMPRESS... | AbstractLEB128Writer implements LEB128Writer { static int getPackedIntLen(long data) { if ((data & COMPRESSED_INT_MASK) == 0) { return 1; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0) { return 2; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0) { return 3; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0)... | AbstractLEB128Writer implements LEB128Writer { static int getPackedIntLen(long data) { if ((data & COMPRESSED_INT_MASK) == 0) { return 1; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0) { return 2; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0) { return 3; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0)... | AbstractLEB128Writer implements LEB128Writer { static int getPackedIntLen(long data) { if ((data & COMPRESSED_INT_MASK) == 0) { return 1; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0) { return 2; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0) { return 3; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0)... | AbstractLEB128Writer implements LEB128Writer { static int getPackedIntLen(long data) { if ((data & COMPRESSED_INT_MASK) == 0) { return 1; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0) { return 2; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0) { return 3; } data >>= 7; if ((data & COMPRESSED_INT_MASK) == 0)... |
@Test public void testStop() { assertEquals(recording, ongoingRecording.stop().getRecording()); verify(recording).stop(); } | @Override public OpenJdkRecordingData stop() { if (recording.getState() != RecordingState.RUNNING) { throw new IllegalStateException("Cannot stop recording that is not running"); } recording.stop(); return new OpenJdkRecordingData(recording); } | OpenJdkOngoingRecording implements OngoingRecording { @Override public OpenJdkRecordingData stop() { if (recording.getState() != RecordingState.RUNNING) { throw new IllegalStateException("Cannot stop recording that is not running"); } recording.stop(); return new OpenJdkRecordingData(recording); } } | OpenJdkOngoingRecording implements OngoingRecording { @Override public OpenJdkRecordingData stop() { if (recording.getState() != RecordingState.RUNNING) { throw new IllegalStateException("Cannot stop recording that is not running"); } recording.stop(); return new OpenJdkRecordingData(recording); } OpenJdkOngoingRecordi... | OpenJdkOngoingRecording implements OngoingRecording { @Override public OpenJdkRecordingData stop() { if (recording.getState() != RecordingState.RUNNING) { throw new IllegalStateException("Cannot stop recording that is not running"); } recording.stop(); return new OpenJdkRecordingData(recording); } OpenJdkOngoingRecordi... | OpenJdkOngoingRecording implements OngoingRecording { @Override public OpenJdkRecordingData stop() { if (recording.getState() != RecordingState.RUNNING) { throw new IllegalStateException("Cannot stop recording that is not running"); } recording.stop(); return new OpenJdkRecordingData(recording); } OpenJdkOngoingRecordi... |
@Test public void testStopOnStopped() { when(recording.getState()).thenReturn(RecordingState.STOPPED); assertThrows( IllegalStateException.class, () -> { ongoingRecording.stop(); }); verify(recording, never()).stop(); } | @Override public OpenJdkRecordingData stop() { if (recording.getState() != RecordingState.RUNNING) { throw new IllegalStateException("Cannot stop recording that is not running"); } recording.stop(); return new OpenJdkRecordingData(recording); } | OpenJdkOngoingRecording implements OngoingRecording { @Override public OpenJdkRecordingData stop() { if (recording.getState() != RecordingState.RUNNING) { throw new IllegalStateException("Cannot stop recording that is not running"); } recording.stop(); return new OpenJdkRecordingData(recording); } } | OpenJdkOngoingRecording implements OngoingRecording { @Override public OpenJdkRecordingData stop() { if (recording.getState() != RecordingState.RUNNING) { throw new IllegalStateException("Cannot stop recording that is not running"); } recording.stop(); return new OpenJdkRecordingData(recording); } OpenJdkOngoingRecordi... | OpenJdkOngoingRecording implements OngoingRecording { @Override public OpenJdkRecordingData stop() { if (recording.getState() != RecordingState.RUNNING) { throw new IllegalStateException("Cannot stop recording that is not running"); } recording.stop(); return new OpenJdkRecordingData(recording); } OpenJdkOngoingRecordi... | OpenJdkOngoingRecording implements OngoingRecording { @Override public OpenJdkRecordingData stop() { if (recording.getState() != RecordingState.RUNNING) { throw new IllegalStateException("Cannot stop recording that is not running"); } recording.stop(); return new OpenJdkRecordingData(recording); } OpenJdkOngoingRecordi... |
@Test public void delegates() throws IOException { Object object = new Object(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(server.url("/")) .addConverterFactory( new Converter.Factory() { @Nullable @Override public Converter<ResponseBody, ?> responseBodyConverter( Type type, Annotation[] annotations, Retrofit... | public static Java8OptionalConverterFactory create() { return new Java8OptionalConverterFactory(); } | Java8OptionalConverterFactory extends Converter.Factory { public static Java8OptionalConverterFactory create() { return new Java8OptionalConverterFactory(); } } | Java8OptionalConverterFactory extends Converter.Factory { public static Java8OptionalConverterFactory create() { return new Java8OptionalConverterFactory(); } private Java8OptionalConverterFactory(); } | Java8OptionalConverterFactory extends Converter.Factory { public static Java8OptionalConverterFactory create() { return new Java8OptionalConverterFactory(); } private Java8OptionalConverterFactory(); static Java8OptionalConverterFactory create(); @Override @Nullable Converter<ResponseBody, ?> responseBodyConverter(
... | Java8OptionalConverterFactory extends Converter.Factory { public static Java8OptionalConverterFactory create() { return new Java8OptionalConverterFactory(); } private Java8OptionalConverterFactory(); static Java8OptionalConverterFactory create(); @Override @Nullable Converter<ResponseBody, ?> responseBodyConverter(
... |
@Test public void varianceRestrictsRange() { try { behavior.setVariancePercent(-13); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("Variance percentage must be between 0 and 100."); } try { behavior.setVariancePercent(174); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessag... | public void setVariancePercent(int variancePercent) { checkPercentageValidity(variancePercent, "Variance percentage must be between 0 and 100."); this.variancePercent = variancePercent; } | NetworkBehavior { public void setVariancePercent(int variancePercent) { checkPercentageValidity(variancePercent, "Variance percentage must be between 0 and 100."); this.variancePercent = variancePercent; } } | NetworkBehavior { public void setVariancePercent(int variancePercent) { checkPercentageValidity(variancePercent, "Variance percentage must be between 0 and 100."); this.variancePercent = variancePercent; } private NetworkBehavior(Random random); } | NetworkBehavior { public void setVariancePercent(int variancePercent) { checkPercentageValidity(variancePercent, "Variance percentage must be between 0 and 100."); this.variancePercent = variancePercent; } private NetworkBehavior(Random random); static NetworkBehavior create(); @SuppressWarnings("ConstantConditions") ... | NetworkBehavior { public void setVariancePercent(int variancePercent) { checkPercentageValidity(variancePercent, "Variance percentage must be between 0 and 100."); this.variancePercent = variancePercent; } private NetworkBehavior(Random random); static NetworkBehavior create(); @SuppressWarnings("ConstantConditions") ... |
@Test public void failureRestrictsRange() { try { behavior.setFailurePercent(-13); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("Failure percentage must be between 0 and 100."); } try { behavior.setFailurePercent(174); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("F... | public void setFailurePercent(int failurePercent) { checkPercentageValidity(failurePercent, "Failure percentage must be between 0 and 100."); this.failurePercent = failurePercent; } | NetworkBehavior { public void setFailurePercent(int failurePercent) { checkPercentageValidity(failurePercent, "Failure percentage must be between 0 and 100."); this.failurePercent = failurePercent; } } | NetworkBehavior { public void setFailurePercent(int failurePercent) { checkPercentageValidity(failurePercent, "Failure percentage must be between 0 and 100."); this.failurePercent = failurePercent; } private NetworkBehavior(Random random); } | NetworkBehavior { public void setFailurePercent(int failurePercent) { checkPercentageValidity(failurePercent, "Failure percentage must be between 0 and 100."); this.failurePercent = failurePercent; } private NetworkBehavior(Random random); static NetworkBehavior create(); @SuppressWarnings("ConstantConditions") // Gua... | NetworkBehavior { public void setFailurePercent(int failurePercent) { checkPercentageValidity(failurePercent, "Failure percentage must be between 0 and 100."); this.failurePercent = failurePercent; } private NetworkBehavior(Random random); static NetworkBehavior create(); @SuppressWarnings("ConstantConditions") // Gua... |
@Test public void failureExceptionIsNotNull() { try { behavior.setFailureException(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("exception == null"); } } | @SuppressWarnings("ConstantConditions") public void setFailureException(Throwable exception) { if (exception == null) { throw new NullPointerException("exception == null"); } this.failureException = exception; } | NetworkBehavior { @SuppressWarnings("ConstantConditions") public void setFailureException(Throwable exception) { if (exception == null) { throw new NullPointerException("exception == null"); } this.failureException = exception; } } | NetworkBehavior { @SuppressWarnings("ConstantConditions") public void setFailureException(Throwable exception) { if (exception == null) { throw new NullPointerException("exception == null"); } this.failureException = exception; } private NetworkBehavior(Random random); } | NetworkBehavior { @SuppressWarnings("ConstantConditions") public void setFailureException(Throwable exception) { if (exception == null) { throw new NullPointerException("exception == null"); } this.failureException = exception; } private NetworkBehavior(Random random); static NetworkBehavior create(); @SuppressWarning... | NetworkBehavior { @SuppressWarnings("ConstantConditions") public void setFailureException(Throwable exception) { if (exception == null) { throw new NullPointerException("exception == null"); } this.failureException = exception; } private NetworkBehavior(Random random); static NetworkBehavior create(); @SuppressWarning... |
@Test public void errorRestrictsRange() { try { behavior.setErrorPercent(-13); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("Error percentage must be between 0 and 100."); } try { behavior.setErrorPercent(174); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("Error per... | public void setErrorPercent(int errorPercent) { checkPercentageValidity(errorPercent, "Error percentage must be between 0 and 100."); this.errorPercent = errorPercent; } | NetworkBehavior { public void setErrorPercent(int errorPercent) { checkPercentageValidity(errorPercent, "Error percentage must be between 0 and 100."); this.errorPercent = errorPercent; } } | NetworkBehavior { public void setErrorPercent(int errorPercent) { checkPercentageValidity(errorPercent, "Error percentage must be between 0 and 100."); this.errorPercent = errorPercent; } private NetworkBehavior(Random random); } | NetworkBehavior { public void setErrorPercent(int errorPercent) { checkPercentageValidity(errorPercent, "Error percentage must be between 0 and 100."); this.errorPercent = errorPercent; } private NetworkBehavior(Random random); static NetworkBehavior create(); @SuppressWarnings("ConstantConditions") // Guarding API nu... | NetworkBehavior { public void setErrorPercent(int errorPercent) { checkPercentageValidity(errorPercent, "Error percentage must be between 0 and 100."); this.errorPercent = errorPercent; } private NetworkBehavior(Random random); static NetworkBehavior create(); @SuppressWarnings("ConstantConditions") // Guarding API nu... |
@Test public void errorFactoryIsNotNull() { try { behavior.setErrorFactory(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("errorFactory == null"); } } | @SuppressWarnings("ConstantConditions") public void setErrorFactory(Callable<Response<?>> errorFactory) { if (errorFactory == null) { throw new NullPointerException("errorFactory == null"); } this.errorFactory = errorFactory; } | NetworkBehavior { @SuppressWarnings("ConstantConditions") public void setErrorFactory(Callable<Response<?>> errorFactory) { if (errorFactory == null) { throw new NullPointerException("errorFactory == null"); } this.errorFactory = errorFactory; } } | NetworkBehavior { @SuppressWarnings("ConstantConditions") public void setErrorFactory(Callable<Response<?>> errorFactory) { if (errorFactory == null) { throw new NullPointerException("errorFactory == null"); } this.errorFactory = errorFactory; } private NetworkBehavior(Random random); } | NetworkBehavior { @SuppressWarnings("ConstantConditions") public void setErrorFactory(Callable<Response<?>> errorFactory) { if (errorFactory == null) { throw new NullPointerException("errorFactory == null"); } this.errorFactory = errorFactory; } private NetworkBehavior(Random random); static NetworkBehavior create(); ... | NetworkBehavior { @SuppressWarnings("ConstantConditions") public void setErrorFactory(Callable<Response<?>> errorFactory) { if (errorFactory == null) { throw new NullPointerException("errorFactory == null"); } this.errorFactory = errorFactory; } private NetworkBehavior(Random random); static NetworkBehavior create(); ... |
@Test public void retrofitPropagated() { MockRetrofit mockRetrofit = new MockRetrofit.Builder(retrofit).build(); assertThat(mockRetrofit.retrofit()).isSameAs(retrofit); } | public Retrofit retrofit() { return retrofit; } | MockRetrofit { public Retrofit retrofit() { return retrofit; } } | MockRetrofit { public Retrofit retrofit() { return retrofit; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); } | MockRetrofit { public Retrofit retrofit() { return retrofit; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guarded by paramete... | MockRetrofit { public Retrofit retrofit() { return retrofit; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guarded by paramete... |
@Test public void networkBehaviorNullThrows() { MockRetrofit.Builder builder = new MockRetrofit.Builder(retrofit); try { builder.networkBehavior(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("behavior == null"); } } | public NetworkBehavior networkBehavior() { return behavior; } | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } } | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); } | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guard... | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guard... |
@Test public void networkBehaviorDefault() { MockRetrofit mockRetrofit = new MockRetrofit.Builder(retrofit).build(); assertThat(mockRetrofit.networkBehavior()).isNotNull(); } | public NetworkBehavior networkBehavior() { return behavior; } | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } } | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); } | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guard... | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guard... |
@Test public void networkBehaviorPropagated() { MockRetrofit mockRetrofit = new MockRetrofit.Builder(retrofit).networkBehavior(behavior).build(); assertThat(mockRetrofit.networkBehavior()).isSameAs(behavior); } | public NetworkBehavior networkBehavior() { return behavior; } | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } } | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); } | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guard... | MockRetrofit { public NetworkBehavior networkBehavior() { return behavior; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guard... |
@Test public void backgroundExecutorNullThrows() { MockRetrofit.Builder builder = new MockRetrofit.Builder(retrofit); try { builder.backgroundExecutor(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("executor == null"); } } | public Executor backgroundExecutor() { return executor; } | MockRetrofit { public Executor backgroundExecutor() { return executor; } } | MockRetrofit { public Executor backgroundExecutor() { return executor; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); } | MockRetrofit { public Executor backgroundExecutor() { return executor; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guarded b... | MockRetrofit { public Executor backgroundExecutor() { return executor; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guarded b... |
@Test public void rawResultTypeThrows() { Type observableType = new TypeToken<Observable<Result>>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage("Result must be parameterized as Result<Foo> or Result<? extends Foo>"); } ... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava3CallAdapter( Void.class, scheduler, isAsync, false, true, false, false, false, true); } boolean isFlowable = ... | RxJava3CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava3CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava3CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava3CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava3CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava3CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava3CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava3CallAdapter( Void.class, scheduler, isAsync, false, t... |
@Test public void backgroundExecutorDefault() { MockRetrofit mockRetrofit = new MockRetrofit.Builder(retrofit).build(); assertThat(mockRetrofit.backgroundExecutor()).isNotNull(); } | public Executor backgroundExecutor() { return executor; } | MockRetrofit { public Executor backgroundExecutor() { return executor; } } | MockRetrofit { public Executor backgroundExecutor() { return executor; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); } | MockRetrofit { public Executor backgroundExecutor() { return executor; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guarded b... | MockRetrofit { public Executor backgroundExecutor() { return executor; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guarded b... |
@Test public void backgroundExecutorPropagated() { MockRetrofit mockRetrofit = new MockRetrofit.Builder(retrofit).backgroundExecutor(executor).build(); assertThat(mockRetrofit.backgroundExecutor()).isSameAs(executor); } | public Executor backgroundExecutor() { return executor; } | MockRetrofit { public Executor backgroundExecutor() { return executor; } } | MockRetrofit { public Executor backgroundExecutor() { return executor; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); } | MockRetrofit { public Executor backgroundExecutor() { return executor; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guarded b... | MockRetrofit { public Executor backgroundExecutor() { return executor; } MockRetrofit(Retrofit retrofit, NetworkBehavior behavior, ExecutorService executor); Retrofit retrofit(); NetworkBehavior networkBehavior(); Executor backgroundExecutor(); @SuppressWarnings("unchecked") // Single-interface proxy creation guarded b... |
@Test public void bodyExecute() throws IOException { Call<String> taco = Calls.response("Taco"); assertEquals("Taco", taco.execute().body()); } | public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... |
@Test public void bodyEnqueue() throws IOException { Call<String> taco = Calls.response("Taco"); final AtomicReference<Response<String>> responseRef = new AtomicReference<>(); taco.enqueue( new Callback<String>() { @Override public void onResponse(Call<String> call, Response<String> response) { responseRef.set(response... | public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... |
@Test public void responseExecute() throws IOException { Response<String> response = Response.success("Taco"); Call<String> taco = Calls.response(response); assertFalse(taco.isExecuted()); assertSame(response, taco.execute()); assertTrue(taco.isExecuted()); try { taco.execute(); fail(); } catch (IllegalStateException e... | public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... |
@Test public void responseEnqueue() { Response<String> response = Response.success("Taco"); Call<String> taco = Calls.response(response); assertFalse(taco.isExecuted()); final AtomicReference<Response<String>> responseRef = new AtomicReference<>(); taco.enqueue( new Callback<String>() { @Override public void onResponse... | public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... |
@Test public void enqueueNullThrows() { Call<String> taco = Calls.response("Taco"); try { taco.enqueue(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("callback == null"); } } | public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... |
@Test public void responseCancelExecute() { Call<String> taco = Calls.response(Response.success("Taco")); assertFalse(taco.isCanceled()); taco.cancel(); assertTrue(taco.isCanceled()); try { taco.execute(); fail(); } catch (IOException e) { assertThat(e).hasMessage("canceled"); } } | public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... |
@Test public void responseCancelEnqueue() throws IOException { Call<String> taco = Calls.response(Response.success("Taco")); assertFalse(taco.isCanceled()); taco.cancel(); assertTrue(taco.isCanceled()); final AtomicReference<Throwable> failureRef = new AtomicReference<>(); taco.enqueue( new Callback<String>() { @Overri... | public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... |
@Test public void failureExecute() { IOException failure = new IOException("Hey"); Call<Object> taco = Calls.failure(failure); assertFalse(taco.isExecuted()); try { taco.execute(); fail(); } catch (IOException e) { assertSame(failure, e); } assertTrue(taco.isExecuted()); } | public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); stat... | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); stat... |
@Test public void response() { Response<String> response = Response.success("Hi"); Result<String> result = Result.response(response); assertThat(result.isError()).isFalse(); assertThat(result.error()).isNull(); assertThat(result.response()).isSameAs(response); } | @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("Co... | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("Co... |
@Test public void failureExecuteCheckedException() { CertificateException failure = new CertificateException("Hey"); Call<Object> taco = Calls.failure(failure); assertFalse(taco.isExecuted()); try { taco.execute(); fail(); } catch (Exception e) { assertSame(failure, e); } assertTrue(taco.isExecuted()); } | public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); stat... | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); stat... |
@Test public void failureEnqueue() { IOException failure = new IOException("Hey"); Call<Object> taco = Calls.failure(failure); assertFalse(taco.isExecuted()); final AtomicReference<Throwable> failureRef = new AtomicReference<>(); taco.enqueue( new Callback<Object>() { @Override public void onResponse(Call<Object> call,... | public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); stat... | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); stat... |
@Test public void cloneHasOwnState() throws IOException { Call<String> taco = Calls.response("Taco"); assertEquals("Taco", taco.execute().body()); Call<String> anotherTaco = taco.clone(); assertFalse(anotherTaco.isExecuted()); assertEquals("Taco", anotherTaco.execute().body()); assertTrue(anotherTaco.isExecuted()); } | public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); } | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... | Calls { public static <T> Call<T> response(@Nullable T successValue) { return new FakeCall<>(Response.success(successValue), null); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failu... |
@Test public void deferredThrowExecute() throws IOException { final IOException failure = new IOException("Hey"); Call<Object> failing = Calls.defer( () -> { throw failure; }); try { failing.execute(); fail(); } catch (IOException e) { assertSame(failure, e); } } | public static <T> Call<T> defer(Callable<Call<T>> callable) { return new DeferredCall<>(callable); } | Calls { public static <T> Call<T> defer(Callable<Call<T>> callable) { return new DeferredCall<>(callable); } } | Calls { public static <T> Call<T> defer(Callable<Call<T>> callable) { return new DeferredCall<>(callable); } private Calls(); } | Calls { public static <T> Call<T> defer(Callable<Call<T>> callable) { return new DeferredCall<>(callable); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); ... | Calls { public static <T> Call<T> defer(Callable<Call<T>> callable) { return new DeferredCall<>(callable); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); ... |
@Test public void deferredThrowEnqueue() { final IOException failure = new IOException("Hey"); Call<Object> failing = Calls.defer( () -> { throw failure; }); final AtomicReference<Throwable> failureRef = new AtomicReference<>(); failing.enqueue( new Callback<Object>() { @Override public void onResponse(Call<Object> cal... | public static <T> Call<T> defer(Callable<Call<T>> callable) { return new DeferredCall<>(callable); } | Calls { public static <T> Call<T> defer(Callable<Call<T>> callable) { return new DeferredCall<>(callable); } } | Calls { public static <T> Call<T> defer(Callable<Call<T>> callable) { return new DeferredCall<>(callable); } private Calls(); } | Calls { public static <T> Call<T> defer(Callable<Call<T>> callable) { return new DeferredCall<>(callable); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); ... | Calls { public static <T> Call<T> defer(Callable<Call<T>> callable) { return new DeferredCall<>(callable); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); ... |
@Test public void deferredThrowUncheckedExceptionEnqueue() { final RuntimeException failure = new RuntimeException("Hey"); final AtomicReference<Throwable> failureRef = new AtomicReference<>(); Calls.failure(failure) .enqueue( new Callback<Object>() { @Override public void onResponse(Call<Object> call, Response<Object>... | public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); } | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); stat... | Calls { public static <T> Call<T> failure(IOException failure) { return new FakeCall<>(null, failure); } private Calls(); static Call<T> defer(Callable<Call<T>> callable); static Call<T> response(@Nullable T successValue); static Call<T> response(Response<T> response); static Call<T> failure(IOException failure); stat... |
@Test public void nullResponseThrows() { try { Result.response(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("response == null"); } } | @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("Co... | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("Co... |
@Test public void error() { Throwable error = new IOException(); Result<Object> result = Result.error(error); assertThat(result.isError()).isTrue(); assertThat(result.error()).isSameAs(error); assertThat(result.response()).isNull(); } | @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("ConstantConditions"... | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("ConstantConditions"... |
@Test public void nullErrorThrows() { try { Result.error(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("error == null"); } } | @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("ConstantConditions"... | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("ConstantConditions"... |
@Test public void nullSchedulerThrows() { try { RxJava2CallAdapterFactory.createWithScheduler(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("scheduler == null"); } } | @SuppressWarnings("ConstantConditions") public static RxJava2CallAdapterFactory createWithScheduler(Scheduler scheduler) { if (scheduler == null) throw new NullPointerException("scheduler == null"); return new RxJava2CallAdapterFactory(scheduler, false); } | RxJava2CallAdapterFactory extends CallAdapter.Factory { @SuppressWarnings("ConstantConditions") public static RxJava2CallAdapterFactory createWithScheduler(Scheduler scheduler) { if (scheduler == null) throw new NullPointerException("scheduler == null"); return new RxJava2CallAdapterFactory(scheduler, false); } } | RxJava2CallAdapterFactory extends CallAdapter.Factory { @SuppressWarnings("ConstantConditions") public static RxJava2CallAdapterFactory createWithScheduler(Scheduler scheduler) { if (scheduler == null) throw new NullPointerException("scheduler == null"); return new RxJava2CallAdapterFactory(scheduler, false); } private... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @SuppressWarnings("ConstantConditions") public static RxJava2CallAdapterFactory createWithScheduler(Scheduler scheduler) { if (scheduler == null) throw new NullPointerException("scheduler == null"); return new RxJava2CallAdapterFactory(scheduler, false); } private... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @SuppressWarnings("ConstantConditions") public static RxJava2CallAdapterFactory createWithScheduler(Scheduler scheduler) { if (scheduler == null) throw new NullPointerException("scheduler == null"); return new RxJava2CallAdapterFactory(scheduler, false); } private... |
@Test public void userSuppliedJaxbContext() throws Exception { JAXBContext context = JAXBContext.newInstance(Contact.class); JaxbConverterFactory factory = JaxbConverterFactory.create(context); Retrofit retrofit = new Retrofit.Builder().baseUrl(server.url("/")).addConverterFactory(factory).build(); service = retrofit.c... | public static JaxbConverterFactory create() { return new JaxbConverterFactory(null); } | JaxbConverterFactory extends Converter.Factory { public static JaxbConverterFactory create() { return new JaxbConverterFactory(null); } } | JaxbConverterFactory extends Converter.Factory { public static JaxbConverterFactory create() { return new JaxbConverterFactory(null); } private JaxbConverterFactory(@Nullable JAXBContext context); } | JaxbConverterFactory extends Converter.Factory { public static JaxbConverterFactory create() { return new JaxbConverterFactory(null); } private JaxbConverterFactory(@Nullable JAXBContext context); static JaxbConverterFactory create(); @SuppressWarnings("ConstantConditions") // Guarding API nullability. static JaxbConv... | JaxbConverterFactory extends Converter.Factory { public static JaxbConverterFactory create() { return new JaxbConverterFactory(null); } private JaxbConverterFactory(@Nullable JAXBContext context); static JaxbConverterFactory create(); @SuppressWarnings("ConstantConditions") // Guarding API nullability. static JaxbConv... |
@Test public void nonRxJavaTypeReturnsNull() { CallAdapter<?, ?> adapter = factory.get(String.class, NO_ANNOTATIONS, retrofit); assertThat(adapter).isNull(); } | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, true, false, false, false, true); } boolean isFlowable = ... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... |
@Test public void responseTypes() { Type oBodyClass = new TypeToken<Observable<String>>() {}.getType(); assertThat(factory.get(oBodyClass, NO_ANNOTATIONS, retrofit).responseType()) .isEqualTo(String.class); Type sBodyClass = new TypeToken<Single<String>>() {}.getType(); assertThat(factory.get(sBodyClass, NO_ANNOTATIONS... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, true, false, false, false, true); } boolean isFlowable = ... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... |
@Test public void rawBodyTypeThrows() { Type observableType = new TypeToken<Observable>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage( "Observable return type must be parameterized as Observable<Foo> or Observable<? ext... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, true, false, false, false, true); } boolean isFlowable = ... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... |
@Test public void rawResponseTypeThrows() { Type observableType = new TypeToken<Observable<Response>>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage("Response must be parameterized as Response<Foo> or Response<? extends ... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, true, false, false, false, true); } boolean isFlowable = ... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... |
@Test public void rawResultTypeThrows() { Type observableType = new TypeToken<Observable<Result>>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage("Result must be parameterized as Result<Foo> or Result<? extends Foo>"); } ... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, true, false, false, false, true); } boolean isFlowable = ... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... | RxJava2CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); if (rawType == Completable.class) { return new RxJava2CallAdapter( Void.class, scheduler, isAsync, false, t... |
@Test public void responseType() { Type bodyClass = new TypeToken<Future<String>>() {}.getType(); assertThat(factory.get(bodyClass, NO_ANNOTATIONS, retrofit).responseType()) .isEqualTo(String.class); Type bodyWildcard = new TypeToken<Future<? extends String>>() {}.getType(); assertThat(factory.get(bodyWildcard, NO_ANNO... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future return type must be parameterized as Future<Foo> or Fu... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... |
@Test public void nonListenableFutureReturnsNull() { CallAdapter<?, ?> adapter = factory.get(String.class, NO_ANNOTATIONS, retrofit); assertThat(adapter).isNull(); } | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future return type must be parameterized as Future<Foo> or Fu... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... |
@Test public void rawTypeThrows() { Type observableType = new TypeToken<Future>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage( "Future return type must be parameterized as Future<Foo> or Future<? extends Foo>"); } } | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future return type must be parameterized as Future<Foo> or Fu... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... |
@Test public void rawResponseTypeThrows() { Type observableType = new TypeToken<Future<Response>>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage("Response must be parameterized as Response<Foo> or Response<? extends Foo>... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future return type must be parameterized as Future<Foo> or Fu... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... | ScalaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Future.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "Future ... |
@Test public void responseType() { Type bodyClass = new TypeToken<CompletableFuture<String>>() {}.getType(); assertThat(factory.get(bodyClass, NO_ANNOTATIONS, retrofit).responseType()) .isEqualTo(String.class); Type bodyWildcard = new TypeToken<CompletableFuture<? extends String>>() {}.getType(); assertThat(factory.get... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "CompletableFuture return type must be parameterize... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... |
@Test public void asLenient() throws IOException, InterruptedException { MockResponse malformedResponse = new MockResponse().setBody("{\"theName\":value}"); server.enqueue(malformedResponse); server.enqueue(malformedResponse); Call<AnImplementation> call = service.anImplementation(new AnImplementation("value")); try { ... | public MoshiConverterFactory asLenient() { return new MoshiConverterFactory(moshi, true, failOnUnknown, serializeNulls); } | MoshiConverterFactory extends Converter.Factory { public MoshiConverterFactory asLenient() { return new MoshiConverterFactory(moshi, true, failOnUnknown, serializeNulls); } } | MoshiConverterFactory extends Converter.Factory { public MoshiConverterFactory asLenient() { return new MoshiConverterFactory(moshi, true, failOnUnknown, serializeNulls); } private MoshiConverterFactory(
Moshi moshi, boolean lenient, boolean failOnUnknown, boolean serializeNulls); } | MoshiConverterFactory extends Converter.Factory { public MoshiConverterFactory asLenient() { return new MoshiConverterFactory(moshi, true, failOnUnknown, serializeNulls); } private MoshiConverterFactory(
Moshi moshi, boolean lenient, boolean failOnUnknown, boolean serializeNulls); static MoshiConverterFactory cr... | MoshiConverterFactory extends Converter.Factory { public MoshiConverterFactory asLenient() { return new MoshiConverterFactory(moshi, true, failOnUnknown, serializeNulls); } private MoshiConverterFactory(
Moshi moshi, boolean lenient, boolean failOnUnknown, boolean serializeNulls); static MoshiConverterFactory cr... |
@Test public void nonListenableFutureReturnsNull() { CallAdapter<?, ?> adapter = factory.get(String.class, NO_ANNOTATIONS, retrofit); assertThat(adapter).isNull(); } | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "CompletableFuture return type must be parameterize... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... |
@Test public void rawTypeThrows() { Type observableType = new TypeToken<CompletableFuture>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage( "CompletableFuture return type must be parameterized as CompletableFuture<Foo> or... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "CompletableFuture return type must be parameterize... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... |
@Test public void rawResponseTypeThrows() { Type observableType = new TypeToken<CompletableFuture<Response>>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage("Response must be parameterized as Response<Foo> or Response<? e... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "CompletableFuture return type must be parameterize... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... | Java8CallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateExceptio... |
@Test public void nullSchedulerThrows() { try { RxJavaCallAdapterFactory.createWithScheduler(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("scheduler == null"); } } | @SuppressWarnings("ConstantConditions") public static RxJavaCallAdapterFactory createWithScheduler(Scheduler scheduler) { if (scheduler == null) throw new NullPointerException("scheduler == null"); return new RxJavaCallAdapterFactory(scheduler, false); } | RxJavaCallAdapterFactory extends CallAdapter.Factory { @SuppressWarnings("ConstantConditions") public static RxJavaCallAdapterFactory createWithScheduler(Scheduler scheduler) { if (scheduler == null) throw new NullPointerException("scheduler == null"); return new RxJavaCallAdapterFactory(scheduler, false); } } | RxJavaCallAdapterFactory extends CallAdapter.Factory { @SuppressWarnings("ConstantConditions") public static RxJavaCallAdapterFactory createWithScheduler(Scheduler scheduler) { if (scheduler == null) throw new NullPointerException("scheduler == null"); return new RxJavaCallAdapterFactory(scheduler, false); } private R... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @SuppressWarnings("ConstantConditions") public static RxJavaCallAdapterFactory createWithScheduler(Scheduler scheduler) { if (scheduler == null) throw new NullPointerException("scheduler == null"); return new RxJavaCallAdapterFactory(scheduler, false); } private R... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @SuppressWarnings("ConstantConditions") public static RxJavaCallAdapterFactory createWithScheduler(Scheduler scheduler) { if (scheduler == null) throw new NullPointerException("scheduler == null"); return new RxJavaCallAdapterFactory(scheduler, false); } private R... |
@Test public void nonRxJavaTypeReturnsNull() { CallAdapter<?, ?> adapter = factory.get(String.class, NO_ANNOTATIONS, retrofit); assertThat(adapter).isNull(); } | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawType != Observable.class && !isSingle && !isCompletable) {... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... |
@Test public void responseTypes() { Type oBodyClass = new TypeToken<Observable<String>>() {}.getType(); assertThat(factory.get(oBodyClass, NO_ANNOTATIONS, retrofit).responseType()) .isEqualTo(String.class); Type sBodyClass = new TypeToken<Single<String>>() {}.getType(); assertThat(factory.get(sBodyClass, NO_ANNOTATIONS... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawType != Observable.class && !isSingle && !isCompletable) {... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... |
@Test public void rawBodyTypeThrows() { Type observableType = new TypeToken<Observable>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage( "Observable return type must be parameterized as Observable<Foo> or Observable<? ext... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawType != Observable.class && !isSingle && !isCompletable) {... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... |
@Test public void rawResponseTypeThrows() { Type observableType = new TypeToken<Observable<Response>>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage("Response must be parameterized as Response<Foo> or Response<? extends ... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawType != Observable.class && !isSingle && !isCompletable) {... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... |
@Test public void rawResultTypeThrows() { Type observableType = new TypeToken<Observable<Result>>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage("Result must be parameterized as Result<Foo> or Result<? extends Foo>"); } ... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawType != Observable.class && !isSingle && !isCompletable) {... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... | RxJavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> rawType = getRawType(returnType); boolean isSingle = rawType == Single.class; boolean isCompletable = rawType == Completable.class; if (rawTyp... |
@Test public void response() { Response<String> response = Response.success("Hi"); Result<String> result = Result.response(response); assertThat(result.isError()).isFalse(); assertThat(result.error()).isNull(); assertThat(result.response()).isSameAs(response); } | @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("Co... | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("Co... |
@Test public void failOnUnknown() throws IOException, InterruptedException { server.enqueue(new MockResponse().setBody("{\"taco\":\"delicious\"}")); Call<AnImplementation> call = serviceFailOnUnknown.anImplementation(new AnImplementation(null)); try { call.execute(); fail(); } catch (JsonDataException e) { assertThat(e... | public MoshiConverterFactory failOnUnknown() { return new MoshiConverterFactory(moshi, lenient, true, serializeNulls); } | MoshiConverterFactory extends Converter.Factory { public MoshiConverterFactory failOnUnknown() { return new MoshiConverterFactory(moshi, lenient, true, serializeNulls); } } | MoshiConverterFactory extends Converter.Factory { public MoshiConverterFactory failOnUnknown() { return new MoshiConverterFactory(moshi, lenient, true, serializeNulls); } private MoshiConverterFactory(
Moshi moshi, boolean lenient, boolean failOnUnknown, boolean serializeNulls); } | MoshiConverterFactory extends Converter.Factory { public MoshiConverterFactory failOnUnknown() { return new MoshiConverterFactory(moshi, lenient, true, serializeNulls); } private MoshiConverterFactory(
Moshi moshi, boolean lenient, boolean failOnUnknown, boolean serializeNulls); static MoshiConverterFactory crea... | MoshiConverterFactory extends Converter.Factory { public MoshiConverterFactory failOnUnknown() { return new MoshiConverterFactory(moshi, lenient, true, serializeNulls); } private MoshiConverterFactory(
Moshi moshi, boolean lenient, boolean failOnUnknown, boolean serializeNulls); static MoshiConverterFactory crea... |
@Test public void nullResponseThrows() { try { Result.response(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("response == null"); } } | @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("Co... | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> response(Response<T> response) { if (response == null) throw new NullPointerException("response == null"); return new Result<>(response, null); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("Co... |
@Test public void error() { Throwable error = new IOException(); Result<Object> result = Result.error(error); assertThat(result.isError()).isTrue(); assertThat(result.error()).isSameAs(error); assertThat(result.response()).isNull(); } | @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("ConstantConditions"... | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("ConstantConditions"... |
@Test public void nullErrorThrows() { try { Result.error(null); fail(); } catch (NullPointerException e) { assertThat(e).hasMessage("error == null"); } } | @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); } | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("ConstantConditions"... | Result { @SuppressWarnings("ConstantConditions") public static <T> Result<T> error(Throwable error) { if (error == null) throw new NullPointerException("error == null"); return new Result<>(null, error); } private Result(@Nullable Response<T> response, @Nullable Throwable error); @SuppressWarnings("ConstantConditions"... |
@Test public void responseType() { Type bodyClass = new TypeToken<ListenableFuture<String>>() {}.getType(); assertThat(factory.get(bodyClass, NO_ANNOTATIONS, retrofit).responseType()) .isEqualTo(String.class); Type bodyWildcard = new TypeToken<ListenableFuture<? extends String>>() {}.getType(); assertThat(factory.get(b... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "ListenableFuture return type must be parameterized"... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... |
@Test public void nonListenableFutureReturnsNull() { CallAdapter<?, ?> adapter = factory.get(String.class, NO_ANNOTATIONS, retrofit); assertThat(adapter).isNull(); } | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "ListenableFuture return type must be parameterized"... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... |
@Test public void rawTypeThrows() { Type observableType = new TypeToken<ListenableFuture>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage( "ListenableFuture return type must be parameterized as ListenableFuture<Foo> or Li... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "ListenableFuture return type must be parameterized"... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... |
@Test public void rawResponseTypeThrows() { Type observableType = new TypeToken<ListenableFuture<Response>>() {}.getType(); try { factory.get(observableType, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalStateException e) { assertThat(e) .hasMessage("Response must be parameterized as Response<Foo> or Response<? ex... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException( "ListenableFuture return type must be parameterized"... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... | GuavaCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != ListenableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException... |
@Test public void rawTypeThrows() { try { factory.get(Call.class, NO_ANNOTATIONS, retrofit); fail(); } catch (IllegalArgumentException e) { assertThat(e) .hasMessage("Call return type must be parameterized as Call<Foo> or Call<? extends Foo>"); } } | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call return type must be parameterized as Call<Foo> or Call<... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... |
@Test public void responseType() { Type classType = new TypeToken<Call<String>>() {}.getType(); assertThat(factory.get(classType, NO_ANNOTATIONS, retrofit).responseType()) .isEqualTo(String.class); Type wilcardType = new TypeToken<Call<? extends String>>() {}.getType(); assertThat(factory.get(wilcardType, NO_ANNOTATION... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call return type must be parameterized as Call<Foo> or Call<... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... |
@Test public void adaptedCallExecute() throws IOException { Type returnType = new TypeToken<Call<String>>() {}.getType(); CallAdapter<String, Call<String>> adapter = (CallAdapter<String, Call<String>>) factory.get(returnType, NO_ANNOTATIONS, retrofit); final Response<String> response = Response.success("Hi"); Call<Stri... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call return type must be parameterized as Call<Foo> or Call<... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... |
@Test public void delegates() throws IOException { final Object object = new Object(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(server.url("/")) .addConverterFactory( new Converter.Factory() { @Nullable @Override public Converter<ResponseBody, Object> responseBodyConverter( Type type, Annotation[] annotation... | public static GuavaOptionalConverterFactory create() { return new GuavaOptionalConverterFactory(); } | GuavaOptionalConverterFactory extends Converter.Factory { public static GuavaOptionalConverterFactory create() { return new GuavaOptionalConverterFactory(); } } | GuavaOptionalConverterFactory extends Converter.Factory { public static GuavaOptionalConverterFactory create() { return new GuavaOptionalConverterFactory(); } private GuavaOptionalConverterFactory(); } | GuavaOptionalConverterFactory extends Converter.Factory { public static GuavaOptionalConverterFactory create() { return new GuavaOptionalConverterFactory(); } private GuavaOptionalConverterFactory(); static GuavaOptionalConverterFactory create(); @Override @Nullable Converter<ResponseBody, ?> responseBodyConverter(
... | GuavaOptionalConverterFactory extends Converter.Factory { public static GuavaOptionalConverterFactory create() { return new GuavaOptionalConverterFactory(); } private GuavaOptionalConverterFactory(); static GuavaOptionalConverterFactory create(); @Override @Nullable Converter<ResponseBody, ?> responseBodyConverter(
... |
@Test public void adaptedCallCloneDeepCopy() { Type returnType = new TypeToken<Call<String>>() {}.getType(); CallAdapter<String, Call<String>> adapter = (CallAdapter<String, Call<String>>) factory.get(returnType, NO_ANNOTATIONS, retrofit); final AtomicBoolean cloned = new AtomicBoolean(); Call<String> delegate = new Em... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call return type must be parameterized as Call<Foo> or Call<... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... |
@Test public void adaptedCallCancel() { Type returnType = new TypeToken<Call<String>>() {}.getType(); CallAdapter<String, Call<String>> adapter = (CallAdapter<String, Call<String>>) factory.get(returnType, NO_ANNOTATIONS, retrofit); final AtomicBoolean canceled = new AtomicBoolean(); Call<String> delegate = new EmptyCa... | @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call return type must be parameterized as Call<Foo> or Call<... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... | DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public @Nullable CallAdapter<?, ?> get( Type returnType, Annotation[] annotations, Retrofit retrofit) { if (getRawType(returnType) != Call.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalArgumentException( "Call... |
@Test public void success() { Object body = new Object(); Response<Object> response = Response.success(body); assertThat(response.raw()).isNotNull(); assertThat(response.code()).isEqualTo(200); assertThat(response.message()).isEqualTo("OK"); assertThat(response.headers().size()).isZero(); assertThat(response.isSuccessf... | public static <T> Response<T> success(@Nullable T body) { return success( body, new okhttp3.Response.Builder() .code(200) .message("OK") .protocol(Protocol.HTTP_1_1) .request(new Request.Builder().url("http: .build()); } | Response { public static <T> Response<T> success(@Nullable T body) { return success( body, new okhttp3.Response.Builder() .code(200) .message("OK") .protocol(Protocol.HTTP_1_1) .request(new Request.Builder().url("http: .build()); } } | Response { public static <T> Response<T> success(@Nullable T body) { return success( body, new okhttp3.Response.Builder() .code(200) .message("OK") .protocol(Protocol.HTTP_1_1) .request(new Request.Builder().url("http: .build()); } private Response(
okhttp3.Response rawResponse, @Nullable T body, @Nullable Respo... | Response { public static <T> Response<T> success(@Nullable T body) { return success( body, new okhttp3.Response.Builder() .code(200) .message("OK") .protocol(Protocol.HTTP_1_1) .request(new Request.Builder().url("http: .build()); } private Response(
okhttp3.Response rawResponse, @Nullable T body, @Nullable Respo... | Response { public static <T> Response<T> success(@Nullable T body) { return success( body, new okhttp3.Response.Builder() .code(200) .message("OK") .protocol(Protocol.HTTP_1_1) .request(new Request.Builder().url("http: .build()); } private Response(
okhttp3.Response rawResponse, @Nullable T body, @Nullable Respo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.