use of com.searchcode.app.model.RepoResult 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());
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class RepoResultTest method testGetJSONCheck.
public void testGetJSONCheck() {
RepoResult repoResult = new RepoResult();
RepoData repoData = new RepoData();
repoData.averageIndexTimeSeconds = 20;
repoData.indexStatus = "indexing";
repoResult.setData(repoData);
String actual = repoResult.getDataAsJson();
assertThat(actual).contains("{\"averageIndexTimeSeconds\":20,\"indexStatus\":\"indexing\"");
assertThat(actual).contains("\"jobRunTime\":{\"seconds\":");
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class RepoResultTest method testGetNameFileOnlyAsciiMultiple.
public void testGetNameFileOnlyAsciiMultiple() {
RepoResult repoResult = new RepoResult();
repoResult.setName("社會test社會");
repoResult.setRowId(1);
String actual = repoResult.getDirectoryName();
assertThat(actual).isEqualTo("1test1");
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class RepoTest method testRepoSaveDelete.
public void testRepoSaveDelete() {
this.repo.saveRepo(new RepoResult(-1, "myname", "git", "myurl", "username", "password", "mysource", "mybranch", "{}"));
RepoResult result = this.repo.getRepoByName("myname");
assertThat(result.getName()).isEqualTo("myname");
assertThat(result.getScm()).isEqualTo("git");
assertThat(result.getUrl()).isEqualTo("myurl");
assertThat(result.getUsername()).isEqualTo("username");
assertThat(result.getPassword()).isEqualTo("password");
assertThat(result.getSource()).isEqualTo("mysource");
assertThat(result.getBranch()).isEqualTo("mybranch");
assertThat(result.getData().averageIndexTimeSeconds).isEqualTo(0);
this.repo.deleteRepoByName("myname");
result = this.repo.getRepoByName("myname");
assertThat(result).isNull();
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class RepoTest method testSearchRepo.
public void testSearchRepo() {
this.repo.saveRepo(new RepoResult(-1, "testGetPagedRepo1", "git", "myurl", "username", "password", "mysource", "mybranch", "{}"));
this.repo.saveRepo(new RepoResult(-1, "testGetPagedRepo2", "git", "myurl", "username", "password", "mysource", "mybranch", "{}"));
this.repo.saveRepo(new RepoResult(-1, "testGetPagedRepo3", "git", "myurl", "username", "password", "mysource", "mybranch", "{}"));
this.repo.saveRepo(new RepoResult(-1, "testGetPagedRepo4", "git", "myurl", "username", "password", "mysource", "mybranch", "{}"));
this.repo.saveRepo(new RepoResult(-1, "testGetPagedRepo5", "svn", "myurl", "username", "password", "mysource", "mybranch", "{}"));
assertThat(this.repo.searchRepo("PassworD").size()).isEqualTo(5);
assertThat(this.repo.searchRepo("TESTGetPagedRepo1").size()).isEqualTo(1);
assertThat(this.repo.searchRepo("svn testGetPagedRepo5").size()).isEqualTo(1);
assertThat(this.repo.searchRepo("svn testGetPagedRepo5").size()).isEqualTo(1);
this.repo.deleteRepoByName("testGetPagedRepo1");
this.repo.deleteRepoByName("testGetPagedRepo2");
this.repo.deleteRepoByName("testGetPagedRepo3");
this.repo.deleteRepoByName("testGetPagedRepo4");
this.repo.deleteRepoByName("testGetPagedRepo5");
}
Aggregations