String requestLine = "GET / HTTP/1.1";
Map<String, String> headers = new HashMap<String, String>();
headers.put("host", "localhost");
HttpRequest request = new HttpRequest(requestLine, headers);
assertNotNull(app.getHandler(request));
requestLine = "GET /persons/1911 HTTP/1.1";
request = new HttpRequest(requestLine, headers);
assertNotNull(app.getHandler(request));
requestLine = "GET /persons/phone_numbers HTTP/1.1";
request = new HttpRequest(requestLine, headers);
assertNotNull(app.getHandler(request));
requestLine = "GET /pets/123 HTTP/1.1";
request = new HttpRequest(requestLine, headers);
assertNotNull(app.getHandler(request));
request = new HttpRequest("GET /missing HTTP/1.1", headers);
assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
request = new HttpRequest("GET /persons HTTP/1.1", headers);
assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
request = new HttpRequest("GET /persons/roger HTTP/1.1", headers);
assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
request = new HttpRequest("GET /persons/123a HTTP/1.1", headers);
assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
request = new HttpRequest("GET /persons/a123 HTTP/1.1", headers);
assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
request = new HttpRequest("GET /pets/a123 HTTP/1.1", headers);
assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
request = new HttpRequest("GET /pets/123a HTTP/1.1", headers);
assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
request = new HttpRequest("GET /pets/1234 HTTP/1.1", headers);
assertEquals(NotFoundRequestHandler.getInstance(), app.getHandler(request));
request = new HttpRequest("GET / HTTP/1.1", headers);
assertEquals(handler1, app.getHandler(request));
request = new HttpRequest("GET /persons/1911 HTTP/1.1", headers);
assertEquals(handler2, app.getHandler(request));
request = new HttpRequest("GET /persons/phone_numbers HTTP/1.1", headers);
assertEquals(handler3, app.getHandler(request));
request = new HttpRequest("GET /pets/123 HTTP/1.1", headers);
assertEquals(handler4, app.getHandler(request));
//Verify that BadRequestRequestHandler is returned if request does not include Host header
headers = new HashMap<String, String>();
request = new HttpRequest("GET /pets/123 HTTP/1.1", headers);
assertEquals(BadRequestRequestHandler.getInstance(), app.getHandler(request));
}