Search in sources :

Example 21 with RepoResult

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());
}
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)

Example 22 with RepoResult

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\":");
}
Also used : RepoResult(com.searchcode.app.model.RepoResult)

Example 23 with RepoResult

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");
}
Also used : RepoResult(com.searchcode.app.model.RepoResult)

Example 24 with RepoResult

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();
}
Also used : RepoResult(com.searchcode.app.model.RepoResult)

Example 25 with RepoResult

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");
}
Also used : RepoResult(com.searchcode.app.model.RepoResult)

Aggregations

RepoResult (com.searchcode.app.model.RepoResult)59 Repo (com.searchcode.app.dao.Repo)13 ApiResponse (com.searchcode.app.dto.api.ApiResponse)9 RepoResultApiResponse (com.searchcode.app.dto.api.RepoResultApiResponse)9 Request (spark.Request)9 ValidatorResult (com.searchcode.app.model.ValidatorResult)8 ApiRouteService (com.searchcode.app.service.route.ApiRouteService)8 UniqueRepoQueue (com.searchcode.app.util.UniqueRepoQueue)8 Connection (java.sql.Connection)5 PreparedStatement (java.sql.PreparedStatement)5 SQLException (java.sql.SQLException)5 ResultSet (java.sql.ResultSet)4 ArrayList (java.util.ArrayList)3 RepositoryChanged (com.searchcode.app.dto.RepositoryChanged)2 RunningIndexJob (com.searchcode.app.dto.RunningIndexJob)2 File (java.io.File)2 Gson (com.google.gson.Gson)1 Data (com.searchcode.app.dao.Data)1 IndexBaseRepoJob (com.searchcode.app.jobs.repository.IndexBaseRepoJob)1 IndexFileRepoJob (com.searchcode.app.jobs.repository.IndexFileRepoJob)1