use of com.searchcode.app.service.route.CodeRouteService in project searchcode-server by boyter.
the class CodeRouteServiceTest method testGetCodeNoParams.
public void testGetCodeNoParams() {
CodeRouteService codeRouteService = new CodeRouteService();
Request request = Mockito.mock(Request.class);
Response response = Mockito.mock(Response.class);
try {
codeRouteService.getCode(request, response);
} catch (HaltException ex) {
}
verify(response, times(1)).redirect("/404/");
}
use of com.searchcode.app.service.route.CodeRouteService in project searchcode-server by boyter.
the class CodeRouteServiceTest method testGetCodeWithParamsNoMatch.
public void testGetCodeWithParamsNoMatch() {
CodeRouteService codeRouteService = new CodeRouteService();
Request request = Mockito.mock(Request.class);
Response response = Mockito.mock(Response.class);
when(request.params(":codeid")).thenReturn("NOTHING-SHOULD-MATCH-THIS-EVER");
try {
codeRouteService.getCode(request, response);
} catch (HaltException ex) {
}
verify(response, times(1)).redirect("/404/");
}
use of com.searchcode.app.service.route.CodeRouteService in project searchcode-server by boyter.
the class CodeRouteServiceTest method testGetProject.
public void testGetProject() {
CodeRouteService codeRouteService = new CodeRouteService();
Request request = Mockito.mock(Request.class);
Response response = Mockito.mock(Response.class);
try {
codeRouteService.getProject(request, response);
} catch (HaltException ex) {
}
verify(response, times(1)).redirect("/404/");
}
use of com.searchcode.app.service.route.CodeRouteService in project searchcode-server by boyter.
the class CodeRouteServiceTest method testRootNoQueryString.
public void testRootNoQueryString() {
CodeRouteService codeRouteService = new CodeRouteService();
Request request = Mockito.mock(Request.class);
Data mockData = Mockito.mock(Data.class);
when(mockData.getDataByName(Values.LOGO, Values.EMPTYSTRING)).thenReturn(Values.EMPTYSTRING);
Singleton.setData(mockData);
ModelAndView modelAndView = codeRouteService.root(request, null);
Map<String, Object> model = (Map<String, Object>) modelAndView.getModel();
String viewName = modelAndView.getViewName();
assertThat(model.get("photoId")).isInstanceOf(Integer.class);
assertThat((int) model.get("photoId")).isGreaterThanOrEqualTo(0);
assertThat((int) model.get("photoId")).isLessThanOrEqualTo(4);
assertThat(model.get("numDocs")).isInstanceOf(Integer.class);
assertThat((int) model.get("numDocs")).isGreaterThanOrEqualTo(0);
assertThat(model.get("logoImage")).isNotNull();
assertThat(model.get("isCommunity")).isEqualTo(App.ISCOMMUNITY);
assertThat(viewName).isEqualTo("index.ftl");
}
use of com.searchcode.app.service.route.CodeRouteService in project searchcode-server by boyter.
the class CodeRouteServiceTest method testHtmlNoQueryString.
public void testHtmlNoQueryString() {
CodeRouteService codeRouteService = new CodeRouteService();
Request request = Mockito.mock(Request.class);
ModelAndView modelAndView = codeRouteService.html(request, null);
Map<String, Object> model = (Map<String, Object>) modelAndView.getModel();
String viewName = modelAndView.getViewName();
assertThat(model.get("photoId")).isInstanceOf(Integer.class);
assertThat((int) model.get("photoId")).isGreaterThanOrEqualTo(0);
assertThat((int) model.get("photoId")).isLessThanOrEqualTo(4);
assertThat(model.get("numDocs")).isInstanceOf(Integer.class);
assertThat((int) model.get("numDocs")).isGreaterThanOrEqualTo(0);
assertThat(model.get("logoImage")).isNotNull();
assertThat(model.get("isCommunity")).isEqualTo(App.ISCOMMUNITY);
assertThat(viewName).isEqualTo("index.ftl");
}
Aggregations