Search in sources :

Example 1 with SharedService

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());
}
Also used : RepositoryChanged(com.searchcode.app.dto.RepositoryChanged) SharedService(com.searchcode.app.service.SharedService) IndexGitRepoJob(com.searchcode.app.jobs.repository.IndexGitRepoJob) UniqueRepoQueue(com.searchcode.app.util.UniqueRepoQueue) RepoResult(com.searchcode.app.model.RepoResult)

Aggregations

RepositoryChanged (com.searchcode.app.dto.RepositoryChanged)1 IndexGitRepoJob (com.searchcode.app.jobs.repository.IndexGitRepoJob)1 RepoResult (com.searchcode.app.model.RepoResult)1 SharedService (com.searchcode.app.service.SharedService)1 UniqueRepoQueue (com.searchcode.app.util.UniqueRepoQueue)1