Skip to content

Commit

Permalink
Add test shouldHandleUriWithQueryParametersWhenReplacingPathElementBy…
Browse files Browse the repository at this point in the history
…IndexFromEnd
  • Loading branch information
monaullah committed Dec 4, 2024
1 parent 6edfccf commit 314d4ce
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/src/test/java/nva/commons/core/paths/UriWrapperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,17 @@ void shouldHandleUriWithPathEndingWithSlashWhenReplacingPathElementByIndexFromEn
assertThat(actualUri, is(equalTo(expectedUri)));
}

@Test
void shouldHandleUriWithQueryParametersWhenReplacingPathElementByIndexFromEnd() {
var originalUri = URI.create("https://example.org/myPath?queryParam=someValue/with/delimiters");
var replacement = "replacement";
var expectedUri = URI.create("https://example.org/replacement?queryParam=someValue/with/delimiters");
var actualUri = UriWrapper.fromUri(originalUri)
.replacePathElementByIndexFromEnd(0, replacement)
.getUri();
assertThat(actualUri, is(equalTo(expectedUri)));
}

@Test
void shouldDoNothingWhenReplacingElementWhenPathIsRoot() {
var originalUri = URI.create("https://example.org/");
Expand Down

0 comments on commit 314d4ce

Please sign in to comment.