BsonRequest extends ServiceRequest<BsonValue> { public static BsonRequest init(HttpServerExchange exchange) { var ret = new BsonRequest(exchange); try { ret.injectContent(); } catch (Throwable ieo) { ret.setInError(true); } return ret; } protected  BsonRequest(HttpServerExchange exchange); static BsonRequest init(HttpServerExchange exchange); static BsonRequest of(HttpServerExchange exchange); void injectContent();  }
@Test @SuppressWarnings("deprecation") public void testGetMappedRequestUri() { HttpServerExchange ex = mock(HttpServerExchange.class); when(ex.getRequestPath()).thenReturn("/"); when(ex.getRequestMethod()).thenReturn(HttpString.EMPTY); String whatUri = "/db/mycollection"; String whereUri = "/"; MongoRequest request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/db/mycollection", request.getUnmappedRequestUri()); whatUri = "*"; whereUri = "/"; request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/", request.getUnmappedRequestUri()); whatUri = "*"; whereUri = "/data"; request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/", request.getUnmappedRequestUri()); whatUri = "/data"; whereUri = "/"; request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/data", request.getUnmappedRequestUri()); whatUri = "/db/coll"; whereUri = "/"; request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/db/coll", request.getUnmappedRequestUri()); whatUri = "/db/coll/doc"; whereUri = "/"; request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/db/coll/doc", request.getUnmappedRequestUri()); whatUri = "/db/coll/"; whereUri = "/"; request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/db/coll", request.getUnmappedRequestUri()); whatUri = "/db/coll whereUri = "/"; request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/db/coll", request.getUnmappedRequestUri()); }
@Test @SuppressWarnings("deprecation") public void testGetMappedRequestUri2() { HttpServerExchange ex = mock(HttpServerExchange.class); when(ex.getRequestPath()).thenReturn("/x"); when(ex.getRequestMethod()).thenReturn(HttpString.EMPTY); String whatUri = "/db/mycollection"; String whereUri = "/"; MongoRequest request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/db/mycollection/x", request.getUnmappedRequestUri()); whatUri = "*"; whereUri = "/"; request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/x", request.getUnmappedRequestUri()); whatUri = "db"; whereUri = "/"; request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/db/x", request.getUnmappedRequestUri()); whatUri = "db/coll"; whereUri = "/"; request = MongoRequest.init(ex, whereUri, whatUri); assertEquals("/db/coll/x", request.getUnmappedRequestUri()); }