### Question:
SnapshotTransferService { public void push(Stream stream, RemoteRepository repo, String remoteStreamName, boolean createRemoteIfNecessary) { try { SshConnection process = sshService.receiveSnapshots(repo, remoteStreamName, createRemoteIfNecessary); InputStream input = process.getInputStream(); OutputStream output = process.getOutputStream(); log.debug("wait for ready"); Util.waitFor(READY_INDICATOR, input); log.debug("send start"); Util.send(START_COMMAND, output); log.debug("read available snapshots"); StreamState targetState = Util.read(StreamState.class, input); log.debug("Send missing snapshots. Target State " + targetState); sendMissingSnapshots(stream, targetState, output); process.close(); } catch (DisplayException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }  void receiveSnapshots(StreamRepository repo, String streamName,
            InputStream input, OutputStream output,
            boolean createStreamIfNecessary); void sendSnapshots(StreamRepository repo, String streamName,
            InputStream input, OutputStream output); void push(Stream stream, RemoteRepository repo,
            String remoteStreamName, boolean createRemoteIfNecessary); void pull(StreamRepository localRepo, String localStreamName,
            RemoteRepository remoteRepo, String remoteStreamName,
            boolean createStreamIfNecessary); static final String READY_INDICATOR; static final String START_COMMAND; }### Answer:
@Test public void transferSnapshotPush() throws Exception { Stream stream = streamService.createStream(repo1, "test"); Stream targetStream = streamService.createStream(repo2, "test2"); Path testFile = repo1.getWorkingDirectory(stream).resolve("test.txt"); Files.copy(new ByteArrayInputStream("Hello".getBytes("UTF-8")), testFile); Snapshot snapshot = streamService.takeSnapshot(stream); transferService.push(stream, null, "test2", false); assertThat(targetStream, not(nullValue())); Path snapshotDir = targetStream.getSnapshotsDir().resolve( snapshot.getSnapshotName()); assertThat(Files.exists(snapshotDir), is(true)); assertThat(Files.exists(snapshotDir.resolve("test.txt")), is(true)); assertEquals(stream.id, streamService.getSnapshots(targetStream).get(0).senderStreamId); }
@Test public void transferSnapshotCreateStream() throws Exception { Stream stream = streamService.createStream(repo1, "test"); transferService.push(stream, null, "test2", true); Stream targetStream = streamService.tryReadStream(repo2, "test2"); assertThat(targetStream, not(nullValue())); }
@Test(expected = DisplayException.class) public void transferSnapshotVersionConflict() throws Exception { Stream stream = streamService.createStream(repo1, "test"); streamService.takeSnapshot(stream); transferService.push(stream, null, "test2", true); stream.versionHistory.getLastEntry().streamId = UUID.randomUUID(); transferService.push(stream, null, "test2", false); }