@@ -0,0 +1,2092 @@
+package net.yeputons.spbau.spring2016.torrent.client;%0A%0Aimport net.yeputons.spbau.spring2016.torrent.FileDescription;%0Aimport net.yeputons.spbau.spring2016.torrent.TorrentConnection;%0Aimport net.yeputons.spbau.spring2016.torrent.protocol.FileEntry;%0Aimport net.yeputons.spbau.spring2016.torrent.protocol.UpdateRequest;%0Aimport org.junit.Before;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.TemporaryFolder;%0A%0Aimport java.io.IOException;%0Aimport java.util.Arrays;%0Aimport java.util.concurrent.Semaphore;%0A%0Aimport static org.mockito.Mockito.*;%0A%0Apublic class TorrentSeederTest %7B%0A    private static final FileDescription FILE = new FileDescription(new FileEntry(1, %22file1.txt%22, 100), 35);%0A    private static final FileDescription FILE2 = new FileDescription(new FileEntry(2, %22file2.txt%22, 50), 35);%0A%0A    @Rule%0A    public TemporaryFolder folder = new TemporaryFolder();%0A%0A    private ClientState state;%0A%0A    @Before%0A    public void initState() %7B%0A        state = new ClientState(folder.getRoot().toPath());%0A        state.getFiles().put(1, FILE);%0A    %7D%0A%0A    @Test%0A    public void testUpdateTracker() throws IOException, InterruptedException %7B%0A        TorrentConnection tracker = mock(TorrentConnection.class);%0A        // CHECKSTYLE.OFF: MagicNumber%0A        TorrentSeeder seeder = new TorrentSeeder(tracker, state, 100);%0A        // CHECKSTYLE.ON: MagicNumber%0A        seeder.start();%0A%0A        Semaphore waitingForRequest = new Semaphore(1);%0A        waitingForRequest.acquire();%0A%0A        when(tracker.makeRequest(new UpdateRequest(anyInt(), Arrays.asList(1)))).thenAnswer((r) -%3E %7B%0A            waitingForRequest.release();%0A            return true;%0A        %7D);%0A        waitingForRequest.acquire();%0A        waitingForRequest.acquire();%0A%0A        state.getFiles().put(2, FILE2);%0A        when(tracker.makeRequest(new UpdateRequest(anyInt(), Arrays.asList(1, 2)))).thenAnswer((r) -%3E %7B%0A            waitingForRequest.release();%0A            return true;%0A        %7D);%0A        waitingForRequest.acquire();%0A        waitingForRequest.acquire();%0A%0A        seeder.shutdown();%0A        seeder.join();%0A    %7D%0A%7D%0A

Add TorrentSeederTest, tests for updateTracker only yet