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