Search in sources :

Example 6 with AdminRouteService

use of com.searchcode.app.service.route.AdminRouteService in project searchcode-server by boyter.

the class AdminRouteServiceTest method testDeleteRepo.

public void testDeleteRepo() {
    Repo mockRepo = Mockito.mock(Repo.class);
    JobService mockJobService = Mockito.mock(JobService.class);
    DataService mockDataService = Mockito.mock(DataService.class);
    AdminRouteService adminRouteService = new AdminRouteService(mockRepo, mockJobService, mockDataService, null, null, null);
    Request mockRequest = Mockito.mock(Request.class);
    when(mockRequest.queryParams("repoName")).thenReturn("myRepo");
    when(mockRepo.getRepoByName("myRepo")).thenReturn(new RepoResult());
    adminRouteService.deleteRepo(mockRequest, null);
    verify(mockDataService, times(1)).addToPersistentDelete("");
}
Also used : Repo(com.searchcode.app.dao.Repo) AdminRouteService(com.searchcode.app.service.route.AdminRouteService) Request(spark.Request) RepoResult(com.searchcode.app.model.RepoResult)

Example 7 with AdminRouteService

use of com.searchcode.app.service.route.AdminRouteService in project searchcode-server by boyter.

the class AdminRouteServiceTest method testPostRepoMultipleRepo.

public void testPostRepoMultipleRepo() {
    Repo mockRepo = Mockito.mock(Repo.class);
    JobService mockJobService = Mockito.mock(JobService.class);
    ValidatorService mockValidatorService = Mockito.mock(ValidatorService.class);
    when(mockRepo.saveRepo(any())).thenReturn(true);
    when(mockValidatorService.validate(any())).thenReturn(new ValidatorResult(true, ""));
    AdminRouteService adminRouteService = new AdminRouteService(mockRepo, mockJobService, null, null, null, mockValidatorService);
    Request mockRequest = Mockito.mock(Request.class);
    when(mockRequest.queryParamsValues("reponame")).thenReturn("name,name".split(","));
    when(mockRequest.queryParamsValues("reposcm")).thenReturn("git,git".split(","));
    when(mockRequest.queryParamsValues("repourl")).thenReturn("url,url".split(","));
    when(mockRequest.queryParamsValues("repousername")).thenReturn("username,username".split(","));
    when(mockRequest.queryParamsValues("repopassword")).thenReturn("password,password".split(","));
    when(mockRequest.queryParamsValues("reposource")).thenReturn("source,source".split(","));
    when(mockRequest.queryParamsValues("repobranch")).thenReturn("master,master".split(","));
    adminRouteService.postRepo(mockRequest, null);
    verify(mockRepo, times(2)).saveRepo(any());
    verify(mockJobService, times(2)).forceEnqueue(any());
    verify(mockValidatorService, times(2)).validate(any());
}
Also used : Repo(com.searchcode.app.dao.Repo) ValidatorResult(com.searchcode.app.model.ValidatorResult) AdminRouteService(com.searchcode.app.service.route.AdminRouteService) Request(spark.Request)

Aggregations

AdminRouteService (com.searchcode.app.service.route.AdminRouteService)7 Request (spark.Request)7 HashSet (java.util.HashSet)4 Repo (com.searchcode.app.dao.Repo)3 RepoResult (com.searchcode.app.model.RepoResult)1 ValidatorResult (com.searchcode.app.model.ValidatorResult)1