@Test public void testDiffSaveAndPush() throws GitAPIException, IOException{ ArrayList<SequencerCollectorPatch> emptyList = new ArrayList<SequencerCollectorPatch>(); ArrayList<SequencerCollectorHunk> mockHunkList = new ArrayList<SequencerCollectorHunk>(); mockHunkList.add( new SequencerCollectorHunk(1, "file.java", "hunk1")); Mockito.when(github.getRepository(Mockito.anyString())).thenReturn(mockRepo); Mockito.when(mockRepo.getCommit(Mockito.anyString())).thenReturn(mockCommit); Mockito.when(filter.getCommitPatches(Mockito.any(GHCommit.class), Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(emptyList); Mockito.when(filter.getHunks(Mockito.any(ArrayList.class), Mockito.anyBoolean(), Mockito.anyInt())).thenReturn(mockHunkList); Mockito.doNothing().when(collector).saveFileDiff(Mockito.anyString(), Mockito.anyString()); }
protected void saveFileDiff(String slug, String sha) throws IOException { System.out.println("saving file..."); URL url = new URL("https", "github.com", "/" + slug + "/commit/" + sha + ".diff"); ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream()); File f = new File(diffsPath + "/" + slug.replace("/", "-") + "-" + sha + "/commit.diff"); f.createNewFile(); FileOutputStream fileOutputStream = new FileOutputStream(f, false); fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE); fileOutputStream.close(); }
SequencerCollector { protected void saveFileDiff(String slug, String sha) throws IOException { System.out.println("saving file..."); URL url = new URL("https", "github.com", "/" + slug + "/commit/" + sha + ".diff"); ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream()); File f = new File(diffsPath + "/" + slug.replace("/", "-") + "-" + sha + "/commit.diff"); f.createNewFile(); FileOutputStream fileOutputStream = new FileOutputStream(f, false); fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE); fileOutputStream.close(); } }
SequencerCollector { protected void saveFileDiff(String slug, String sha) throws IOException { System.out.println("saving file..."); URL url = new URL("https", "github.com", "/" + slug + "/commit/" + sha + ".diff"); ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream()); File f = new File(diffsPath + "/" + slug.replace("/", "-") + "-" + sha + "/commit.diff"); f.createNewFile(); FileOutputStream fileOutputStream = new FileOutputStream(f, false); fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE); fileOutputStream.close(); } SequencerCollector(boolean filterMultiFile, boolean filterMultiHunk, int hunkDistance);  SequencerCollector(boolean filterMultiFile, boolean filterMultiHunk);  SequencerCollector(); }
SequencerCollector { protected void saveFileDiff(String slug, String sha) throws IOException { System.out.println("saving file..."); URL url = new URL("https", "github.com", "/" + slug + "/commit/" + sha + ".diff"); ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream()); File f = new File(diffsPath + "/" + slug.replace("/", "-") + "-" + sha + "/commit.diff"); f.createNewFile(); FileOutputStream fileOutputStream = new FileOutputStream(f, false); fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE); fileOutputStream.close(); } SequencerCollector(boolean filterMultiFile, boolean filterMultiHunk, int hunkDistance);  SequencerCollector(boolean filterMultiFile, boolean filterMultiHunk);  SequencerCollector(); void handle(String repositorySlug, String sha); void initialize(); }
SequencerCollector { protected void saveFileDiff(String slug, String sha) throws IOException { System.out.println("saving file..."); URL url = new URL("https", "github.com", "/" + slug + "/commit/" + sha + ".diff"); ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream()); File f = new File(diffsPath + "/" + slug.replace("/", "-") + "-" + sha + "/commit.diff"); f.createNewFile(); FileOutputStream fileOutputStream = new FileOutputStream(f, false); fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE); fileOutputStream.close(); } SequencerCollector(boolean filterMultiFile, boolean filterMultiHunk, int hunkDistance);  SequencerCollector(boolean filterMultiFile, boolean filterMultiHunk);  SequencerCollector(); void handle(String repositorySlug, String sha); void initialize();  }