use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class ApiRouteServiceTest method testGetIndexTime.
public void testGetIndexTime() {
Request mockRequest = mock(Request.class);
Repo repoMock = mock(Repo.class);
when(mockRequest.queryParams("reponame")).thenReturn("somename");
when(mockRequest.queryParams()).thenReturn((new HashMap<String, String>() {
{
put("reponame", "reponame");
}
}).keySet());
when(repoMock.getRepoByName("somename")).thenReturn(new RepoResult(0, "name", "scm", "url", "username", "password", "source", "branch", "\n" + "{\"rowId\":1,\"name\":\"test\",\"scm\":\"git\",\"url\":\"/test/\",\"username\":\"\",\"password\":\"\",\"source\":\"\",\"branch\":\"master\",\"data\":{\"averageIndexTimeSeconds\":9,\"indexStatus\":\"success\",\"jobRunTime\":{\"seconds\":1496356541,\"nanos\":188000000}}}"));
ApiRouteService apiRouteService = new ApiRouteService(null, null, repoMock, null, null);
String averageIndexTimeSeconds = apiRouteService.getIndexTime(mockRequest, null);
assertThat(averageIndexTimeSeconds).isEqualTo("0 seconds ago");
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class ValidatorServiceTest method testValidatorServiceExistingName.
public void testValidatorServiceExistingName() {
Repo mockRepo = mock(Repo.class);
ValidatorService validatorService = new ValidatorService(mockRepo, new Helpers());
when(mockRepo.getRepoByName("exists")).thenReturn(new RepoResult());
RepoResult repoResult = new RepoResult(0, "exists", "something", "url", "", "", "source", "branch", "{}");
ValidatorResult validate = validatorService.validate(repoResult);
assertThat(validate.isValid).isFalse();
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class ValidatorServiceTest method testRepoResultInValidReponame.
public void testRepoResultInValidReponame() {
ValidatorService validatorService = new ValidatorService();
ValidatorResult validate = validatorService.validate(new RepoResult(0, "some/thing", "something", "url", "", "", "source", "branch", "{}"));
assertThat(validate.isValid).isFalse();
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class UniqueRepoQueueTest method testEnqueueDifferent.
public void testEnqueueDifferent() {
UniqueRepoQueue queue = new UniqueRepoQueue(new ConcurrentArrayQueue<>());
RepoResult rr1 = new RepoResult(1, "name", "scm", "url", "username", "password", "source", "branch", "");
RepoResult rr2 = new RepoResult(2, "name2", "scm", "url", "username", "password", "source", "branch", "");
queue.add(rr1);
queue.add(rr2);
assertEquals(2, queue.size());
}
use of com.searchcode.app.model.RepoResult in project searchcode-server by boyter.
the class UniqueRepoQueueTest method testBleedingBetweenUniqueQueues.
public void testBleedingBetweenUniqueQueues() {
UniqueRepoQueue queue1 = Singleton.getUniqueGitRepoQueue();
UniqueRepoQueue queue2 = Singleton.getUniqueSvnRepoQueue();
RepoResult rr1 = new RepoResult(1, "name", "git", "url", "username", "password", "source", "branch", "");
RepoResult rr2 = new RepoResult(2, "name2", "svn", "url", "username", "password", "source", "branch", "");
queue1.add(rr1);
queue2.add(rr2);
assertEquals(1, queue1.size());
assertEquals(1, queue2.size());
assertTrue(rr1.equals(queue1.poll()));
assertTrue(rr2.equals(queue2.poll()));
}
Aggregations