use of com.searchcode.app.service.SharedService in project searchcode-server by boyter.
the class IndexBaseRepoJobTest method testExecuteHasMethodInQueueNewRepository.
public void testExecuteHasMethodInQueueNewRepository() throws JobExecutionException {
SharedService sharedServiceMock = mock(SharedService.class);
when(sharedServiceMock.getPauseBackgroundJobs()).thenReturn(false);
when(sharedServiceMock.getBackgroundJobsEnabled()).thenReturn(true);
IndexGitRepoJob indexGitRepoJob = new IndexGitRepoJob(sharedServiceMock);
IndexGitRepoJob spy = spy(indexGitRepoJob);
spy.haveRepoResult = false;
UniqueRepoQueue uniqueRepoQueue = new UniqueRepoQueue();
uniqueRepoQueue.add(new RepoResult(1, "name", "scm", "url", "username", "password", "source", "branch", "{}"));
when(spy.getNextQueuedRepo()).thenReturn(uniqueRepoQueue);
when(spy.isEnabled()).thenReturn(true);
when(spy.getNewRepository(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyBoolean())).thenReturn(new RepositoryChanged(false, null, null));
when(mockCodeIndexer.shouldPauseAdding()).thenReturn(false);
spy.codeIndexer = mockCodeIndexer;
spy.execute(this.mockContext);
assertThat(spy.haveRepoResult).isTrue();
assertThat(spy.LOWMEMORY).isTrue();
verify(spy).getNextQueuedRepo();
verify(spy, times(2)).getNewRepository(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyBoolean());
}
Aggregations