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