use of com.searchcode.app.service.route.AdminRouteService in project searchcode-server by boyter.
the class AdminRouteServiceTest method testGetStatLogs.
public void testGetStatLogs() {
AdminRouteService adminRouteService = new AdminRouteService();
Singleton.getLogger().apiLog("test");
Singleton.getLogger().warning("test");
Singleton.getLogger().searchLog("test");
Singleton.getLogger().severe("test");
Singleton.getLogger().info("test");
List<String> statValue = Arrays.asList("alllogs", "infologs", "warninglogs", "severelogs", "searchlogs", "apilogs");
for (String stat : statValue) {
Request mockRequest = Mockito.mock(Request.class);
Set<String> returnSet = new HashSet<>();
returnSet.add("statname");
when(mockRequest.queryParams()).thenReturn(returnSet);
when(mockRequest.queryParams("statname")).thenReturn(stat);
String result = adminRouteService.getStat(mockRequest, null);
assertThat(result).as("For value %s", stat).isNotEmpty();
}
}
use of com.searchcode.app.service.route.AdminRouteService in project searchcode-server by boyter.
the class AdminRouteServiceTest method testPostRepoRepoNamesEmptyNothing.
public void testPostRepoRepoNamesEmptyNothing() {
Repo mockRepo = Mockito.mock(Repo.class);
JobService mockJobService = Mockito.mock(JobService.class);
AdminRouteService adminRouteService = new AdminRouteService(mockRepo, mockJobService, null, null, null, null);
Request mockRequest = Mockito.mock(Request.class);
when(mockRequest.queryParamsValues("reponame")).thenReturn(new String[0]);
when(mockRequest.queryParamsValues("reposcm")).thenReturn(new String[0]);
when(mockRequest.queryParamsValues("repourl")).thenReturn(new String[0]);
when(mockRequest.queryParamsValues("repousername")).thenReturn(new String[0]);
when(mockRequest.queryParamsValues("repopassword")).thenReturn(new String[0]);
when(mockRequest.queryParamsValues("reposource")).thenReturn(new String[0]);
when(mockRequest.queryParamsValues("repobranch")).thenReturn(new String[0]);
adminRouteService.postRepo(mockRequest, null);
}
use of com.searchcode.app.service.route.AdminRouteService in project searchcode-server by boyter.
the class AdminRouteServiceTest method testCheckIndexStatus.
public void testCheckIndexStatus() {
AdminRouteService adminRouteService = new AdminRouteService();
Request mockRequest = Mockito.mock(Request.class);
Set<String> returnSet = new HashSet<>();
returnSet.add("reponame");
when(mockRequest.queryParams()).thenReturn(returnSet);
when(mockRequest.queryParams("reponame")).thenReturn("hopefullyarandomnamethatdoesnotexist");
String result = adminRouteService.checkIndexStatus(mockRequest, null);
assertThat(result).isEmpty();
}
use of com.searchcode.app.service.route.AdminRouteService in project searchcode-server by boyter.
the class AdminRouteServiceTest method testGetStatValuesExpectEmpty.
public void testGetStatValuesExpectEmpty() {
AdminRouteService adminRouteService = new AdminRouteService();
Singleton.getLogger().clearAllLogs();
List<String> statValue = Arrays.asList(null, "", "runningjobs", "alllogs", "infologs", "warninglogs", "severelogs", "searchlogs");
for (String stat : statValue) {
Request mockRequest = Mockito.mock(Request.class);
Set<String> returnSet = new HashSet<>();
returnSet.add("statname");
when(mockRequest.queryParams()).thenReturn(returnSet);
when(mockRequest.queryParams("statname")).thenReturn(stat);
String result = adminRouteService.getStat(mockRequest, null);
assertThat(result).as("For value %s", stat).isEmpty();
}
}
use of com.searchcode.app.service.route.AdminRouteService in project searchcode-server by boyter.
the class AdminRouteServiceTest method testGetStatValuesExpectValue.
public void testGetStatValuesExpectValue() {
SharedService sharedServiceMock = Mockito.mock(SharedService.class);
StatsService statsServiceMock = Mockito.mock(StatsService.class);
when(statsServiceMock.getMemoryUsage(any())).thenReturn("Yep");
when(statsServiceMock.getLoadAverage()).thenReturn("Yep");
when(statsServiceMock.getUptime()).thenReturn("Yep");
AdminRouteService adminRouteService = new AdminRouteService(null, null, null, sharedServiceMock, statsServiceMock, null);
List<String> statValue = Arrays.asList("memoryusage", "loadaverage", "uptime", "searchcount", "spellingcount", "repocount", "numdocs", "servertime", "deletionqueue");
for (String stat : statValue) {
Request mockRequest = Mockito.mock(Request.class);
Set<String> returnSet = new HashSet<>();
returnSet.add("statname");
when(mockRequest.queryParams()).thenReturn(returnSet);
when(mockRequest.queryParams("statname")).thenReturn(stat);
String result = adminRouteService.getStat(mockRequest, null);
assertThat(result).as("For value %s", stat).isNotEmpty();
}
}
Aggregations