### Question:
BreakpointInterceptor implements Interceptor.Connect, Interceptor.Fetch { @NonNull @Override public DownloadConnection.Connected interceptConnect(DownloadChain chain) throws IOException { final DownloadConnection.Connected connected = chain.processConnect(); final BreakpointInfo info = chain.getInfo(); if (chain.getCache().isInterrupt()) { throw InterruptException.SIGNAL; } if (info.getBlockCount() == 1 && !info.isChunked()) { final long blockInstanceLength = getExactContentLengthRangeFrom0(connected); final long infoInstanceLength = info.getTotalLength(); if (blockInstanceLength > 0 && blockInstanceLength != infoInstanceLength) { Util.d(TAG, "SingleBlock special check: the response instance-length[" + blockInstanceLength + "] isn't equal to the instance length from trial-" + "connection[" + infoInstanceLength + "]"); final BlockInfo blockInfo = info.getBlock(0); boolean isFromBreakpoint = blockInfo.getRangeLeft() != 0; final BlockInfo newBlockInfo = new BlockInfo(0, blockInstanceLength); info.resetBlockInfos(); info.addBlock(newBlockInfo); if (isFromBreakpoint) { final String msg = "Discard breakpoint because of on this special case, we have" + " to download from beginning"; Util.w(TAG, msg); throw new RetryException(msg); } OkDownload.with().callbackDispatcher().dispatch() .downloadFromBeginning(chain.getTask(), info, CONTENT_LENGTH_CHANGED); } } final DownloadStore store = chain.getDownloadStore(); try { if (!store.update(info)) { throw new IOException("Update store failed!"); } } catch (Exception e) { throw new IOException("Update store failed!", e); } return connected; }  @NonNull @Override DownloadConnection.Connected interceptConnect(DownloadChain chain); @Override long interceptFetch(DownloadChain chain);  }### Answer:
@Test public void interceptConnect_process() throws IOException { when(store.update(any(BreakpointInfo.class))).thenReturn(true); interceptor.interceptConnect(chain); verify(store).update(chain.getInfo()); verify(chain).processConnect(); }
@Test public void interceptConnect_notSingleBlockOrChunked() throws IOException { when(chain.processConnect()).thenReturn(connected); when(chain.getInfo()).thenReturn(info); when(chain.getCache()).thenReturn(cache); when(info.getBlockCount()).thenReturn(2); when(info.isChunked()).thenReturn(false); interceptor.interceptConnect(chain); verify(info, never()).resetBlockInfos(); verify(info, never()).addBlock(any(BlockInfo.class)); when(info.getBlockCount()).thenReturn(1); when(info.isChunked()).thenReturn(true); interceptor.interceptConnect(chain); verify(info, never()).resetBlockInfos(); verify(info, never()).addBlock(any(BlockInfo.class)); }