File tree 1 file changed +28
-0
lines changed
commons/src/test/java/org/restheart/exchange
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,34 @@ public void testPathTemplatedMappedRequest() {
245
245
assertEquals ("acme_coll" , request .getCollectionName ());
246
246
}
247
247
248
+ /**
249
+ *
250
+ */
251
+ @ Test
252
+ public void testPathTemplatedMappedRequestWithWildcard () {
253
+ var requestPath = "/acme/coll/docid" ;
254
+
255
+ // Here mimic MongoService that attach PathTemplateMatch to the exchange
256
+ PathTemplateMatcher <MongoMount > templateMongoMounts = new PathTemplateMatcher <>();
257
+ String whatUri = "/restheart/{tenant}_{coll}" ;
258
+ String whereUri = "/{tenant}/{coll}/*" ;
259
+ var mongoMount = new MongoMount (whatUri ,whereUri );
260
+ templateMongoMounts .add (mongoMount .uri , mongoMount );
261
+
262
+ var tmm = templateMongoMounts .match (requestPath );
263
+
264
+ HttpServerExchange ex = mock (HttpServerExchange .class );
265
+ when (ex .getRequestPath ()).thenReturn (requestPath );
266
+ when (ex .getRequestMethod ()).thenReturn (HttpString .EMPTY );
267
+ when (ex .getAttachment (PathTemplateMatch .ATTACHMENT_KEY )).thenReturn (tmm );
268
+
269
+ MongoRequest request = MongoRequest .init (ex , whereUri , whatUri );
270
+
271
+ assertEquals ("/restheart/acme_coll/docid" , request .getUnmappedRequestUri ());
272
+ assertEquals ("restheart" , request .getDBName ());
273
+ assertEquals ("acme_coll" , request .getCollectionName ());
274
+ }
275
+
248
276
/**
249
277
* helper class to store mongo mounts info
250
278
*/
You can’t perform that action at this time.
0 commit comments