diff --git a/src/test/java/org/kohsuke/github/RepositoryMockTest.java b/src/test/java/org/kohsuke/github/RepositoryMockTest.java deleted file mode 100644 index f7dc02618f..0000000000 --- a/src/test/java/org/kohsuke/github/RepositoryMockTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.kohsuke.github; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; - -import java.util.Iterator; - -import static org.mockito.Mockito.when; - -/** - * @author Luciano P. Sabenca (luciano.sabenca [at] movile [com] | lucianosabenca [at] gmail [dot] com - */ -public class RepositoryMockTest { - - @Mock - GitHub mockGitHub; - - @Mock - GitHubPageIterator iterator; - - @Mock - GHRepository mockRepository; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void listCollaborators() throws Exception { - GHUser user1 = new GHUser(); - user1.login = "login1"; - - GHUser user2 = new GHUser(); - user2.login = "login2"; - - when(iterator.hasNext()).thenReturn(true, false, true); - when(iterator.next()).thenReturn(new GHUser[]{ user1 }, new GHUser[]{ user2 }); - - Requester requester = Mockito.mock(Requester.class); - when(mockGitHub.createRequest()).thenReturn(requester); - - when(requester.withUrlPath("/repos/*/*/collaborators")).thenReturn(requester); - - when(requester.fetchIterator(GHUser[].class, 0)).thenReturn(iterator, iterator); - - PagedIterable pagedIterable = Mockito.mock(PagedIterable.class); - when(mockRepository.listCollaborators()).thenReturn(pagedIterable); - - PagedIterator userPagedIterator = new PagedIterator(iterator) { - @Override - protected void wrapUp(GHUser[] page) { - - } - }; - PagedIterator userPagedIterator2 = new PagedIterator(iterator) { - @Override - protected void wrapUp(GHUser[] page) { - - } - }; - - when(pagedIterable.iterator()).thenReturn(userPagedIterator, userPagedIterator2); - - Iterator returnIterator1 = mockRepository.listCollaborators().iterator(); - - Assert.assertTrue(returnIterator1.hasNext()); - GHUser user = returnIterator1.next(); - Assert.assertEquals(user, user1); - Assert.assertFalse(returnIterator1.hasNext()); - - Iterator returnIterator2 = mockRepository.listCollaborators().iterator(); - - Assert.assertTrue(returnIterator2.hasNext()); - user = returnIterator1.next(); - Assert.assertEquals(user, user2); - } -}