Search in sources :

Example 51 with Helpers

use of com.searchcode.app.util.Helpers in project searchcode-server by boyter.

the class ApiRouteServiceTest method testRepoAddMissingRepoUrl.

public void testRepoAddMissingRepoUrl() {
    Request mockRequest = mock(Request.class);
    SQLiteRepo mockSQLiteRepo = mock(SQLiteRepo.class);
    ApiRouteService apiRouteService = new ApiRouteService(null, null, mockSQLiteRepo, null, null, null, new Helpers(), new LoggerWrapper());
    apiRouteService.apiEnabled = true;
    apiRouteService.apiAuth = false;
    when(mockRequest.queryParams("reponame")).thenReturn("test");
    ApiResponse apiResponse = apiRouteService.repoAdd(mockRequest, null);
    assertThat(apiResponse.getMessage()).isEqualTo("repourl is a required parameter");
    assertThat(apiResponse.isSucessful()).isFalse();
}
Also used : ApiRouteService(com.searchcode.app.service.route.ApiRouteService) Helpers(com.searchcode.app.util.Helpers) LoggerWrapper(com.searchcode.app.util.LoggerWrapper) Request(spark.Request) SQLiteRepo(com.searchcode.app.dao.SQLiteRepo) ApiResponse(com.searchcode.app.dto.api.ApiResponse) RepoResultApiResponse(com.searchcode.app.dto.api.RepoResultApiResponse)

Example 52 with Helpers

use of com.searchcode.app.util.Helpers in project searchcode-server by boyter.

the class ValidatorServiceTest method testValidatorServiceExistingNameIgnored.

public void testValidatorServiceExistingNameIgnored() {
    SQLiteRepo mockSQLiteRepo = mock(SQLiteRepo.class);
    ValidatorService validatorService = new ValidatorService(mockSQLiteRepo, new Helpers());
    when(mockSQLiteRepo.getRepoByName("exists")).thenReturn(Optional.of(new RepoResult()));
    RepoResult repoResult = new RepoResult().setRowId(0).setName("exists").setScm("something").setUrl("url").setUsername("").setPassword("").setSource("source").setBranch("branch").setData("{}");
    ValidatorResult validate = validatorService.validate(repoResult, true);
    assertThat(validate.isValid).isTrue();
}
Also used : Helpers(com.searchcode.app.util.Helpers) ValidatorResult(com.searchcode.app.model.ValidatorResult) SQLiteRepo(com.searchcode.app.dao.SQLiteRepo) RepoResult(com.searchcode.app.model.RepoResult)

Example 53 with Helpers

use of com.searchcode.app.util.Helpers in project searchcode-server by boyter.

the class ValidatorServiceTest method testValidatorServiceExistingName.

public void testValidatorServiceExistingName() {
    SQLiteRepo mockSQLiteRepo = mock(SQLiteRepo.class);
    ValidatorService validatorService = new ValidatorService(mockSQLiteRepo, new Helpers());
    when(mockSQLiteRepo.getRepoByName("exists")).thenReturn(Optional.of(new RepoResult()));
    RepoResult repoResult = new RepoResult().setRowId(0).setName("exists").setScm("something").setUrl("url").setUsername("").setPassword("").setSource("source").setBranch("branch").setData("{}");
    ValidatorResult validate = validatorService.validate(repoResult, false);
    assertThat(validate.isValid).isFalse();
}
Also used : Helpers(com.searchcode.app.util.Helpers) ValidatorResult(com.searchcode.app.model.ValidatorResult) SQLiteRepo(com.searchcode.app.dao.SQLiteRepo) RepoResult(com.searchcode.app.model.RepoResult)

Aggregations

Helpers (com.searchcode.app.util.Helpers)53 LoggerWrapper (com.searchcode.app.util.LoggerWrapper)32 ApiRouteService (com.searchcode.app.service.route.ApiRouteService)31 Request (spark.Request)31 RepoResultApiResponse (com.searchcode.app.dto.api.RepoResultApiResponse)29 SQLiteRepo (com.searchcode.app.dao.SQLiteRepo)27 ApiResponse (com.searchcode.app.dto.api.ApiResponse)26 RepoResult (com.searchcode.app.model.RepoResult)12 ApiResult (com.searchcode.app.model.ApiResult)9 Data (com.searchcode.app.dao.Data)5 ValidatorResult (com.searchcode.app.model.ValidatorResult)4 IndexService (com.searchcode.app.service.index.IndexService)3 UniqueRepoQueue (com.searchcode.app.util.UniqueRepoQueue)3 SQLiteMemoryDatabaseConfig (com.searchcode.app.config.SQLiteMemoryDatabaseConfig)2 SourceResult (com.searchcode.app.model.SourceResult)2 Matchers.anyString (org.mockito.Matchers.anyString)2 CodeIndexDocument (com.searchcode.app.dto.CodeIndexDocument)1 CodeResult (com.searchcode.app.dto.CodeResult)1 SearchResult (com.searchcode.app.dto.SearchResult)1 CodeRouteService (com.searchcode.app.service.route.CodeRouteService)1